Module: Gitlab::Tracking

Defined in:
lib/gitlab/tracking.rb,
lib/gitlab/tracking/incident_management.rb

Defined Under Namespace

Modules: ControllerConcern, IncidentManagement

Constant Summary collapse

SNOWPLOW_NAMESPACE =
'gl'

Class Method Summary collapse

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/gitlab/tracking.rb', line 25

def enabled?
  Gitlab::CurrentSettings.snowplow_enabled?
end

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


29
30
31
32
33
# File 'lib/gitlab/tracking.rb', line 29

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

  snowplow.track_struct_event(category, action, label, property, value, context, (Time.now.to_f * 1000).to_i)
end

.self_describing_event(schema_url, event_data_json, context: nil) ⇒ Object


35
36
37
38
39
40
# File 'lib/gitlab/tracking.rb', line 35

def self_describing_event(schema_url, event_data_json, context: nil)
  return unless enabled?

  event_json = SnowplowTracker::SelfDescribingJson.new(schema_url, event_data_json)
  snowplow.track_self_describing_event(event_json, context, (Time.now.to_f * 1000).to_i)
end

.snowplow_options(group) ⇒ Object


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gitlab/tracking.rb', line 42

def snowplow_options(group)
  additional_features = Feature.enabled?(:additional_snowplow_tracking, group)
  {
    namespace: SNOWPLOW_NAMESPACE,
    hostname: Gitlab::CurrentSettings.snowplow_collector_hostname,
    cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain,
    app_id: Gitlab::CurrentSettings.snowplow_app_id,
    form_tracking: additional_features,
    link_click_tracking: additional_features
  }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end