Commit 37b52cb1 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'tracking-feature-flag' into 'master'

Remove feature flagging for some tracking

See merge request gitlab-org/gitlab!16552
parents b941c67c baad7c29
......@@ -10,12 +10,8 @@ const DEFAULT_SNOWPLOW_OPTIONS = {
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,
formTracking: false,
linkClickTracking: false,
};
const extractData = (el, opts = {}) => {
......@@ -96,6 +92,9 @@ export function initUserTracking() {
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
window.snowplow('enableActivityTracking', 30, 30);
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
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
form_tracking: additional_features,
link_click_tracking: additional_features
}.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
end
......
......@@ -29,24 +29,26 @@ describe('Tracking', () => {
forceSecureTracker: true,
eventMethod: 'post',
contexts: { webPage: true },
activityTrackingEnabled: false,
pageTrackingEnabled: false,
formTracking: false,
linkClickTracking: false,
});
});
it('should activate features based on what has been enabled', () => {
initUserTracking();
expect(snowplowSpy).not.toHaveBeenCalledWith('enableActivityTracking', 30, 30);
expect(snowplowSpy).not.toHaveBeenCalledWith('trackPageView');
expect(snowplowSpy).toHaveBeenCalledWith('enableActivityTracking', 30, 30);
expect(snowplowSpy).toHaveBeenCalledWith('trackPageView');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).not.toHaveBeenCalledWith('enableLinkClickTracking');
window.snowplowOptions = Object.assign({}, window.snowplowOptions, {
activityTrackingEnabled: true,
pageTrackingEnabled: true,
formTracking: true,
linkClickTracking: true,
});
initUserTracking();
expect(snowplowSpy).toHaveBeenCalledWith('enableActivityTracking', 30, 30);
expect(snowplowSpy).toHaveBeenCalledWith('trackPageView');
expect(snowplowSpy).toHaveBeenCalledWith('enableFormTracking');
expect(snowplowSpy).toHaveBeenCalledWith('enableLinkClickTracking');
});
});
......
......@@ -20,8 +20,8 @@ describe Gitlab::Tracking do
hostname: 'gitfoo.com',
cookieDomain: '.gitfoo.com',
appId: '_abc123_',
pageTrackingEnabled: true,
activityTrackingEnabled: true
formTracking: true,
linkClickTracking: true
)
end
......@@ -33,8 +33,8 @@ describe Gitlab::Tracking do
).and_return(false)
expect(subject.snowplow_options('_group_')).to include(
pageTrackingEnabled: false,
activityTrackingEnabled: false
formTracking: false,
linkClickTracking: false
)
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