Class: Gitlab::Tracking::Destinations::Snowplow
- Inherits:
-
Object
- Object
- Gitlab::Tracking::Destinations::Snowplow
- Defined in:
- lib/gitlab/tracking/destinations/snowplow.rb
Direct Known Subclasses
Constant Summary collapse
- SNOWPLOW_NAMESPACE =
'gl'- DEDICATED_APP_ID =
'gitlab_dedicated'- SELF_MANAGED_APP_ID =
'gitlab_sm'
Instance Attribute Summary collapse
-
#destination_configuration ⇒ Object
readonly
Returns the value of attribute destination_configuration.
Instance Method Summary collapse
- #app_id ⇒ Object
- #emit_event_payload(payload) ⇒ Object
- #event(category, action, label: nil, property: nil, value: nil, context: nil) ⇒ Object
- #frontend_client_options(group) ⇒ Object
-
#initialize(destination_configuration = DestinationConfiguration.snowplow_configuration) ⇒ Snowplow
constructor
A new instance of Snowplow.
Constructor Details
#initialize(destination_configuration = DestinationConfiguration.snowplow_configuration) ⇒ Snowplow
Returns a new instance of Snowplow.
17 18 19 20 |
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 17 def initialize(destination_configuration = DestinationConfiguration.snowplow_configuration) @destination_configuration = destination_configuration @event_eligibility_checker = Gitlab::Tracking::EventEligibilityChecker.new end |
Instance Attribute Details
#destination_configuration ⇒ Object (readonly)
Returns the value of attribute destination_configuration.
15 16 17 |
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 15 def destination_configuration @destination_configuration end |
Instance Method Details
#app_id ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 51 def app_id if Gitlab::CurrentSettings.snowplow_enabled? Gitlab::CurrentSettings.snowplow_app_id else product_usage_event_app_id end end |
#emit_event_payload(payload) ⇒ Object
37 38 39 40 41 |
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 37 def emit_event_payload(payload) # Using #input as the tracker doesn't have an option to track using a json object # https://snowplow.github.io/snowplow-ruby-tracker/SnowplowTracker/Emitter.html#input-instance_method emitter.input(payload) end |
#event(category, action, label: nil, property: nil, value: nil, context: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 22 def event(category, action, label: nil, property: nil, value: nil, context: nil) return unless @event_eligibility_checker.eligible?(action) tracker.track_struct_event( category: category, action: action, label: label, property: property, value: value, context: context, tstamp: (Time.now.to_f * 1000).to_i ) increment_total_events_counter end |
#frontend_client_options(group) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 43 def (group) if Gitlab::CurrentSettings.snowplow_enabled? (group) else end end |