Module: Gitlab::Tracking

Included in:
ProfilesController, UserSettings::ProfilesController
Defined in:
lib/gitlab/tracking.rb,
lib/gitlab/tracking/helpers.rb,
lib/gitlab/tracking/event_validator.rb,
lib/gitlab/tracking/event_definition.rb,
lib/gitlab/tracking/standard_context.rb,
lib/gitlab/tracking/incident_management.rb,
lib/gitlab/tracking/service_ping_context.rb,
lib/gitlab/tracking/destinations/snowplow.rb,
lib/gitlab/tracking/snowplow_event_logger.rb,
lib/gitlab/tracking/snowplow_test_emitter.rb,
lib/gitlab/tracking/snowplow_logging_emitter.rb,
lib/gitlab/tracking/event_eligibility_checker.rb,
lib/gitlab/tracking/event_definition_validator.rb,
lib/gitlab/tracking/destinations/snowplow_micro.rb,
lib/gitlab/tracking/helpers/weak_password_error_event.rb,
lib/gitlab/tracking/destinations/destination_configuration.rb,
lib/gitlab/tracking/destinations/snowplow_context_validator.rb

Defined Under Namespace

Modules: Destinations, Helpers, IncidentManagement Classes: EventDefinition, EventDefinitionValidator, EventEligibilityChecker, EventValidator, ServicePingContext, SnowplowEventLogger, SnowplowLoggingEmitter, SnowplowTestEmitter, StandardContext

Constant Summary collapse

InvalidEventError =
Class.new(RuntimeError)

Class Method Summary collapse

Class Method Details

.collector_hostnameObject



39
40
41
# File 'lib/gitlab/tracking.rb', line 39

def collector_hostname
  tracker.hostname
end

.event(category, action, label: nil, property: nil, value: nil, context: [], project: nil, user: nil, namespace: nil, **extra) ⇒ Object

rubocop:disable Metrics/ParameterLists



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/tracking.rb', line 19

def event(category, action, label: nil, property: nil, value: nil, context: [], project: nil, user: nil, namespace: nil, **extra) # rubocop:disable Metrics/ParameterLists
  action = action.to_s

  project_id = project.is_a?(Integer) ? project : project&.id

  contexts = [
    Tracking::StandardContext.new(
      namespace: namespace,
      project_id: project_id,
      user: user,
      **extra).to_context, *context
  ]

  track_struct_event(tracker, category, action, label: label, property: property, value: value, contexts: contexts)
end

.frontend_client_options(group) ⇒ Object



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

def frontend_client_options(group)
  tracker.frontend_client_options(group)
end

.frontend_connect_directly_to_snowplow_collector?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/gitlab/tracking.rb', line 11

def frontend_connect_directly_to_snowplow_collector?
  Gitlab::CurrentSettings.snowplow_enabled? && !Gitlab::CurrentSettings.snowplow_collector_hostname.blank?
end

.micro_verification_enabled?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/gitlab/tracking.rb', line 15

def micro_verification_enabled?
  Gitlab::Utils.to_boolean(ENV['VERIFY_TRACKING'], default: false)
end

.snowplow_micro_enabled?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/gitlab/tracking.rb', line 43

def snowplow_micro_enabled?
  Rails.env.development? || micro_verification_enabled?
end

.trackerObject



47
48
49
50
51
52
53
# File 'lib/gitlab/tracking.rb', line 47

def tracker
  @tracker ||= if snowplow_micro_enabled?
                 Gitlab::Tracking::Destinations::SnowplowMicro.new
               else
                 Gitlab::Tracking::Destinations::Snowplow.new
               end
end