@codecademy/tracking 0.25.1-alpha.0c5e25.0 → 0.25.1-alpha.39ffef.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.
@@ -1,4 +1,4 @@
1
- @codecademy/tracking:build: cache hit, replaying output 1d6a7a29a6606c46
1
+ @codecademy/tracking:build: cache hit, replaying output 63a9971dd36f0e2a
2
2
  @codecademy/tracking:build: $ yarn build:clean && yarn build:compile && yarn build:types
3
3
  @codecademy/tracking:build: $ rm -rf dist
4
4
  @codecademy/tracking:build: $ babel ./src --out-dir ./dist --copy-files --extensions ".ts,.tsx"
@@ -7,5 +7,5 @@
7
7
  @codecademy/tracking:build: 
8
8
  @codecademy/tracking:build: Why you should do it regularly:
9
9
  @codecademy/tracking:build: https://github.com/browserslist/browserslist#browsers-data-updating
10
- @codecademy/tracking:build: Successfully compiled 18 files with Babel (2779ms).
10
+ @codecademy/tracking:build: Successfully compiled 18 files with Babel (1935ms).
11
11
  @codecademy/tracking:build: $ tsc --emitDeclarationOnly
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ### [0.25.1-alpha.0c5e25.0](https://github.com/Codecademy/client-modules/compare/@codecademy/tracking@0.25.0...@codecademy/tracking@0.25.1-alpha.0c5e25.0) (2022-10-21)
6
+ ### [0.25.1-alpha.39ffef.0](https://github.com/Codecademy/client-modules/compare/@codecademy/tracking@0.25.0...@codecademy/tracking@0.25.1-alpha.39ffef.0) (2022-10-25)
7
7
 
8
8
  **Note:** Version bump only for package @codecademy/tracking
9
9
 
@@ -16,6 +16,10 @@ export declare type TrackingIntegrationsSettings = {
16
16
  * User details to identify in Segment.
17
17
  */
18
18
  user?: UserIntegrationSummary;
19
+ /**
20
+ * Whether user has opted out or is excluded from external tracking
21
+ */
22
+ optedOutExternalTracking: boolean;
19
23
  /**
20
24
  * Segment write key.
21
25
  */
@@ -24,4 +28,4 @@ export declare type TrackingIntegrationsSettings = {
24
28
  /**
25
29
  * @see README.md for details and usage.
26
30
  */
27
- export declare const initializeTrackingIntegrations: ({ onError, production, scope, user, writeKey, }: TrackingIntegrationsSettings) => Promise<void>;
31
+ export declare const initializeTrackingIntegrations: ({ onError, production, scope, user, optedOutExternalTracking, writeKey, }: TrackingIntegrationsSettings) => Promise<void>;
@@ -5,6 +5,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
5
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
6
 
7
7
  import { conditionallyLoadAnalytics } from './conditionallyLoadAnalytics';
8
+ import { Consent } from './consent';
8
9
  import { fetchDestinationsForWriteKey } from './fetchDestinationsForWriteKey';
9
10
  import { mapDestinations } from './mapDestinations';
10
11
  import { initializeOneTrust } from './onetrust';
@@ -15,13 +16,13 @@ import { runSegmentSnippet } from './runSegmentSnippet';
15
16
  */
16
17
  export var initializeTrackingIntegrations = /*#__PURE__*/function () {
17
18
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
18
- var onError, production, scope, user, writeKey, destinations, _mapDestinations, destinationPreferences, identifyPreferences;
19
+ var onError, production, scope, user, optedOutExternalTracking, writeKey, destinations, _mapDestinations, destinationPreferences, identifyPreferences;
19
20
 
20
21
  return _regeneratorRuntime.wrap(function _callee$(_context) {
21
22
  while (1) {
22
23
  switch (_context.prev = _context.next) {
23
24
  case 0:
24
- onError = _ref.onError, production = _ref.production, scope = _ref.scope, user = _ref.user, writeKey = _ref.writeKey;
25
+ onError = _ref.onError, production = _ref.production, scope = _ref.scope, user = _ref.user, optedOutExternalTracking = _ref.optedOutExternalTracking, writeKey = _ref.writeKey;
25
26
  _context.next = 3;
26
27
  return new Promise(function (resolve) {
27
28
  return setTimeout(resolve, 1000);
@@ -35,26 +36,30 @@ export var initializeTrackingIntegrations = /*#__PURE__*/function () {
35
36
  });
36
37
 
37
38
  case 5:
38
- // 3. Segment's copy-and-paste snippet is run to load the Segment global library
39
+ if (optedOutExternalTracking) {
40
+ scope.OnetrustActiveGroups = [Consent.StrictlyNecessary, Consent.Functional];
41
+ } // 3. Segment's copy-and-paste snippet is run to load the Segment global library
42
+
43
+
39
44
  runSegmentSnippet(); // 4. Destination integrations for Segment are fetched
40
45
 
41
- _context.next = 8;
46
+ _context.next = 9;
42
47
  return fetchDestinationsForWriteKey({
43
48
  onError: onError,
44
49
  writeKey: writeKey
45
50
  });
46
51
 
47
- case 8:
52
+ case 9:
48
53
  destinations = _context.sent;
49
54
 
50
55
  if (destinations) {
51
- _context.next = 11;
56
+ _context.next = 12;
52
57
  break;
53
58
  }
54
59
 
55
60
  return _context.abrupt("return");
56
61
 
57
- case 11:
62
+ case 12:
58
63
  // 5. Those integrations are compared against the user's consent decisions into a list of allowed destinations
59
64
  _mapDestinations = mapDestinations({
60
65
  consentDecision: scope.OnetrustActiveGroups,
@@ -69,7 +74,7 @@ export var initializeTrackingIntegrations = /*#__PURE__*/function () {
69
74
  writeKey: writeKey
70
75
  });
71
76
 
72
- case 13:
77
+ case 14:
73
78
  case "end":
74
79
  return _context.stop();
75
80
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codecademy/tracking",
3
3
  "description": "Tracking library for Codecademy apps.",
4
- "version": "0.25.1-alpha.0c5e25.0",
4
+ "version": "0.25.1-alpha.39ffef.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "module": "./dist/index.js",
7
7
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "@babel/cli": "^7.13.10",
17
17
  "@types/fetch-mock": "^7.3.3",
18
18
  "@types/jest": "^26.0.15",
19
- "babel-preset-codecademy": "6.0.1-alpha.0c5e25.0",
19
+ "babel-preset-codecademy": "^6.0.0",
20
20
  "fetch-mock": "^9.11.0",
21
21
  "jest-fetch-mock": "^3.0.3",
22
22
  "ts-jest": "^26.4.1",
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "c14cd6faf9b1146fb3476c090a8f73b82c16f79d"
38
+ "gitHead": "3a22a52e9dd3080c3aadc492878a9e3c85580559"
39
39
  }