diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/main.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/tracking.js | 28 | ||||
-rw-r--r-- | app/views/layouts/_snowplow.html.haml | 21 |
3 files changed, 20 insertions, 31 deletions
diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 0ddf40b0405..39f2097c174 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -35,7 +35,6 @@ import initPerformanceBar from './performance_bar'; import initSearchAutocomplete from './search_autocomplete'; import GlFieldErrors from './gl_field_errors'; import initUserPopovers from './user_popovers'; -import { initUserTracking } from './tracking'; import { __ } from './locale'; import 'ee_else_ce/main_ee'; @@ -95,7 +94,6 @@ function deferredInitialisation() { initLogoAnimation(); initUsagePingConsent(); initUserPopovers(); - initUserTracking(); if (document.querySelector('.search')) initSearchAutocomplete(); diff --git a/app/assets/javascripts/tracking.js b/app/assets/javascripts/tracking.js index 03281b5ef49..a852f937eec 100644 --- a/app/assets/javascripts/tracking.js +++ b/app/assets/javascripts/tracking.js @@ -1,23 +1,5 @@ import $ from 'jquery'; -const DEFAULT_SNOWPLOW_OPTIONS = { - namespace: 'gl', - hostname: window.location.hostname, - cookieDomain: window.location.hostname, - appId: '', - userFingerprint: false, - respectDoNotTrack: true, - forceSecureTracker: true, - eventMethod: 'post', - contexts: { webPage: true }, - // Page tracking tracks a single event when the page loads. - pageTrackingEnabled: false, - // Activity tracking tracks when a user is still interacting with the page. - // Events like scrolling and mouse movements are used to determine if the - // user has the tab active and is still actively engaging. - activityTrackingEnabled: false, -}; - const extractData = (el, opts = {}) => { const { trackEvent, trackLabel = '', trackProperty = '' } = el.dataset; let trackValue = el.dataset.trackValue || el.value || ''; @@ -89,13 +71,3 @@ export default class Tracking { }; } } - -export function initUserTracking() { - if (!Tracking.enabled()) return; - - const opts = Object.assign({}, DEFAULT_SNOWPLOW_OPTIONS, window.snowplowOptions); - window.snowplow('newTracker', opts.namespace, opts.hostname, opts); - - if (opts.activityTrackingEnabled) window.snowplow('enableActivityTracking', 30, 30); - if (opts.pageTrackingEnabled) window.snowplow('trackPageView'); // must be after enableActivityTracking -} diff --git a/app/views/layouts/_snowplow.html.haml b/app/views/layouts/_snowplow.html.haml index d7ff5ad1094..5f5c5e984c5 100644 --- a/app/views/layouts/_snowplow.html.haml +++ b/app/views/layouts/_snowplow.html.haml @@ -7,4 +7,23 @@ };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","#{asset_url('snowplow/sp.js')}","snowplow")); - window.snowplowOptions = #{Gitlab::Tracking.snowplow_options(@group).to_json} + window.snowplow('newTracker', '#{Gitlab::SnowplowTracker::NAMESPACE}', '#{Gitlab::CurrentSettings.snowplow_collector_hostname}', { + appId: '#{Gitlab::CurrentSettings.snowplow_site_id}', + cookieDomain: '#{Gitlab::CurrentSettings.snowplow_cookie_domain}', + userFingerprint: false, + respectDoNotTrack: true, + forceSecureTracker: true, + post: true, + contexts: { webPage: true }, + stateStorageStrategy: "localStorage" + }); + + window.snowplow('enableActivityTracking', 30, 30); + window.snowplow('trackPageView'); + +- return unless Feature.enabled?(:additional_snowplow_tracking, @group) + += javascript_tag nonce: true do + :plain + window.snowplow('enableFormTracking'); + window.snowplow('enableLinkClickTracking'); |