Commit 69eef2e7 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch...

Merge branch '339706-move-snowplow-logic-from-gitlab-tracking-module-to-gitlab-tracking-destinations-snowplow' into 'master'

Refactor Gitlab::Tracking module

See merge request gitlab-org/gitlab!75362
parents 363798e3 010f4725
......@@ -2,11 +2,9 @@
module Gitlab
module Tracking
SNOWPLOW_NAMESPACE = 'gl'
class << self
def enabled?
snowplow_micro_enabled? || Gitlab::CurrentSettings.snowplow_enabled?
snowplow.enabled?
end
def event(category, action, label: nil, property: nil, value: nil, context: [], project: nil, user: nil, namespace: nil, **extra) # rubocop:disable Metrics/ParameterLists
......
......@@ -8,6 +8,8 @@ module Gitlab
class Snowplow < Base
extend ::Gitlab::Utils::Override
SNOWPLOW_NAMESPACE = 'gl'
override :event
def event(category, action, label: nil, property: nil, value: nil, context: nil)
return unless enabled?
......@@ -19,7 +21,7 @@ module Gitlab
def options(group)
additional_features = Feature.enabled?(:additional_snowplow_tracking, group, type: :ops)
{
namespace: Gitlab::Tracking::SNOWPLOW_NAMESPACE,
namespace: SNOWPLOW_NAMESPACE,
hostname: hostname,
cookie_domain: cookie_domain,
app_id: app_id,
......@@ -28,16 +30,16 @@ module Gitlab
}.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end
def enabled?
Gitlab::CurrentSettings.snowplow_enabled?
end
def hostname
Gitlab::CurrentSettings.snowplow_collector_hostname
end
private
def enabled?
Gitlab::Tracking.enabled?
end
def app_id
Gitlab::CurrentSettings.snowplow_app_id
end
......@@ -54,7 +56,7 @@ module Gitlab
@tracker ||= SnowplowTracker::Tracker.new(
emitter,
SnowplowTracker::Subject.new,
Gitlab::Tracking::SNOWPLOW_NAMESPACE,
SNOWPLOW_NAMESPACE,
app_id
)
end
......
......@@ -18,6 +18,11 @@ module Gitlab
).transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end
override :enabled?
def enabled?
true
end
override :hostname
def hostname
"#{uri.host}:#{uri.port}"
......
......@@ -29,7 +29,7 @@ RSpec.describe Gitlab::Tracking::Destinations::Snowplow do
expect(SnowplowTracker::Tracker)
.to receive(:new)
.with(emitter, an_instance_of(SnowplowTracker::Subject), Gitlab::Tracking::SNOWPLOW_NAMESPACE, '_abc123_')
.with(emitter, an_instance_of(SnowplowTracker::Subject), described_class::SNOWPLOW_NAMESPACE, '_abc123_')
.and_return(tracker)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment