summaryrefslogtreecommitdiff
path: root/spec/frontend/tracking_spec.js
diff options
context:
space:
mode:
authorJeremy Jackson <jjackson@gitlab.com>2019-08-28 06:52:14 +0000
committerJan Provaznik <jprovaznik@gitlab.com>2019-08-28 06:52:14 +0000
commit150976833548a98ddfc41178e16024aa6112f518 (patch)
tree398cff2df20709dc0488fe5090b4be8848aadfa0 /spec/frontend/tracking_spec.js
parent07c67200ff3558426f8f26c2e5788c8bea075768 (diff)
downloadgitlab-ce-150976833548a98ddfc41178e16024aa6112f518.tar.gz
Changes snowplow to use cookies for sessions
This also restructures how and where the configuration for Snowplow lives.
Diffstat (limited to 'spec/frontend/tracking_spec.js')
-rw-r--r--spec/frontend/tracking_spec.js46
1 files changed, 41 insertions, 5 deletions
diff --git a/spec/frontend/tracking_spec.js b/spec/frontend/tracking_spec.js
index 0e862c683d3..7c98a1a66c9 100644
--- a/spec/frontend/tracking_spec.js
+++ b/spec/frontend/tracking_spec.js
@@ -1,20 +1,56 @@
import $ from 'jquery';
import { setHTMLFixture } from './helpers/fixtures';
-import Tracking from '~/tracking';
+import Tracking, { initUserTracking } from '~/tracking';
describe('Tracking', () => {
+ let snowplowSpy;
+
beforeEach(() => {
window.snowplow = window.snowplow || (() => {});
+ window.snowplowOptions = {
+ namespace: '_namespace_',
+ hostname: 'app.gitfoo.com',
+ cookieDomain: '.gitfoo.com',
+ };
+ snowplowSpy = jest.spyOn(window, 'snowplow');
});
- describe('.event', () => {
- let snowplowSpy = null;
+ describe('initUserTracking', () => {
+ it('calls through to get a new tracker with the expected options', () => {
+ initUserTracking();
+ expect(snowplowSpy).toHaveBeenCalledWith('newTracker', '_namespace_', 'app.gitfoo.com', {
+ namespace: '_namespace_',
+ hostname: 'app.gitfoo.com',
+ cookieDomain: '.gitfoo.com',
+ appId: '',
+ userFingerprint: false,
+ respectDoNotTrack: true,
+ forceSecureTracker: true,
+ eventMethod: 'post',
+ contexts: { webPage: true },
+ activityTrackingEnabled: false,
+ pageTrackingEnabled: false,
+ });
+ });
- beforeEach(() => {
- snowplowSpy = jest.spyOn(window, 'snowplow');
+ it('should activate features based on what has been enabled', () => {
+ initUserTracking();
+ expect(snowplowSpy).not.toHaveBeenCalledWith('enableActivityTracking', 30, 30);
+ expect(snowplowSpy).not.toHaveBeenCalledWith('trackPageView');
+
+ window.snowplowOptions = Object.assign({}, window.snowplowOptions, {
+ activityTrackingEnabled: true,
+ pageTrackingEnabled: true,
+ });
+
+ initUserTracking();
+ expect(snowplowSpy).toHaveBeenCalledWith('enableActivityTracking', 30, 30);
+ expect(snowplowSpy).toHaveBeenCalledWith('trackPageView');
});
+ });
+ describe('.event', () => {
afterEach(() => {
window.doNotTrack = undefined;
navigator.doNotTrack = undefined;