@chordcommerce/analytics 1.17.1 → 1.18.1
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/README.md +8 -0
- package/dist/cjs/client/cdp.d.ts +3 -0
- package/dist/cjs/client/cdp.js +123 -0
- package/dist/cjs/client/consent/index.d.ts +11 -0
- package/dist/cjs/client/consent/index.js +241 -0
- package/dist/cjs/client/consent/ketch.d.ts +16 -0
- package/dist/cjs/client/consent/ketch.js +53 -0
- package/dist/cjs/client/consent/onetrust.d.ts +22 -0
- package/dist/cjs/client/consent/onetrust.js +85 -0
- package/dist/cjs/client/consent/segment.d.ts +17 -0
- package/dist/cjs/client/consent/segment.js +155 -0
- package/dist/cjs/client/consent/shopify.d.ts +21 -0
- package/dist/cjs/client/consent/shopify.js +51 -0
- package/dist/cjs/client/index.d.ts +111 -0
- package/dist/cjs/client/index.js +861 -0
- package/dist/cjs/client/utils.d.ts +1 -0
- package/dist/cjs/client/utils.js +12 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/setupTests.d.ts +1 -0
- package/dist/cjs/setupTests.js +6 -0
- package/dist/cjs/types/client.d.ts +96 -0
- package/dist/cjs/types/client.js +2 -0
- package/dist/cjs/types/consent.d.ts +11 -0
- package/dist/cjs/types/consent.js +2 -0
- package/dist/cjs/types/formatters.d.ts +114 -0
- package/dist/cjs/types/formatters.js +2 -0
- package/dist/cjs/types/index.d.ts +7 -0
- package/dist/cjs/types/index.js +22 -0
- package/dist/cjs/types/input.d.ts +396 -0
- package/dist/cjs/types/input.js +2 -0
- package/dist/cjs/types/objects.d.ts +379 -0
- package/dist/cjs/types/objects.js +2 -0
- package/dist/cjs/types/typewriter.d.ts +6502 -0
- package/dist/cjs/types/typewriter.js +5 -0
- package/dist/cjs/utils.d.ts +2 -0
- package/dist/cjs/utils.js +25 -0
- package/dist/cjs/validators/custom.d.ts +43 -0
- package/dist/cjs/validators/custom.js +18 -0
- package/dist/cjs/validators/index.d.ts +4 -0
- package/dist/cjs/validators/index.js +20 -0
- package/dist/cjs/validators/objects.d.ts +696 -0
- package/dist/cjs/validators/objects.js +128 -0
- package/dist/cjs/validators/tracking-plan-map.d.ts +6603 -0
- package/dist/cjs/validators/tracking-plan-map.js +72 -0
- package/dist/cjs/validators/tracking-plan.d.ts +9275 -0
- package/dist/cjs/validators/tracking-plan.js +1682 -0
- package/dist/client/consent/index.js +1 -1
- package/dist/client/consent/onetrust.d.ts +2 -2
- package/dist/client/consent/onetrust.js +30 -6
- package/package.json +4 -2
|
@@ -27,7 +27,7 @@ export const addCdpConsent = (options) => {
|
|
|
27
27
|
case 'ketch':
|
|
28
28
|
return ketchConsentAdapter();
|
|
29
29
|
case 'onetrust':
|
|
30
|
-
return onetrustConsentAdapter();
|
|
30
|
+
return onetrustConsentAdapter(options);
|
|
31
31
|
case 'shopify':
|
|
32
32
|
return shopifyConsentAdapter();
|
|
33
33
|
case 'segment':
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConsentConfiguration } from '../../types/index.js';
|
|
1
|
+
import type { ChordAnalyticsOptions, ConsentConfiguration } from '../../types/index.js';
|
|
2
2
|
declare global {
|
|
3
3
|
interface Window {
|
|
4
4
|
OneTrust?: OneTrustApi;
|
|
@@ -14,7 +14,7 @@ interface OneTrustApi {
|
|
|
14
14
|
interface OneTrustGroup {
|
|
15
15
|
CustomGroupId: string;
|
|
16
16
|
}
|
|
17
|
-
export declare const onetrustConsentAdapter: () => {
|
|
17
|
+
export declare const onetrustConsentAdapter: (options: ChordAnalyticsOptions) => {
|
|
18
18
|
getCurrentConsent: () => ConsentConfiguration;
|
|
19
19
|
handleConsentUpdates: (updateCdpConsent: (consent: ConsentConfiguration) => void) => void;
|
|
20
20
|
userCanBeTracked: () => boolean;
|
|
@@ -42,15 +42,39 @@ const getCurrentConsent = () => {
|
|
|
42
42
|
/**
|
|
43
43
|
* Handles subsequent changes to consent configuration.
|
|
44
44
|
*/
|
|
45
|
-
const handleConsentUpdates = (updateCdpConsent) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const handleConsentUpdates = (updateCdpConsent, options) => {
|
|
46
|
+
const maxRetries = 100;
|
|
47
|
+
const retryInterval = 50;
|
|
48
|
+
let attempts = 0;
|
|
49
|
+
const setupHandler = () => {
|
|
50
|
+
const api = getApi();
|
|
51
|
+
if (!api) {
|
|
52
|
+
attempts++;
|
|
53
|
+
if (attempts < maxRetries) {
|
|
54
|
+
if (options.debug && options.enableLogging) {
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log('OneTrust API not found, retrying...');
|
|
57
|
+
}
|
|
58
|
+
setTimeout(setupHandler, retryInterval);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (options.debug && options.enableLogging) {
|
|
63
|
+
// eslint-disable-next-line no-console
|
|
64
|
+
console.log('OneTrust API found, setting up consent changed handler');
|
|
65
|
+
}
|
|
66
|
+
api.OnConsentChanged(() => {
|
|
67
|
+
updateCdpConsent(getCurrentConsent());
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
setupHandler();
|
|
49
71
|
};
|
|
50
|
-
export const onetrustConsentAdapter = () => {
|
|
72
|
+
export const onetrustConsentAdapter = (options) => {
|
|
51
73
|
return {
|
|
52
74
|
getCurrentConsent,
|
|
53
|
-
handleConsentUpdates
|
|
75
|
+
handleConsentUpdates: (updateCdpConsent) => {
|
|
76
|
+
handleConsentUpdates(updateCdpConsent, options);
|
|
77
|
+
},
|
|
54
78
|
userCanBeTracked,
|
|
55
79
|
};
|
|
56
80
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chordcommerce/analytics",
|
|
3
3
|
"description": "Chord Commerce event tracking",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.18.1",
|
|
5
5
|
"author": "Chord Commerce <help@chord.co> (https://www.chord.co)",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "yarn clean &&
|
|
17
|
+
"build": "yarn clean && yarn build:esm && yarn build:cjs",
|
|
18
|
+
"build:cjs": "tsc -b tsconfig-build-cjs.json",
|
|
19
|
+
"build:esm": "tsc -b tsconfig-build.json",
|
|
18
20
|
"clean": "rimraf dist",
|
|
19
21
|
"test": "jest",
|
|
20
22
|
"test:watch": "jest --watch",
|