Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJeremy Jackson <jjackson@gitlab.com>2019-08-27 01:16:23 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-08-27 01:16:23 +0300
commit92b723db956e2b75b4bdcfb4d94c3c3cff8bf639 (patch)
tree9c1d60ebc1e38689428b7579d1932203a1e70a3c /lib
parent1d83240beb08aaaa240efbc8f63293019603a744 (diff)
Revert "Merge branch 'user-tracking-settings' into 'master'"
This reverts merge request !31826
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/snowplow_tracker.rb35
-rw-r--r--lib/gitlab/tracking.rb44
2 files changed, 35 insertions, 44 deletions
diff --git a/lib/gitlab/snowplow_tracker.rb b/lib/gitlab/snowplow_tracker.rb
new file mode 100644
index 00000000000..9f12513e09e
--- /dev/null
+++ b/lib/gitlab/snowplow_tracker.rb
@@ -0,0 +1,35 @@
+# 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
diff --git a/lib/gitlab/tracking.rb b/lib/gitlab/tracking.rb
deleted file mode 100644
index ef669b03c87..00000000000
--- a/lib/gitlab/tracking.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-require 'snowplow-tracker'
-
-module Gitlab
- module Tracking
- SNOWPLOW_NAMESPACE = 'gl'
-
- class << self
- def enabled?
- Gitlab::CurrentSettings.snowplow_enabled?
- end
-
- 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_i)
- end
-
- 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_site_id,
- page_tracking_enabled: additional_features,
- activity_tracking_enabled: additional_features
- }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
- end
-
- private
-
- def snowplow
- @snowplow ||= SnowplowTracker::Tracker.new(
- SnowplowTracker::Emitter.new(Gitlab::CurrentSettings.snowplow_collector_hostname),
- SnowplowTracker::Subject.new,
- SNOWPLOW_NAMESPACE,
- Gitlab::CurrentSettings.snowplow_site_id
- )
- end
- end
- end
-end