@codecademy/tracking 0.23.0 → 0.23.4
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 +30 -0
- package/CHANGELOG.md +77 -206
- package/babel.config.js +9 -3
- package/dist/events/__tests__/track.test.d.js +1 -0
- package/dist/events/__tests__/track.test.js +13 -14
- package/dist/events/__tests__/user.test.d.js +1 -0
- package/dist/events/__tests__/user.test.js +3 -7
- package/dist/events/track.js +27 -37
- package/dist/events/types.js +2 -0
- package/dist/events/user.js +5 -7
- package/dist/integrations/__tests__/conditionallyLoadAnalytics.test.js +97 -0
- package/dist/integrations/__tests__/fetchDestinationsForWriteKey.test.js +112 -0
- package/dist/integrations/__tests__/mapDestinations.test.js +120 -0
- package/dist/integrations/device.js +2 -0
- package/dist/integrations/fetchDestinationsForWriteKey.js +27 -24
- package/dist/integrations/index.js +4 -6
- package/dist/integrations/mapDestinations.js +19 -20
- package/dist/integrations/onetrust.js +7 -9
- package/dist/integrations/runSegmentSnippet.js +0 -1
- package/dist/integrations/types.js +2 -0
- package/dist/{events → libs/tracking/src/events}/index.d.ts +0 -0
- package/dist/{events → libs/tracking/src/events}/track.d.ts +0 -0
- package/dist/{events → libs/tracking/src/events}/types.d.ts +0 -0
- package/dist/{events → libs/tracking/src/events}/user.d.ts +0 -0
- package/dist/{index.d.ts → libs/tracking/src/index.d.ts} +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/conditionallyLoadAnalytics.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/consent.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/device.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/fetchDestinationsForWriteKey.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/index.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/mapDestinations.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/onetrust.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/runSegmentSnippet.d.ts +0 -0
- package/dist/{integrations → libs/tracking/src/integrations}/types.d.ts +0 -0
- package/package.json +5 -27
- package/project.json +45 -0
- package/tsconfig.json +13 -4
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +9 -0
- package/.turbo/turbo-build.log +0 -11
- package/dist/events/__tests__/track.test.d.ts +0 -1
- package/dist/events/__tests__/user.test.d.ts +0 -1
- 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/jest.config.js +0 -1
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) 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
|
-
|
|
1
|
+
import "core-js/modules/es.object.assign.js";
|
|
2
|
+
import "core-js/modules/es.array.concat.js";
|
|
3
|
+
import "core-js/modules/es.array.includes.js";
|
|
4
|
+
import "core-js/modules/es.string.includes.js";
|
|
5
|
+
import "core-js/modules/es.array.map.js";
|
|
15
6
|
import { Consent } from './consent';
|
|
16
7
|
// The Functional category may need to be added here in the future.
|
|
17
8
|
var targetingCategories = ['Advertising', 'Attribution', 'Email Marketing'];
|
|
@@ -27,21 +18,29 @@ export var mapDestinations = function mapDestinations(_ref) {
|
|
|
27
18
|
destinations = _ref.destinations;
|
|
28
19
|
var destinationPreferences = Object.assign.apply(Object, [{
|
|
29
20
|
'Segment.io': consentDecision.includes(Consent.Functional)
|
|
30
|
-
}].concat(
|
|
21
|
+
}].concat(destinations.map(function (dest) {
|
|
22
|
+
var _ref5;
|
|
23
|
+
|
|
31
24
|
if (targetingCategories.includes(dest.category)) {
|
|
32
|
-
|
|
25
|
+
var _ref2;
|
|
26
|
+
|
|
27
|
+
return _ref2 = {}, _ref2[dest.id] = consentDecision.includes(Consent.Targeting), _ref2;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
if (performanceCategories.includes(dest.category)) {
|
|
36
|
-
|
|
31
|
+
var _ref3;
|
|
32
|
+
|
|
33
|
+
return _ref3 = {}, _ref3[dest.id] = consentDecision.includes(Consent.Performance), _ref3;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
if (functionalCategories.includes(dest.category)) {
|
|
40
|
-
|
|
37
|
+
var _ref4;
|
|
38
|
+
|
|
39
|
+
return _ref4 = {}, _ref4[dest.id] = consentDecision.includes(Consent.Functional), _ref4;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
return
|
|
44
|
-
})))
|
|
42
|
+
return _ref5 = {}, _ref5[dest.id] = true, _ref5;
|
|
43
|
+
})));
|
|
45
44
|
var identifyPreferences = {
|
|
46
45
|
All: false,
|
|
47
46
|
FullStory: consentDecision.includes(Consent.Performance),
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
1
|
+
import _asyncToGenerator from "/home/runner/work/mono/mono/node_modules/@babel/runtime/helpers/asyncToGenerator.js";
|
|
2
|
+
import _regeneratorRuntime from "/home/runner/work/mono/mono/node_modules/@babel/runtime/regenerator/index.js";
|
|
3
|
+
import "core-js/modules/es.object.to-string.js";
|
|
4
|
+
import "core-js/modules/es.promise.js";
|
|
7
5
|
export var initializeOneTrust = /*#__PURE__*/function () {
|
|
8
6
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
9
7
|
var production, scope, script, style;
|
|
@@ -16,7 +14,7 @@ export var initializeOneTrust = /*#__PURE__*/function () {
|
|
|
16
14
|
script.setAttribute('async', 'true');
|
|
17
15
|
script.setAttribute('src', 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js');
|
|
18
16
|
script.setAttribute('type', 'text/javascript');
|
|
19
|
-
script.setAttribute('data-domain-script', "cfa7b129-f37b-4f5a-9991-3f75ba7b85fb"
|
|
17
|
+
script.setAttribute('data-domain-script', "cfa7b129-f37b-4f5a-9991-3f75ba7b85fb" + (production ? '' : '-test'));
|
|
20
18
|
document.body.appendChild(script);
|
|
21
19
|
style = document.createElement('style');
|
|
22
20
|
style.textContent = rawStyles;
|
|
@@ -25,12 +23,12 @@ export var initializeOneTrust = /*#__PURE__*/function () {
|
|
|
25
23
|
scope.OptanonWrapper = function () {
|
|
26
24
|
var _scope$dataLayer, _script$parentNode;
|
|
27
25
|
|
|
28
|
-
(_scope$dataLayer = scope.dataLayer)
|
|
26
|
+
(_scope$dataLayer = scope.dataLayer) != null ? _scope$dataLayer : scope.dataLayer = [];
|
|
29
27
|
scope.dataLayer.push({
|
|
30
28
|
event: 'OneTrustGroupsUpdated'
|
|
31
29
|
});
|
|
32
30
|
resolve();
|
|
33
|
-
(_script$parentNode = script.parentNode)
|
|
31
|
+
(_script$parentNode = script.parentNode) == null ? void 0 : _script$parentNode.removeChild(script);
|
|
34
32
|
};
|
|
35
33
|
}));
|
|
36
34
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{integrations → libs/tracking/src/integrations}/conditionallyLoadAnalytics.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/{integrations → libs/tracking/src/integrations}/fetchDestinationsForWriteKey.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,39 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/tracking",
|
|
3
3
|
"description": "Tracking library for Codecademy apps.",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.4",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
|
-
"module": "./dist/index.js",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git@github.com:Codecademy/client-modules.git"
|
|
11
|
-
},
|
|
12
6
|
"dependencies": {
|
|
13
7
|
"@babel/runtime": "^7.12.1"
|
|
14
8
|
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@babel/cli": "^7.13.10",
|
|
17
|
-
"@types/fetch-mock": "^7.3.3",
|
|
18
|
-
"@types/jest": "^26.0.15",
|
|
19
|
-
"babel-preset-codecademy": "^6.0.0",
|
|
20
|
-
"fetch-mock": "^9.11.0",
|
|
21
|
-
"jest-fetch-mock": "^3.0.3",
|
|
22
|
-
"ts-jest": "^26.4.1",
|
|
23
|
-
"typescript": "*"
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"verify": "tsc --noEmit",
|
|
27
|
-
"test": "jest",
|
|
28
|
-
"test-watch": "jest --watch",
|
|
29
|
-
"build:compile": "babel ./src --out-dir ./dist --copy-files --extensions \".ts,.tsx\"",
|
|
30
|
-
"build:clean": "rm -rf dist",
|
|
31
|
-
"build:types": "tsc --emitDeclarationOnly",
|
|
32
|
-
"build": "yarn build:clean && yarn build:compile && yarn build:types"
|
|
33
|
-
},
|
|
34
9
|
"license": "MIT",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
35
12
|
"publishConfig": {
|
|
36
13
|
"access": "public"
|
|
37
14
|
},
|
|
38
|
-
"
|
|
15
|
+
"repository": "git@github.com:Codecademy/client-modules.git",
|
|
16
|
+
"gitHead": "af57b29fc3cc19e1a1bdee0033a6de2d98f89e73"
|
|
39
17
|
}
|
package/project.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
3
|
+
"sourceRoot": "libs/tracking/src",
|
|
4
|
+
"projectType": "library",
|
|
5
|
+
"targets": {
|
|
6
|
+
"build": {
|
|
7
|
+
"outputs": ["{options.outputPath}"],
|
|
8
|
+
"executor": "nx:run-commands",
|
|
9
|
+
"options": {
|
|
10
|
+
"cwd": "libs/tracking",
|
|
11
|
+
"outputPath": "./dist",
|
|
12
|
+
"commands": [
|
|
13
|
+
"rm -rf ./dist",
|
|
14
|
+
"babel ./src --out-dir ./dist --copy-files --extensions \".ts,.tsx\"",
|
|
15
|
+
"tsc --emitDeclarationOnly --project ./tsconfig.lib.json"
|
|
16
|
+
],
|
|
17
|
+
"parallel": false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"publish-build": {
|
|
21
|
+
"executor": "nx:run-commands",
|
|
22
|
+
"dependsOn": ["build"],
|
|
23
|
+
"options": {
|
|
24
|
+
"commands": [],
|
|
25
|
+
"parallel": false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"lint": {
|
|
29
|
+
"executor": "@nrwl/linter:eslint",
|
|
30
|
+
"outputs": ["{options.outputFile}"],
|
|
31
|
+
"options": {
|
|
32
|
+
"lintFilePatterns": ["libs/tracking/**/*.{ts,tsx,js,jsx}"]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"test": {
|
|
36
|
+
"executor": "@nrwl/jest:jest",
|
|
37
|
+
"outputs": ["coverage/libs/tracking"],
|
|
38
|
+
"options": {
|
|
39
|
+
"jestConfig": "libs/tracking/jest.config.ts",
|
|
40
|
+
"passWithNoTests": true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"tags": []
|
|
45
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"include": ["../../typings/*.d.ts", "./src/**/*.ts", "./src/**/*.tsx"],
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
4
3
|
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
5
11
|
"allowJs": true,
|
|
6
|
-
"
|
|
7
|
-
}
|
|
12
|
+
"declaration": true
|
|
13
|
+
},
|
|
14
|
+
"files": [],
|
|
15
|
+
"include": ["../../typings/*.d.ts", "./src/**/*.ts", "./src/**/*.tsx"],
|
|
16
|
+
"exclude": ["./dist"]
|
|
8
17
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
[35m@codecademy/tracking:build: [0mcache hit, replaying output [2ma59512fe7c92ec96[0m
|
|
2
|
-
[35m@codecademy/tracking:build: [0m$ yarn build:clean && yarn build:compile && yarn build:types
|
|
3
|
-
[35m@codecademy/tracking:build: [0m$ rm -rf dist
|
|
4
|
-
[35m@codecademy/tracking:build: [0m$ babel ./src --out-dir ./dist --copy-files --extensions ".ts,.tsx"
|
|
5
|
-
[35m@codecademy/tracking:build: [0mBrowserslist: caniuse-lite is outdated. Please run:
|
|
6
|
-
[35m@codecademy/tracking:build: [0mnpx browserslist@latest --update-db
|
|
7
|
-
[35m@codecademy/tracking:build: [0m
|
|
8
|
-
[35m@codecademy/tracking:build: [0mWhy you should do it regularly:
|
|
9
|
-
[35m@codecademy/tracking:build: [0mhttps://github.com/browserslist/browserslist#browsers-data-updating
|
|
10
|
-
[35m@codecademy/tracking:build: [0mSuccessfully compiled 18 files with Babel (1208ms).
|
|
11
|
-
[35m@codecademy/tracking:build: [0m$ tsc --emitDeclarationOnly
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/jest.config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../jest.config.base')('tracking');
|