@chordcommerce/analytics 1.9.0 → 1.9.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/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +28 -3
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
23
23
|
options: ChordAnalyticsOptions<T>;
|
|
24
24
|
constructor(options: ChordAnalyticsOptions<T>);
|
|
25
25
|
cdp: () => AnyAnalytics;
|
|
26
|
+
ccdp: () => AnyAnalytics;
|
|
26
27
|
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
27
28
|
/**
|
|
28
29
|
* Validate the body of a `track` event against the Chord tracking plan.
|
package/dist/client/index.js
CHANGED
|
@@ -22,15 +22,24 @@ export class ChordAnalytics {
|
|
|
22
22
|
*/
|
|
23
23
|
this.invoked = true;
|
|
24
24
|
/*
|
|
25
|
-
* Return the CDP instance
|
|
25
|
+
* Return the CDP instance provided in `options.cdp`.
|
|
26
26
|
*/
|
|
27
27
|
this.cdp = () => {
|
|
28
|
-
|
|
29
|
-
const a =
|
|
28
|
+
var _a;
|
|
29
|
+
const a = (_a = this.options) === null || _a === void 0 ? void 0 : _a.cdp;
|
|
30
30
|
if (typeof a === 'function')
|
|
31
31
|
return a();
|
|
32
32
|
return a;
|
|
33
33
|
};
|
|
34
|
+
/*
|
|
35
|
+
* Return the Chord CDP instance or queue.
|
|
36
|
+
*/
|
|
37
|
+
this.ccdp = () => {
|
|
38
|
+
const { cdpDomain, cdpWriteKey, namespace } = this.options;
|
|
39
|
+
if (!cdpDomain || !cdpWriteKey)
|
|
40
|
+
return null;
|
|
41
|
+
return (window === null || window === void 0 ? void 0 : window[`_${namespace}`]) || cdpQueue(namespace);
|
|
42
|
+
};
|
|
34
43
|
/*
|
|
35
44
|
* Log a message to the console if `options.enableLogging` is true.
|
|
36
45
|
*/
|
|
@@ -90,6 +99,10 @@ export class ChordAnalytics {
|
|
|
90
99
|
if (a && typeof a.track === 'function') {
|
|
91
100
|
a.track(event, finalEventProps, options, () => resolve());
|
|
92
101
|
}
|
|
102
|
+
const b = this.ccdp();
|
|
103
|
+
if (b && typeof b.track === 'function') {
|
|
104
|
+
b.track(event, finalEventProps, options, () => resolve());
|
|
105
|
+
}
|
|
93
106
|
}
|
|
94
107
|
catch (error) {
|
|
95
108
|
this.logger(error);
|
|
@@ -105,6 +118,10 @@ export class ChordAnalytics {
|
|
|
105
118
|
if (a && typeof a.identify === 'function') {
|
|
106
119
|
a.identify(...props);
|
|
107
120
|
}
|
|
121
|
+
const b = this.ccdp();
|
|
122
|
+
if (b && typeof b.identify === 'function') {
|
|
123
|
+
b.identify(...props);
|
|
124
|
+
}
|
|
108
125
|
}
|
|
109
126
|
catch (error) {
|
|
110
127
|
this.logger(error);
|
|
@@ -119,6 +136,10 @@ export class ChordAnalytics {
|
|
|
119
136
|
if (a && typeof a.page === 'function') {
|
|
120
137
|
a.page({ meta: this.meta() });
|
|
121
138
|
}
|
|
139
|
+
const b = this.ccdp();
|
|
140
|
+
if (b && typeof b.page === 'function') {
|
|
141
|
+
b.page({ meta: this.meta() });
|
|
142
|
+
}
|
|
122
143
|
}
|
|
123
144
|
catch (error) {
|
|
124
145
|
this.logger(error);
|
|
@@ -130,6 +151,10 @@ export class ChordAnalytics {
|
|
|
130
151
|
if (a && typeof a.reset === 'function') {
|
|
131
152
|
a.reset();
|
|
132
153
|
}
|
|
154
|
+
const b = this.ccdp();
|
|
155
|
+
if (b && typeof b.reset === 'function') {
|
|
156
|
+
b.reset();
|
|
157
|
+
}
|
|
133
158
|
}
|
|
134
159
|
catch (error) {
|
|
135
160
|
this.logger(error);
|
package/package.json
CHANGED