Class: Gitlab::Tracking::Destinations::Snowplow

Inherits:
Base
  • Object
show all
Extended by:
Utils::Override
Defined in:
lib/gitlab/tracking/destinations/snowplow.rb

Direct Known Subclasses

DatabaseEventsSnowplow, SnowplowMicro

Constant Summary collapse

SNOWPLOW_NAMESPACE =
'gl'

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 41

def enabled?
  Gitlab::CurrentSettings.snowplow_enabled?
end

#event(category, action, label: nil, property: nil, value: nil, context: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 14

def event(category, action, label: nil, property: nil, value: nil, context: nil)
  return unless enabled?

  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

#hostnameObject



45
46
47
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 45

def hostname
  Gitlab::CurrentSettings.snowplow_collector_hostname
end

#options(group) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gitlab/tracking/destinations/snowplow.rb', line 29

def options(group)
  additional_features = Feature.enabled?(:additional_snowplow_tracking, group, type: :ops)
  {
    namespace: SNOWPLOW_NAMESPACE,
    hostname: hostname,
    cookie_domain: cookie_domain,
    app_id: app_id,
    form_tracking: additional_features,
    link_click_tracking: additional_features
  }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end