Class: Contrast::Agent::Reporting::ApplicationInventoryActivity
- Inherits:
-
ApplicationReportingEvent
- Object
- ReportableHash
- ReportingEvent
- ApplicationReportingEvent
- Contrast::Agent::Reporting::ApplicationInventoryActivity
- Defined in:
- lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb
Overview
This is the new ApplicationInventoryActivity class which will include all the information about the inventory of the application which was discovered during exercise of the application during this activity period.
Instance Attribute Summary collapse
-
#browsers ⇒ Object
readonly
@ return [Array<String>] - User-Agent Header value.
-
#components ⇒ Object
readonly
return [Array<Contrast::Agent::Reporting::ArchitectureComponent>].
Attributes inherited from ReportingEvent
#event_endpoint, #event_method
Instance Method Summary collapse
- #attach_data(architectures) ⇒ Object
- #duration ⇒ Object
-
#empty? ⇒ Boolean
Helper method to determine if InventoryActivity has no data.
-
#initialize ⇒ ApplicationInventoryActivity
constructor
A new instance of ApplicationInventoryActivity.
- #to_controlled_hash ⇒ Object
Methods inherited from ReportingEvent
Methods inherited from ReportableHash
#event_json, #valid?, #validate
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize ⇒ ApplicationInventoryActivity
Returns a new instance of ApplicationInventoryActivity.
21 22 23 24 25 26 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 21 def initialize @event_type = :application_inventory_activity @browsers = [] @components = [] super() end |
Instance Attribute Details
#browsers ⇒ Object (readonly)
@ return [Array<String>] - User-Agent Header value
19 20 21 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 19 def browsers @browsers end |
#components ⇒ Object (readonly)
return [Array<Contrast::Agent::Reporting::ArchitectureComponent>]
17 18 19 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 17 def components @components end |
Instance Method Details
#attach_data(architectures) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 38 def attach_data architectures Array(architectures).each do |architecture| @components << architecture end request_headers = Contrast::Agent::REQUEST_TRACKER.current&.request&.headers @browsers << request_headers['USER_AGENT'] if request_headers end |
#duration ⇒ Object
46 47 48 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 46 def duration Contrast::Utils::Timer.now_ms - (Contrast::Agent::REQUEST_TRACKER.current&.timer&.start_ms || 0) end |
#empty? ⇒ Boolean
Helper method to determine if InventoryActivity has no data
51 52 53 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 51 def empty? @browsers.empty? && @components.empty? end |
#to_controlled_hash ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb', line 28 def to_controlled_hash { activityDuration: duration, browsers: browsers, components: components.map(&:to_controlled_hash) } end |