gitlab-org--gitlab-foss/lib/gitlab/snowplow_tracker.rb
Jeremy Jackson 5d9d5e6031 Migrates Snowplow backend from EE to CE
This introduces several changes, but these are all just ported from the
EE project.
2019-08-14 19:21:58 +00:00

35 lines
829 B
Ruby

# frozen_string_literal: true
require 'snowplow-tracker'
module Gitlab
module SnowplowTracker
NAMESPACE = 'cf'
class << self
def track_event(category, action, label: nil, property: nil, value: nil, context: nil)
tracker&.track_struct_event(category, action, label, property, value, context, Time.now.to_i)
end
private
def tracker
return unless enabled?
@tracker ||= ::SnowplowTracker::Tracker.new(emitter, subject, NAMESPACE, Gitlab::CurrentSettings.snowplow_site_id)
end
def subject
::SnowplowTracker::Subject.new
end
def emitter
::SnowplowTracker::Emitter.new(Gitlab::CurrentSettings.snowplow_collector_hostname)
end
def enabled?
Gitlab::CurrentSettings.snowplow_enabled?
end
end
end
end