Class: Bugstack::Event
- Inherits:
-
Object
- Object
- Bugstack::Event
- Defined in:
- lib/bugstack/event.rb
Overview
Represents an error event to be sent to BugStack.
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#exception_type ⇒ Object
Returns the value of attribute exception_type.
-
#file ⇒ Object
Returns the value of attribute file.
-
#fingerprint ⇒ Object
Returns the value of attribute fingerprint.
-
#function ⇒ Object
Returns the value of attribute function.
-
#message ⇒ Object
Returns the value of attribute message.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#request ⇒ Object
Returns the value of attribute request.
-
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(message:, stack_trace: "", file: "", function: "", fingerprint: "", exception_type: "", request: nil, environment: nil, timestamp: nil, metadata: {}) ⇒ Event
constructor
A new instance of Event.
-
#to_payload(config) ⇒ Hash
Serialize to the standard BugStack API payload.
Constructor Details
#initialize(message:, stack_trace: "", file: "", function: "", fingerprint: "", exception_type: "", request: nil, environment: nil, timestamp: nil, metadata: {}) ⇒ Event
Returns a new instance of Event.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bugstack/event.rb', line 12 def initialize( message:, stack_trace: "", file: "", function: "", fingerprint: "", exception_type: "", request: nil, environment: nil, timestamp: nil, metadata: {} ) @message = @stack_trace = stack_trace @file = file @function = function @fingerprint = fingerprint @exception_type = exception_type @request = request @environment = environment || default_environment @timestamp = || Time.now.utc.iso8601 @metadata = || {} end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def environment @environment end |
#exception_type ⇒ Object
Returns the value of attribute exception_type.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def exception_type @exception_type end |
#file ⇒ Object
Returns the value of attribute file.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def file @file end |
#fingerprint ⇒ Object
Returns the value of attribute fingerprint.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def fingerprint @fingerprint end |
#function ⇒ Object
Returns the value of attribute function.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def function @function end |
#message ⇒ Object
Returns the value of attribute message.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def @message end |
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def @metadata end |
#request ⇒ Object
Returns the value of attribute request.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def request @request end |
#stack_trace ⇒ Object
Returns the value of attribute stack_trace.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def stack_trace @stack_trace end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
9 10 11 |
# File 'lib/bugstack/event.rb', line 9 def @timestamp end |
Instance Method Details
#to_payload(config) ⇒ Hash
Serialize to the standard BugStack API payload.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bugstack/event.rb', line 40 def to_payload(config) payload = { "apiKey" => config.api_key, "error" => { "message" => @message, "stackTrace" => @stack_trace, "file" => @file, "function" => @function, "fingerprint" => @fingerprint }, "environment" => { "language" => @environment[:language], "languageVersion" => @environment[:language_version], "framework" => @environment[:framework].to_s, "frameworkVersion" => @environment[:framework_version].to_s, "os" => @environment[:os], "sdkVersion" => @environment[:sdk_version] }, "timestamp" => @timestamp } if @request payload["request"] = { "route" => @request[:route].to_s, "method" => @request[:method].to_s } end payload["projectId"] = config.project_id unless config.project_id.empty? = @metadata.dup ["autoFix"] = true if config.auto_fix payload["metadata"] = unless .empty? payload end |