@codecademy/tracking 0.25.1-alpha.1a54e4.0 → 0.25.1-alpha.5b36ce.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 216c90d217c37b75
1
+ @codecademy/tracking:build: cache hit, replaying output 53b2821e10cf2062
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 (1747ms).
10
+ @codecademy/tracking:build: Successfully compiled 18 files with Babel (2060ms).
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.1a54e4.0](https://github.com/Codecademy/client-modules/compare/@codecademy/tracking@0.25.0...@codecademy/tracking@0.25.1-alpha.1a54e4.0) (2022-10-20)
6
+ ### [0.25.1-alpha.5b36ce.0](https://github.com/Codecademy/client-modules/compare/@codecademy/tracking@0.25.0...@codecademy/tracking@0.25.1-alpha.5b36ce.0) (2022-10-24)
7
7
 
8
8
  **Note:** Version bump only for package @codecademy/tracking
9
9
 
@@ -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,46 +16,52 @@ 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, writeKey, optedOut, 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
25
  onError = _ref.onError, production = _ref.production, scope = _ref.scope, user = _ref.user, writeKey = _ref.writeKey;
25
- _context.next = 3;
26
+ optedOut = user === null || user === void 0 ? void 0 : user.opted_out_external_tracking; // 1. Wait 1000ms to allow any other post-hydration logic to run first
27
+
28
+ _context.next = 4;
26
29
  return new Promise(function (resolve) {
27
30
  return setTimeout(resolve, 1000);
28
31
  });
29
32
 
30
- case 3:
31
- _context.next = 5;
33
+ case 4:
34
+ _context.next = 6;
32
35
  return initializeOneTrust({
33
36
  scope: scope,
34
37
  production: production
35
38
  });
36
39
 
37
- case 5:
38
- // 3. Segment's copy-and-paste snippet is run to load the Segment global library
40
+ case 6:
41
+ if (optedOut) {
42
+ scope.OnetrustActiveGroups = [Consent.StrictlyNecessary, Consent.Functional];
43
+ } // 3. Segment's copy-and-paste snippet is run to load the Segment global library
44
+
45
+
39
46
  runSegmentSnippet(); // 4. Destination integrations for Segment are fetched
40
47
 
41
- _context.next = 8;
48
+ _context.next = 10;
42
49
  return fetchDestinationsForWriteKey({
43
50
  onError: onError,
44
51
  writeKey: writeKey
45
52
  });
46
53
 
47
- case 8:
54
+ case 10:
48
55
  destinations = _context.sent;
49
56
 
50
57
  if (destinations) {
51
- _context.next = 11;
58
+ _context.next = 13;
52
59
  break;
53
60
  }
54
61
 
55
62
  return _context.abrupt("return");
56
63
 
57
- case 11:
64
+ case 13:
58
65
  // 5. Those integrations are compared against the user's consent decisions into a list of allowed destinations
59
66
  _mapDestinations = mapDestinations({
60
67
  consentDecision: scope.OnetrustActiveGroups,
@@ -69,7 +76,7 @@ export var initializeTrackingIntegrations = /*#__PURE__*/function () {
69
76
  writeKey: writeKey
70
77
  });
71
78
 
72
- case 13:
79
+ case 15:
73
80
  case "end":
74
81
  return _context.stop();
75
82
  }
@@ -2,6 +2,7 @@ import { Consent } from './consent';
2
2
  export interface UserIntegrationSummary {
3
3
  email: string;
4
4
  id: string;
5
+ opted_out_external_tracking: boolean;
5
6
  }
6
7
  export interface SegmentAnalytics {
7
8
  identify(id: string, details: Record<string, string>, options: SegmentAnalyticsOptions): void;
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.1a54e4.0",
4
+ "version": "0.25.1-alpha.5b36ce.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.1a54e4.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": "4a0521b0b5a28071423bb6f61f2f14ac1a8da09c"
38
+ "gitHead": "29503baa2905555fad928184d58a78776afdad0c"
39
39
  }