@codecademy/tracking 1.0.0-alpha.f35aad.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +33 -0
- package/CHANGELOG.md +161 -47
- package/LICENSE +1 -1
- package/babel.config.js +11 -2
- package/package.json +6 -29
- package/project.json +46 -0
- package/tsconfig.json +16 -4
- package/tsconfig.spec.json +9 -0
- package/dist/events/__tests__/track.spec.d.ts +0 -1
- package/dist/events/__tests__/track.spec.js +0 -78
- package/dist/events/__tests__/track.test.d.ts +0 -1
- package/dist/events/__tests__/track.test.js +0 -78
- package/dist/events/__tests__/user.spec.d.ts +0 -1
- package/dist/events/__tests__/user.spec.js +0 -42
- package/dist/events/__tests__/user.test.d.ts +0 -1
- package/dist/events/__tests__/user.test.js +0 -42
- package/dist/events/index.d.ts +0 -3
- package/dist/events/index.js +0 -3
- package/dist/events/track.d.ts +0 -11
- package/dist/events/track.js +0 -88
- package/dist/events/types.d.ts +0 -218
- package/dist/events/types.js +0 -0
- package/dist/events/user.d.ts +0 -2
- package/dist/events/user.js +0 -39
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/integrations/__tests__/conditionallyLoadAnalytics-test.d.ts +0 -1
- package/dist/integrations/__tests__/fetchDestinationsForWriteKey-test.d.ts +0 -1
- package/dist/integrations/__tests__/mapDestinations-test.d.ts +0 -1
- package/dist/integrations/conditionallyLoadAnalytics.d.ts +0 -9
- package/dist/integrations/conditionallyLoadAnalytics.js +0 -24
- package/dist/integrations/consent.d.ts +0 -9
- package/dist/integrations/consent.js +0 -11
- package/dist/integrations/fetchDestinationsForWriteKey.d.ts +0 -6
- package/dist/integrations/fetchDestinationsForWriteKey.js +0 -76
- package/dist/integrations/index.d.ts +0 -27
- package/dist/integrations/index.js +0 -84
- package/dist/integrations/mapDestinations.d.ts +0 -19
- package/dist/integrations/mapDestinations.js +0 -55
- package/dist/integrations/onetrust.d.ts +0 -6
- package/dist/integrations/onetrust.js +0 -51
- package/dist/integrations/runSegmentSnippet.d.ts +0 -1
- package/dist/integrations/runSegmentSnippet.js +0 -86
- package/dist/integrations/types.d.ts +0 -24
- package/dist/integrations/types.js +0 -0
- package/jest.config.js +0 -7
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export var conditionallyLoadAnalytics = function conditionallyLoadAnalytics(_ref) {
|
|
2
|
-
var analytics = _ref.analytics,
|
|
3
|
-
destinationPreferences = _ref.destinationPreferences,
|
|
4
|
-
identifyPreferences = _ref.identifyPreferences,
|
|
5
|
-
user = _ref.user,
|
|
6
|
-
writeKey = _ref.writeKey;
|
|
7
|
-
|
|
8
|
-
if (analytics.initialize) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
analytics.load(writeKey, {
|
|
13
|
-
integrations: destinationPreferences
|
|
14
|
-
});
|
|
15
|
-
analytics.page();
|
|
16
|
-
|
|
17
|
-
if (user) {
|
|
18
|
-
analytics.identify(user.id, {
|
|
19
|
-
email: user.email
|
|
20
|
-
}, {
|
|
21
|
-
integrations: identifyPreferences
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @see https://www.notion.so/codecademy/GDPR-Compliance-141ebcc7ffa542daa0da56e35f482b41
|
|
3
|
-
*/
|
|
4
|
-
export var Consent;
|
|
5
|
-
|
|
6
|
-
(function (Consent) {
|
|
7
|
-
Consent["Functional"] = "C0003";
|
|
8
|
-
Consent["Performance"] = "C0002";
|
|
9
|
-
Consent["StrictlyNecessary"] = "C0001";
|
|
10
|
-
Consent["Targeting"] = "C0004";
|
|
11
|
-
})(Consent || (Consent = {}));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SegmentDestination } from './types';
|
|
2
|
-
export declare type FetchDestinationsSettings = {
|
|
3
|
-
onError: (message: string) => void;
|
|
4
|
-
writeKey: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const fetchDestinationsForWriteKey: ({ writeKey, onError, }: FetchDestinationsSettings) => Promise<SegmentDestination[] | undefined>;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
|
|
3
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
|
|
11
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
|
-
|
|
13
|
-
export var fetchDestinationsForWriteKey = /*#__PURE__*/function () {
|
|
14
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
15
|
-
var writeKey, onError, response, destinations, _iterator, _step, destination;
|
|
16
|
-
|
|
17
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
18
|
-
while (1) {
|
|
19
|
-
switch (_context.prev = _context.next) {
|
|
20
|
-
case 0:
|
|
21
|
-
writeKey = _ref.writeKey, onError = _ref.onError;
|
|
22
|
-
_context.prev = 1;
|
|
23
|
-
_context.next = 4;
|
|
24
|
-
return fetch("https://cdn.segment.com/v1/projects/".concat(writeKey, "/integrations"));
|
|
25
|
-
|
|
26
|
-
case 4:
|
|
27
|
-
response = _context.sent;
|
|
28
|
-
|
|
29
|
-
if (response.ok) {
|
|
30
|
-
_context.next = 8;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
onError("Failed to fetch integrations for write key ".concat(writeKey, ": HTTP ").concat(response.status, " ").concat(response.statusText));
|
|
35
|
-
return _context.abrupt("return", []);
|
|
36
|
-
|
|
37
|
-
case 8:
|
|
38
|
-
_context.next = 10;
|
|
39
|
-
return response.json();
|
|
40
|
-
|
|
41
|
-
case 10:
|
|
42
|
-
destinations = _context.sent;
|
|
43
|
-
_iterator = _createForOfIteratorHelper(destinations);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
47
|
-
destination = _step.value;
|
|
48
|
-
destination.id = destination.creationName;
|
|
49
|
-
delete destination.creationName;
|
|
50
|
-
}
|
|
51
|
-
} catch (err) {
|
|
52
|
-
_iterator.e(err);
|
|
53
|
-
} finally {
|
|
54
|
-
_iterator.f();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return _context.abrupt("return", destinations);
|
|
58
|
-
|
|
59
|
-
case 16:
|
|
60
|
-
_context.prev = 16;
|
|
61
|
-
_context.t0 = _context["catch"](1);
|
|
62
|
-
onError("Unknown error fetching Segment destinations for write key ".concat(writeKey, ": ").concat(_context.t0));
|
|
63
|
-
return _context.abrupt("return", []);
|
|
64
|
-
|
|
65
|
-
case 20:
|
|
66
|
-
case "end":
|
|
67
|
-
return _context.stop();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}, _callee, null, [[1, 16]]);
|
|
71
|
-
}));
|
|
72
|
-
|
|
73
|
-
return function fetchDestinationsForWriteKey(_x) {
|
|
74
|
-
return _ref2.apply(this, arguments);
|
|
75
|
-
};
|
|
76
|
-
}();
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { TrackingWindow, UserIntegrationSummary } from './types';
|
|
2
|
-
export declare type TrackingIntegrationsSettings = {
|
|
3
|
-
/**
|
|
4
|
-
* Called whenever a network request fails.
|
|
5
|
-
*/
|
|
6
|
-
onError: (message: string) => void;
|
|
7
|
-
/**
|
|
8
|
-
* Whether this is running in a production environment.
|
|
9
|
-
*/
|
|
10
|
-
production: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Global scope (often the window) where globals such as analytics are stored.
|
|
13
|
-
*/
|
|
14
|
-
scope: TrackingWindow;
|
|
15
|
-
/**
|
|
16
|
-
* User details to identify in Segment.
|
|
17
|
-
*/
|
|
18
|
-
user?: UserIntegrationSummary;
|
|
19
|
-
/**
|
|
20
|
-
* Segment write key.
|
|
21
|
-
*/
|
|
22
|
-
writeKey: string;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* @see README.md for details and usage.
|
|
26
|
-
*/
|
|
27
|
-
export declare const initializeTrackingIntegrations: ({ onError, production, scope, user, writeKey, }: TrackingIntegrationsSettings) => Promise<void>;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
|
|
3
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
-
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
|
|
7
|
-
import { conditionallyLoadAnalytics } from './conditionallyLoadAnalytics';
|
|
8
|
-
import { fetchDestinationsForWriteKey } from './fetchDestinationsForWriteKey';
|
|
9
|
-
import { mapDestinations } from './mapDestinations';
|
|
10
|
-
import { initializeOneTrust } from './onetrust';
|
|
11
|
-
import { runSegmentSnippet } from './runSegmentSnippet';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @see README.md for details and usage.
|
|
15
|
-
*/
|
|
16
|
-
export var initializeTrackingIntegrations = /*#__PURE__*/function () {
|
|
17
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
18
|
-
var onError, production, scope, user, writeKey, destinations, _mapDestinations, destinationPreferences, identifyPreferences;
|
|
19
|
-
|
|
20
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21
|
-
while (1) {
|
|
22
|
-
switch (_context.prev = _context.next) {
|
|
23
|
-
case 0:
|
|
24
|
-
onError = _ref.onError, production = _ref.production, scope = _ref.scope, user = _ref.user, writeKey = _ref.writeKey;
|
|
25
|
-
_context.next = 3;
|
|
26
|
-
return new Promise(function (resolve) {
|
|
27
|
-
return setTimeout(resolve, 1000);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
case 3:
|
|
31
|
-
_context.next = 5;
|
|
32
|
-
return initializeOneTrust({
|
|
33
|
-
scope: scope,
|
|
34
|
-
production: production
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
case 5:
|
|
38
|
-
// 3. Segment's copy-and-paste snippet is run to load the Segment global library
|
|
39
|
-
runSegmentSnippet(); // 4. Destination integrations for Segment are fetched
|
|
40
|
-
|
|
41
|
-
_context.next = 8;
|
|
42
|
-
return fetchDestinationsForWriteKey({
|
|
43
|
-
onError: onError,
|
|
44
|
-
writeKey: writeKey
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
case 8:
|
|
48
|
-
destinations = _context.sent;
|
|
49
|
-
|
|
50
|
-
if (destinations) {
|
|
51
|
-
_context.next = 11;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return _context.abrupt("return");
|
|
56
|
-
|
|
57
|
-
case 11:
|
|
58
|
-
// 5. Those integrations are compared against the user's consent decisions into a list of allowed destinations
|
|
59
|
-
_mapDestinations = mapDestinations({
|
|
60
|
-
consentDecision: scope.OnetrustActiveGroups,
|
|
61
|
-
destinations: destinations,
|
|
62
|
-
user: user
|
|
63
|
-
}), destinationPreferences = _mapDestinations.destinationPreferences, identifyPreferences = _mapDestinations.identifyPreferences; // 6. We load only those allowed destinations using Segment's `analytics.load`
|
|
64
|
-
|
|
65
|
-
conditionallyLoadAnalytics({
|
|
66
|
-
analytics: scope.analytics,
|
|
67
|
-
destinationPreferences: destinationPreferences,
|
|
68
|
-
identifyPreferences: identifyPreferences,
|
|
69
|
-
user: user,
|
|
70
|
-
writeKey: writeKey
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
case 13:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context.stop();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, _callee);
|
|
79
|
-
}));
|
|
80
|
-
|
|
81
|
-
return function initializeTrackingIntegrations(_x) {
|
|
82
|
-
return _ref2.apply(this, arguments);
|
|
83
|
-
};
|
|
84
|
-
}();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Consent } from './consent';
|
|
2
|
-
import { SegmentDestination, UserIntegrationSummary } from './types';
|
|
3
|
-
export declare type DestinationMapOptions = {
|
|
4
|
-
consentDecision?: Consent[];
|
|
5
|
-
destinations: SegmentDestination[];
|
|
6
|
-
user?: UserIntegrationSummary;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @see https://www.notion.so/codecademy/GDPR-Compliance-141ebcc7ffa542daa0da56e35f482b41
|
|
10
|
-
*/
|
|
11
|
-
export declare const mapDestinations: ({ consentDecision, destinations, user, }: DestinationMapOptions) => {
|
|
12
|
-
destinationPreferences: Record<string, boolean>;
|
|
13
|
-
identifyPreferences: {
|
|
14
|
-
All: boolean;
|
|
15
|
-
FullStory: boolean;
|
|
16
|
-
Hindsight: boolean;
|
|
17
|
-
UserLeap: boolean;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
|
|
5
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
10
|
-
|
|
11
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
-
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
-
|
|
15
|
-
import { Consent } from './consent';
|
|
16
|
-
// The Functional category may need to be added here in the future.
|
|
17
|
-
var targetingCategories = ['Advertising', 'Attribution', 'Email Marketing'];
|
|
18
|
-
var performanceCategories = ['Analytics', 'Customer Success'];
|
|
19
|
-
/**
|
|
20
|
-
* @see https://www.notion.so/codecademy/GDPR-Compliance-141ebcc7ffa542daa0da56e35f482b41
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export var mapDestinations = function mapDestinations(_ref) {
|
|
24
|
-
var _ref$consentDecision = _ref.consentDecision,
|
|
25
|
-
consentDecision = _ref$consentDecision === void 0 ? [Consent.StrictlyNecessary] : _ref$consentDecision,
|
|
26
|
-
destinations = _ref.destinations,
|
|
27
|
-
user = _ref.user;
|
|
28
|
-
// See GROW-1111, GROW-1137 for FullStory context
|
|
29
|
-
// The intention is to enable fullstory for logged-in users. See GROW-2292
|
|
30
|
-
var enableFullStory = !!user;
|
|
31
|
-
var destinationPreferences = Object.assign.apply(Object, [{
|
|
32
|
-
'Segment.io': consentDecision.includes(Consent.Functional),
|
|
33
|
-
FullStory: enableFullStory
|
|
34
|
-
}].concat(_toConsumableArray(destinations.map(function (dest) {
|
|
35
|
-
if (targetingCategories.includes(dest.category)) {
|
|
36
|
-
return _defineProperty({}, dest.id, consentDecision.includes(Consent.Targeting));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (performanceCategories.includes(dest.category)) {
|
|
40
|
-
return _defineProperty({}, dest.id, consentDecision.includes(Consent.Performance));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return _defineProperty({}, dest.id, true);
|
|
44
|
-
}))));
|
|
45
|
-
var identifyPreferences = {
|
|
46
|
-
All: false,
|
|
47
|
-
FullStory: enableFullStory,
|
|
48
|
-
Hindsight: consentDecision.includes(Consent.Targeting),
|
|
49
|
-
UserLeap: consentDecision.includes(Consent.Performance)
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
destinationPreferences: destinationPreferences,
|
|
53
|
-
identifyPreferences: identifyPreferences
|
|
54
|
-
};
|
|
55
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
|
|
3
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
-
|
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
-
|
|
7
|
-
export var initializeOneTrust = /*#__PURE__*/function () {
|
|
8
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
9
|
-
var production, scope, script, style;
|
|
10
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
-
while (1) {
|
|
12
|
-
switch (_context.prev = _context.next) {
|
|
13
|
-
case 0:
|
|
14
|
-
production = _ref.production, scope = _ref.scope;
|
|
15
|
-
script = document.createElement('script');
|
|
16
|
-
script.setAttribute('async', 'true');
|
|
17
|
-
script.setAttribute('src', 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js');
|
|
18
|
-
script.setAttribute('type', 'text/javascript');
|
|
19
|
-
script.setAttribute('data-domain-script', "cfa7b129-f37b-4f5a-9991-3f75ba7b85fb".concat(production ? '' : '-test'));
|
|
20
|
-
document.body.appendChild(script);
|
|
21
|
-
style = document.createElement('style');
|
|
22
|
-
style.textContent = rawStyles;
|
|
23
|
-
document.body.appendChild(style);
|
|
24
|
-
return _context.abrupt("return", new Promise(function (resolve) {
|
|
25
|
-
scope.OptanonWrapper = function () {
|
|
26
|
-
var _scope$dataLayer, _script$parentNode;
|
|
27
|
-
|
|
28
|
-
(_scope$dataLayer = scope.dataLayer) !== null && _scope$dataLayer !== void 0 ? _scope$dataLayer : scope.dataLayer = [];
|
|
29
|
-
scope.dataLayer.push({
|
|
30
|
-
event: 'OneTrustGroupsUpdated'
|
|
31
|
-
});
|
|
32
|
-
resolve();
|
|
33
|
-
(_script$parentNode = script.parentNode) === null || _script$parentNode === void 0 ? void 0 : _script$parentNode.removeChild(script);
|
|
34
|
-
};
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
case 11:
|
|
38
|
-
case "end":
|
|
39
|
-
return _context.stop();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}, _callee);
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
return function initializeOneTrust(_x) {
|
|
46
|
-
return _ref2.apply(this, arguments);
|
|
47
|
-
};
|
|
48
|
-
}(); // For now, these three values duplicate theme colors from gamut-styles
|
|
49
|
-
// We don't want to take a full dependency on that package here...
|
|
50
|
-
|
|
51
|
-
var rawStyles = "\n:root {\n --onetrust-brand-purple: #3A10E5;\n --onetrust-color-gray-500: #828285;\n --onetrust-color-white: #fff;\n}\n\n#onetrust-banner-sdk {\n padding: 1rem !important;\n}\n#onetrust-banner-sdk > .ot-sdk-container {\n width: 100% !important;\n}\n#onetrust-banner-sdk > .ot-sdk-container > .ot-sdk-row {\n display: flex !important;\n flex-direction: column !important;\n align-items: center !important;\n max-width: 1436px !important;\n margin: 0 auto !important;\n}\n#onetrust-banner-sdk > .ot-sdk-container > .ot-sdk-row:after {\n content: none !important;\n}\n#onetrust-group-container {\n display: flex !important;\n justify-content: center;\n float: none !important;\n width: 100% !important;\n max-width: 1148px !important;\n margin-left: 0 !important;\n margin-bottom: 0.625rem !important;\n}\n#onetrust-policy,\n#onetrust-policy-text {\n margin: 0 !important;\n font-size: 0.875rem !important;\n line-height: 1.375rem !important;\n text-align: center !important;\n float: none !important;\n}\n#onetrust-policy-text a {\n text-decoration: none;\n line-height: 26px !important;\n margin-left: 0 !important;\n}\n#onetrust-button-group-parent {\n position: relative !important;\n top: initial !important;\n left: initial !important;\n transform: initial !important;\n width: 264px !important;\n margin: 0 !important;\n padding: 0 !important;\n float: none !important;\n}\n#onetrust-button-group {\n display: flex !important;\n margin: 0 !important;\n}\n#onetrust-pc-btn-handler, #onetrust-accept-btn-handler {\n min-width: initial !important;\n padding: 0.375rem 1rem !important;\n margin: 0 !important;\n opacity: 1 !important;\n border-radius: 2px !important;\n line-height: 1.5 !important;\n user-select: none !important;\n font-size: 1rem !important;\n}\n#onetrust-pc-btn-handler:focus, #onetrust-accept-btn-handler:focus {\n box-shadow: 0 0 0 2px var(--onetrust-color-white), 0 0 0 4px var(--onetrust-brand-purple);\n text-decoration: none !important;\n outline: none !important;\n}\n#onetrust-pc-btn-handler{\n color: var(--onetrust-brand-purple) !important;\n border: 1px solid var(--onetrust-brand-purple)!important;\n background: var(--onetrust-color-white) !important\n}\n#onetrust-accept-btn-handler {\n color: var(--onetrust-color-white) !important;\n background: var(--onetrust-brand-purple)!important;\n margin-left: 1rem !important;\n}\n#onetrust-close-btn-container {\n display: none !important;\n}\n\n.pc-logo {\n display: none !important;\n}\n\n#accept-recommended-btn-handler,\n.ot-pc-refuse-all-handler,\n.save-preference-btn-handler {\n margin-left: 4px !important;\n font-size: 14px !important;\n}\n\n#accept-recommended-btn-handler:focus,\n#onetrust-pc-sdk .ot-pc-refuse-all-handler:focus,\n#onetrust-pc-sdk .save-preference-btn-handler:focus {\n box-shadow: 0 0 0 2px var(--onetrust-color-white), 0 0 0 4px var(--onetrust-brand-purple);\n text-decoration: none !important;\n outline: none !important;\n opacity: 1 !important;\n}\n\n.ot-switch-label {\n border: 1px solid var(--onetrust-color-gray-500) !important;\n background-color: var(--onetrust-color-gray-500) !important;\n}\n\n.ot-switch-nob {\n background: var(--onetrust-color-white) !important;\n}\n\n.ot-switch-inner:before {\n background-color: var(--onetrust-brand-purple) !important;\n}\n\n.switch-checkbox:checked+.ot-switch-label .ot-switch-nob {\n border-color: var(--onetrust-brand-purple) !important;\n}\n\n.ot-pc-footer-logo {\n display: none !important;\n}\n\n#onetrust-banner-sdk>.ot-sdk-container {\n overflow: visible !important;\n}\n\n@media (max-width: 30rem) {\n #accept-recommended-btn-handler,\n .ot-pc-refuse-all-handler,\n .save-preference-btn-handler {\n width: 96% !important;\n }\n}\n\n@media (min-width: 37.5rem) {\n #onetrust-banner-sdk {\n padding: 0.875rem 1rem !important;\n }\n}\n@media (min-width: 48rem) {\n #onetrust-banner-sdk {\n padding: 0.875rem 1.25rem !important;\n }\n}\n@media (min-width: 1650px) {\n #onetrust-banner-sdk > .ot-sdk-container > .ot-sdk-row {\n flex-direction: row !important;\n justify-content: space-between !important;\n }\n #onetrust-group-container {\n margin-bottom: 0 !important;\n }\n #onetrust-button-group {\n flex-direction: row !important;\n }\n}\n";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function runSegmentSnippet(): void;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console, prefer-rest-params */
|
|
2
|
-
/**
|
|
3
|
-
* This code is copypasta from the Segment documentation.
|
|
4
|
-
* It creates the global analytics object and loads the Segment Analytics API that uses it.
|
|
5
|
-
*
|
|
6
|
-
* @see https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-copy-the-segment-snippet
|
|
7
|
-
*/
|
|
8
|
-
export const runSegmentSnippet = () => {
|
|
9
|
-
// Create a queue, but don't obliterate an existing one!
|
|
10
|
-
const analytics = (window.analytics = window.analytics || []);
|
|
11
|
-
|
|
12
|
-
// If the real analytics.js is already on the page return.
|
|
13
|
-
if (analytics.initialize) return;
|
|
14
|
-
|
|
15
|
-
// If the snippet was invoked already show an error.
|
|
16
|
-
if (analytics.invoked) {
|
|
17
|
-
console.error('Segment snippet included twice.');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Invoked flag, to make sure the snippet
|
|
22
|
-
// is never invoked twice.
|
|
23
|
-
analytics.invoked = true;
|
|
24
|
-
|
|
25
|
-
// A list of the methods in Analytics.js to stub.
|
|
26
|
-
analytics.methods = [
|
|
27
|
-
'trackSubmit',
|
|
28
|
-
'trackClick',
|
|
29
|
-
'trackLink',
|
|
30
|
-
'trackForm',
|
|
31
|
-
'pageview',
|
|
32
|
-
'identify',
|
|
33
|
-
'reset',
|
|
34
|
-
'group',
|
|
35
|
-
'track',
|
|
36
|
-
'ready',
|
|
37
|
-
'alias',
|
|
38
|
-
'debug',
|
|
39
|
-
'page',
|
|
40
|
-
'once',
|
|
41
|
-
'off',
|
|
42
|
-
'on',
|
|
43
|
-
'addSourceMiddleware',
|
|
44
|
-
'addIntegrationMiddleware',
|
|
45
|
-
'setAnonymousId',
|
|
46
|
-
'addDestinationMiddleware',
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
// Define a factory to create stubs. These are placeholders
|
|
50
|
-
// for methods in Analytics.js so that you never have to wait
|
|
51
|
-
// for it to load to actually record data. The `method` is
|
|
52
|
-
// stored as the first argument, so we can replay the data.
|
|
53
|
-
analytics.factory = function (method) {
|
|
54
|
-
return function () {
|
|
55
|
-
const args = Array.prototype.slice.call(arguments);
|
|
56
|
-
args.unshift(method);
|
|
57
|
-
analytics.push(args);
|
|
58
|
-
return analytics;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// For each of our methods, generate a queueing stub.
|
|
63
|
-
for (let i = 0; i < analytics.methods.length; i++) {
|
|
64
|
-
const key = analytics.methods[i];
|
|
65
|
-
analytics[key] = analytics.factory(key);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Define a method to load Analytics.js from our CDN,
|
|
69
|
-
// and that will be sure to only ever load it once.
|
|
70
|
-
analytics.load = function (key, options) {
|
|
71
|
-
// Create an async script element based on your key.
|
|
72
|
-
const script = document.createElement('script');
|
|
73
|
-
script.type = 'text/javascript';
|
|
74
|
-
script.async = true;
|
|
75
|
-
script.src =
|
|
76
|
-
'https://cdn.segment.com/analytics.js/v1/' + key + '/analytics.min.js';
|
|
77
|
-
|
|
78
|
-
// Insert our script next to the first script element.
|
|
79
|
-
const first = document.getElementsByTagName('script')[0];
|
|
80
|
-
first.parentNode.insertBefore(script, first);
|
|
81
|
-
analytics._loadOptions = options;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Add a version to keep track of what's in the wild.
|
|
85
|
-
analytics.SNIPPET_VERSION = '4.1.0';
|
|
86
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Consent } from './consent';
|
|
2
|
-
export interface UserIntegrationSummary {
|
|
3
|
-
email: string;
|
|
4
|
-
id: string;
|
|
5
|
-
}
|
|
6
|
-
export interface SegmentAnalytics {
|
|
7
|
-
identify(id: string, details: Record<string, string>, options: SegmentAnalyticsOptions): void;
|
|
8
|
-
initialize?: boolean;
|
|
9
|
-
load(writeKey: string, options: SegmentAnalyticsOptions): void;
|
|
10
|
-
page(): void;
|
|
11
|
-
}
|
|
12
|
-
export interface SegmentDestination {
|
|
13
|
-
category: string;
|
|
14
|
-
id: string;
|
|
15
|
-
}
|
|
16
|
-
export interface SegmentAnalyticsOptions {
|
|
17
|
-
integrations: Record<string, boolean>;
|
|
18
|
-
}
|
|
19
|
-
export interface TrackingWindow {
|
|
20
|
-
analytics?: SegmentAnalytics;
|
|
21
|
-
dataLayer?: unknown[];
|
|
22
|
-
OnetrustActiveGroups?: Consent[];
|
|
23
|
-
OptanonWrapper?: () => void;
|
|
24
|
-
}
|
|
File without changes
|