Commit baad7c29 authored by jejacks0n's avatar jejacks0n

Remove feature flagging for some tracking

This properly exposes page view and activity tracking to everyone
and includes form tracking and link click tracking behind a feature
flag.
parent a0d3691c
...@@ -10,12 +10,8 @@ const DEFAULT_SNOWPLOW_OPTIONS = { ...@@ -10,12 +10,8 @@ const DEFAULT_SNOWPLOW_OPTIONS = {
forceSecureTracker: true, forceSecureTracker: true,
eventMethod: 'post', eventMethod: 'post',
contexts: { webPage: true }, contexts: { webPage: true },
// Page tracking tracks a single event when the page loads. formTracking: false,
pageTrackingEnabled: false, linkClickTracking: 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 extractData = (el, opts = {}) => {
...@@ -96,6 +92,9 @@ export function initUserTracking() { ...@@ -96,6 +92,9 @@ export function initUserTracking() {
const opts = Object.assign({}, DEFAULT_SNOWPLOW_OPTIONS, window.snowplowOptions); const opts = Object.assign({}, DEFAULT_SNOWPLOW_OPTIONS, window.snowplowOptions);
window.snowplow('newTracker', opts.namespace, opts.hostname, opts); window.snowplow('newTracker', opts.namespace, opts.hostname, opts);
if (opts.activityTrackingEnabled) window.snowplow('enableActivityTracking', 30, 30); window.snowplow('enableActivityTracking', 30, 30);
if (opts.pageTrackingEnabled) window.snowplow('trackPageView'); // must be after enableActivityTracking window.snowplow('trackPageView'); // must be after enableActivityTracking
if (opts.formTracking) window.snowplow('enableFormTracking');
if (opts.linkClickTracking) window.snowplow('enableLinkClickTracking');
} }
...@@ -24,8 +24,8 @@ module Gitlab ...@@ -24,8 +24,8 @@ module Gitlab
hostname: Gitlab::CurrentSettings.snowplow_collector_hostname, hostname: Gitlab::CurrentSettings.snowplow_collector_hostname,
cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain, cookie_domain: Gitlab::CurrentSettings.snowplow_cookie_domain,
app_id: Gitlab::CurrentSettings.snowplow_site_id, app_id: Gitlab::CurrentSettings.snowplow_site_id,
page_tracking_enabled: additional_features, form_tracking: additional_features,
activity_tracking_enabled: additional_features link_click_tracking: additional_features
}.transform_keys! { |key| key.to_s.camelize(:lower).to_sym } }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end end
......
...@@ -29,24 +29,26 @@ describe('Tracking', () => { ...@@ -29,24 +29,26 @@ describe('Tracking', () => {
forceSecureTracker: true, forceSecureTracker: true,
eventMethod: 'post', eventMethod: 'post',
contexts: { webPage: true }, contexts: { webPage: true },
activityTrackingEnabled: false, formTracking: false,
pageTrackingEnabled: false, linkClickTracking: false,
}); });
}); });
it('should activate features based on what has been enabled', () => { it('should activate features based on what has been enabled', () => {
initUserTracking(); initUserTracking();
expect(snowplowSpy).not.toHaveBeenCalledWith('enableActivityTracking', 30, 30); expect(snowplowSpy).toHaveBeenCalledWith('enableActivityTracking', 30, 30);
expect(snowplowSpy).not.toHaveBeenCalledWith('trackPageView'); expect(snowplowSpy).toHaveBeenCalledWith('trackPageView');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableLinkClickTracking');
window.snowplowOptions = Object.assign({}, window.snowplowOptions, { window.snowplowOptions = Object.assign({}, window.snowplowOptions, {
activityTrackingEnabled: true, formTracking: true,
pageTrackingEnabled: true, linkClickTracking: true,
}); });
initUserTracking(); initUserTracking();
expect(snowplowSpy).toHaveBeenCalledWith('enableActivityTracking', 30, 30); expect(snowplowSpy).toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).toHaveBeenCalledWith('trackPageView'); expect(snowplowSpy).toHaveBeenCalledWith('enableLinkClickTracking');
}); });
}); });
......
...@@ -20,8 +20,8 @@ describe Gitlab::Tracking do ...@@ -20,8 +20,8 @@ describe Gitlab::Tracking do
hostname: 'gitfoo.com', hostname: 'gitfoo.com',
cookieDomain: '.gitfoo.com', cookieDomain: '.gitfoo.com',
appId: '_abc123_', appId: '_abc123_',
pageTrackingEnabled: true, formTracking: true,
activityTrackingEnabled: true linkClickTracking: true
) )
end end
...@@ -33,8 +33,8 @@ describe Gitlab::Tracking do ...@@ -33,8 +33,8 @@ describe Gitlab::Tracking do
).and_return(false) ).and_return(false)
expect(subject.snowplow_options('_group_')).to include( expect(subject.snowplow_options('_group_')).to include(
pageTrackingEnabled: false, formTracking: false,
activityTrackingEnabled: false linkClickTracking: false
) )
end end
end 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