@chordcommerce/analytics 1.18.1 → 1.18.3-beta.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/cjs/client/cdp.js +11 -3
- package/dist/cjs/client/consent/index.js +13 -6
- package/dist/cjs/client/index.d.ts +5 -6
- package/dist/cjs/client/index.js +78 -50
- package/dist/client/cdp.js +7 -1
- package/dist/client/consent/index.js +8 -4
- package/dist/client/index.d.ts +5 -6
- package/dist/client/index.js +107 -94
- package/package.json +1 -1
package/dist/cjs/client/cdp.js
CHANGED
|
@@ -75,10 +75,18 @@ var addCdpSnippet = function (options) { return __awaiter(void 0, void 0, void 0
|
|
|
75
75
|
case 1:
|
|
76
76
|
// Wait for CDP to be ready before setting up consent
|
|
77
77
|
_a.sent();
|
|
78
|
-
if (options.consent)
|
|
79
|
-
|
|
78
|
+
if (!options.consent) return [3 /*break*/, 3];
|
|
79
|
+
if (options.debug && options.enableLogging) {
|
|
80
|
+
console.log('Chord CDP: Setting up consent management');
|
|
80
81
|
}
|
|
81
|
-
return [
|
|
82
|
+
return [4 /*yield*/, (0, index_js_1.addCdpConsent)(options).init()];
|
|
83
|
+
case 2:
|
|
84
|
+
_a.sent();
|
|
85
|
+
if (options.debug && options.enableLogging) {
|
|
86
|
+
console.log('Chord CDP: Consent management setup complete');
|
|
87
|
+
}
|
|
88
|
+
_a.label = 3;
|
|
89
|
+
case 3: return [2 /*return*/];
|
|
82
90
|
}
|
|
83
91
|
});
|
|
84
92
|
}); };
|
|
@@ -209,7 +209,7 @@ var addCdpConsent = function (options) {
|
|
|
209
209
|
* Returns a promise that resolves to true if CDP should be loaded, false otherwise.
|
|
210
210
|
*/
|
|
211
211
|
var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
212
|
-
var canBeTracked;
|
|
212
|
+
var canBeTracked, error_1;
|
|
213
213
|
return __generator(this, function (_a) {
|
|
214
214
|
switch (_a.label) {
|
|
215
215
|
case 0:
|
|
@@ -226,11 +226,18 @@ var addCdpConsent = function (options) {
|
|
|
226
226
|
return [2 /*return*/, false];
|
|
227
227
|
_a.label = 2;
|
|
228
228
|
case 2:
|
|
229
|
-
|
|
230
|
-
setupConsentManagement()
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return [
|
|
229
|
+
_a.trys.push([2, 4, , 5]);
|
|
230
|
+
return [4 /*yield*/, setupConsentManagement()];
|
|
231
|
+
case 3:
|
|
232
|
+
_a.sent();
|
|
233
|
+
return [3 /*break*/, 5];
|
|
234
|
+
case 4:
|
|
235
|
+
error_1 = _a.sent();
|
|
236
|
+
if (options.debug && options.enableLogging) {
|
|
237
|
+
console.error('Error setting up consent management:', error_1);
|
|
238
|
+
}
|
|
239
|
+
return [3 /*break*/, 5];
|
|
240
|
+
case 5: return [2 /*return*/, true];
|
|
234
241
|
}
|
|
235
242
|
});
|
|
236
243
|
}); };
|
|
@@ -30,6 +30,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
30
30
|
* Promise that resolves when CDP is ready
|
|
31
31
|
*/
|
|
32
32
|
private cdpReadyPromise;
|
|
33
|
+
private resetInProgress;
|
|
33
34
|
constructor(options: ChordAnalyticsOptions<T>);
|
|
34
35
|
/**
|
|
35
36
|
* Initialize CDP snippet and wait for it to be ready
|
|
@@ -43,9 +44,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
43
44
|
cdp: () => AnyAnalytics;
|
|
44
45
|
ccdp: () => AnyAnalytics;
|
|
45
46
|
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
46
|
-
|
|
47
|
-
* Validate the body of a `track` event against the Chord tracking plan.
|
|
48
|
-
*/
|
|
47
|
+
isResetting: () => boolean;
|
|
49
48
|
validate: (event: string, props: EventProperties) => ValidateResult[];
|
|
50
49
|
/**
|
|
51
50
|
* Generate the event `meta` property.
|
|
@@ -74,8 +73,8 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
74
73
|
* Send an `identify` event to the CDP with user id and traits.
|
|
75
74
|
*/
|
|
76
75
|
identify: {
|
|
77
|
-
(userId?: string, traits?: IdentifyTraits, options?: AnyOptions): void
|
|
78
|
-
(traits?: IdentifyTraits, options?: AnyOptions): void
|
|
76
|
+
(userId?: string, traits?: IdentifyTraits, options?: AnyOptions): Promise<void>;
|
|
77
|
+
(traits?: IdentifyTraits, options?: AnyOptions): Promise<void>;
|
|
79
78
|
};
|
|
80
79
|
/**
|
|
81
80
|
* Send a `page` event to the CDP.
|
|
@@ -83,7 +82,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
83
82
|
page: {
|
|
84
83
|
(props?: Record<string, any>): void;
|
|
85
84
|
};
|
|
86
|
-
reset: () => void
|
|
85
|
+
reset: () => Promise<void>;
|
|
87
86
|
trackCartViewed: (props: CartViewedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
88
87
|
trackCheckoutStarted: (props: CheckoutStartedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
89
88
|
trackCheckoutStepCompleted: (props: CheckoutStepCompletedInput, options?: AnyOptions) => Promise<void>;
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -81,6 +81,7 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
81
81
|
* Promise that resolves when CDP is ready
|
|
82
82
|
*/
|
|
83
83
|
this.cdpReadyPromise = null;
|
|
84
|
+
this.resetInProgress = false;
|
|
84
85
|
/**
|
|
85
86
|
* Set debug mode for Chord Analytics
|
|
86
87
|
* @param enabled - Whether debug mode should be enabled
|
|
@@ -123,9 +124,9 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
123
124
|
// eslint-disable-next-line no-console
|
|
124
125
|
console.log.apply(console, __spreadArray([message], optionalParams, false));
|
|
125
126
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
this.isResetting = function () {
|
|
128
|
+
return _this.resetInProgress;
|
|
129
|
+
};
|
|
129
130
|
this.validate = function (event, props) {
|
|
130
131
|
if (!event) {
|
|
131
132
|
_this.logger('No event name provided');
|
|
@@ -258,8 +259,7 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
258
259
|
props[_i] = arguments[_i];
|
|
259
260
|
}
|
|
260
261
|
return __awaiter(_this, void 0, void 0, function () {
|
|
261
|
-
var identifyPromises, a_2, b_2;
|
|
262
|
-
var _this = this;
|
|
262
|
+
var identifyPromises, a_2, b_2, results, error_1;
|
|
263
263
|
return __generator(this, function (_a) {
|
|
264
264
|
switch (_a.label) {
|
|
265
265
|
case 0:
|
|
@@ -269,29 +269,30 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
269
269
|
_a.sent();
|
|
270
270
|
_a.label = 2;
|
|
271
271
|
case 2:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
b_2 = this.cdp();
|
|
281
|
-
if (b_2 && typeof b_2.identify === 'function') {
|
|
282
|
-
identifyPromises.push(new Promise(function (resolve) {
|
|
283
|
-
b_2.identify.apply(b_2, __spreadArray(__spreadArray([], props, false), [function () { return resolve(); }], false));
|
|
284
|
-
}));
|
|
285
|
-
}
|
|
286
|
-
// We don't return the promise to maintain the void return type
|
|
287
|
-
Promise.allSettled(identifyPromises).then(function (results) {
|
|
288
|
-
_this.logger('identify event sent', results);
|
|
289
|
-
});
|
|
272
|
+
_a.trys.push([2, 4, , 5]);
|
|
273
|
+
identifyPromises = [];
|
|
274
|
+
a_2 = this.ccdp();
|
|
275
|
+
if (a_2 && typeof a_2.identify === 'function') {
|
|
276
|
+
identifyPromises.push(new Promise(function (resolve) {
|
|
277
|
+
a_2.identify.apply(a_2, __spreadArray(__spreadArray([], props, false), [function () { return resolve(); }], false));
|
|
278
|
+
}));
|
|
290
279
|
}
|
|
291
|
-
|
|
292
|
-
|
|
280
|
+
b_2 = this.cdp();
|
|
281
|
+
if (b_2 && typeof b_2.identify === 'function') {
|
|
282
|
+
identifyPromises.push(new Promise(function (resolve) {
|
|
283
|
+
b_2.identify.apply(b_2, __spreadArray(__spreadArray([], props, false), [function () { return resolve(); }], false));
|
|
284
|
+
}));
|
|
293
285
|
}
|
|
294
|
-
return [
|
|
286
|
+
return [4 /*yield*/, Promise.allSettled(identifyPromises)];
|
|
287
|
+
case 3:
|
|
288
|
+
results = _a.sent();
|
|
289
|
+
this.logger('identify event sent', results);
|
|
290
|
+
return [3 /*break*/, 5];
|
|
291
|
+
case 4:
|
|
292
|
+
error_1 = _a.sent();
|
|
293
|
+
this.logger(error_1);
|
|
294
|
+
return [3 /*break*/, 5];
|
|
295
|
+
case 5: return [2 /*return*/];
|
|
295
296
|
}
|
|
296
297
|
});
|
|
297
298
|
});
|
|
@@ -340,28 +341,55 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
340
341
|
});
|
|
341
342
|
});
|
|
342
343
|
};
|
|
343
|
-
this.reset = function () {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
344
|
+
this.reset = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
345
|
+
var a, b, maxAttempts, attempts, userState, error_2;
|
|
346
|
+
var _a;
|
|
347
|
+
return __generator(this, function (_b) {
|
|
348
|
+
switch (_b.label) {
|
|
349
|
+
case 0:
|
|
350
|
+
_b.trys.push([0, 4, 5, 6]);
|
|
351
|
+
this.resetInProgress = true;
|
|
352
|
+
a = this.ccdp();
|
|
353
|
+
if (a && typeof a.reset === 'function') {
|
|
354
|
+
a.reset();
|
|
355
|
+
}
|
|
356
|
+
b = this.cdp();
|
|
357
|
+
if (b && typeof b.reset === 'function') {
|
|
358
|
+
b.reset();
|
|
359
|
+
}
|
|
360
|
+
maxAttempts = 50;
|
|
361
|
+
attempts = 0;
|
|
362
|
+
_b.label = 1;
|
|
363
|
+
case 1:
|
|
364
|
+
if (!(attempts < maxAttempts)) return [3 /*break*/, 3];
|
|
365
|
+
// eslint-disable-next-line
|
|
366
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 10); })];
|
|
367
|
+
case 2:
|
|
368
|
+
// eslint-disable-next-line
|
|
369
|
+
_b.sent();
|
|
370
|
+
try {
|
|
371
|
+
userState = ((_a = a === null || a === void 0 ? void 0 : a.user) === null || _a === void 0 ? void 0 : _a.call(a)) || {};
|
|
372
|
+
if (userState.userId === null || userState.userId === undefined) {
|
|
373
|
+
return [3 /*break*/, 3];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (_c) {
|
|
377
|
+
return [3 /*break*/, 3];
|
|
378
|
+
}
|
|
379
|
+
attempts++;
|
|
380
|
+
return [3 /*break*/, 1];
|
|
381
|
+
case 3: return [3 /*break*/, 6];
|
|
382
|
+
case 4:
|
|
383
|
+
error_2 = _b.sent();
|
|
384
|
+
this.logger(error_2);
|
|
385
|
+
return [3 /*break*/, 6];
|
|
386
|
+
case 5:
|
|
387
|
+
this.resetInProgress = false;
|
|
388
|
+
return [7 /*endfinally*/];
|
|
389
|
+
case 6: return [2 /*return*/];
|
|
357
390
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
catch (error) {
|
|
362
|
-
_this.logger(error);
|
|
363
|
-
}
|
|
364
|
-
};
|
|
391
|
+
});
|
|
392
|
+
}); };
|
|
365
393
|
// TODO: Add support for props.products
|
|
366
394
|
this.trackCartViewed = function (props, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
367
395
|
var cart, payload, formattedPayload;
|
|
@@ -837,7 +865,7 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
837
865
|
*/
|
|
838
866
|
ChordAnalytics.prototype.initializeCdp = function () {
|
|
839
867
|
return __awaiter(this, void 0, void 0, function () {
|
|
840
|
-
var
|
|
868
|
+
var error_3;
|
|
841
869
|
return __generator(this, function (_a) {
|
|
842
870
|
switch (_a.label) {
|
|
843
871
|
case 0:
|
|
@@ -848,8 +876,8 @@ var ChordAnalytics = /** @class */ (function () {
|
|
|
848
876
|
_a.sent();
|
|
849
877
|
return [3 /*break*/, 3];
|
|
850
878
|
case 2:
|
|
851
|
-
|
|
852
|
-
console.error('CDP initialization failed:',
|
|
879
|
+
error_3 = _a.sent();
|
|
880
|
+
console.error('CDP initialization failed:', error_3);
|
|
853
881
|
return [3 /*break*/, 3];
|
|
854
882
|
case 3: return [2 /*return*/];
|
|
855
883
|
}
|
package/dist/client/cdp.js
CHANGED
|
@@ -40,7 +40,13 @@ export const addCdpSnippet = (options) => __awaiter(void 0, void 0, void 0, func
|
|
|
40
40
|
// Wait for CDP to be ready before setting up consent
|
|
41
41
|
yield cdpReadyPromise;
|
|
42
42
|
if (options.consent) {
|
|
43
|
-
|
|
43
|
+
if (options.debug && options.enableLogging) {
|
|
44
|
+
console.log('Chord CDP: Setting up consent management');
|
|
45
|
+
}
|
|
46
|
+
yield addCdpConsent(options).init();
|
|
47
|
+
if (options.debug && options.enableLogging) {
|
|
48
|
+
console.log('Chord CDP: Consent management setup complete');
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
});
|
|
46
52
|
/*
|
|
@@ -148,10 +148,14 @@ export const addCdpConsent = (options) => {
|
|
|
148
148
|
if (!canBeTracked)
|
|
149
149
|
return false;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
try {
|
|
152
|
+
yield setupConsentManagement();
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (options.debug && options.enableLogging) {
|
|
156
|
+
console.error('Error setting up consent management:', error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
155
159
|
return true;
|
|
156
160
|
});
|
|
157
161
|
return {
|
package/dist/client/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
30
30
|
* Promise that resolves when CDP is ready
|
|
31
31
|
*/
|
|
32
32
|
private cdpReadyPromise;
|
|
33
|
+
private resetInProgress;
|
|
33
34
|
constructor(options: ChordAnalyticsOptions<T>);
|
|
34
35
|
/**
|
|
35
36
|
* Initialize CDP snippet and wait for it to be ready
|
|
@@ -43,9 +44,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
43
44
|
cdp: () => AnyAnalytics;
|
|
44
45
|
ccdp: () => AnyAnalytics;
|
|
45
46
|
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
46
|
-
|
|
47
|
-
* Validate the body of a `track` event against the Chord tracking plan.
|
|
48
|
-
*/
|
|
47
|
+
isResetting: () => boolean;
|
|
49
48
|
validate: (event: string, props: EventProperties) => ValidateResult[];
|
|
50
49
|
/**
|
|
51
50
|
* Generate the event `meta` property.
|
|
@@ -74,8 +73,8 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
74
73
|
* Send an `identify` event to the CDP with user id and traits.
|
|
75
74
|
*/
|
|
76
75
|
identify: {
|
|
77
|
-
(userId?: string, traits?: IdentifyTraits, options?: AnyOptions): void
|
|
78
|
-
(traits?: IdentifyTraits, options?: AnyOptions): void
|
|
76
|
+
(userId?: string, traits?: IdentifyTraits, options?: AnyOptions): Promise<void>;
|
|
77
|
+
(traits?: IdentifyTraits, options?: AnyOptions): Promise<void>;
|
|
79
78
|
};
|
|
80
79
|
/**
|
|
81
80
|
* Send a `page` event to the CDP.
|
|
@@ -83,7 +82,7 @@ export declare class ChordAnalytics<T extends ObjectTypes = ObjectTypes> {
|
|
|
83
82
|
page: {
|
|
84
83
|
(props?: Record<string, any>): void;
|
|
85
84
|
};
|
|
86
|
-
reset: () => void
|
|
85
|
+
reset: () => Promise<void>;
|
|
87
86
|
trackCartViewed: (props: CartViewedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
88
87
|
trackCheckoutStarted: (props: CheckoutStartedInput<T>, options?: AnyOptions) => Promise<void>;
|
|
89
88
|
trackCheckoutStepCompleted: (props: CheckoutStepCompletedInput, options?: AnyOptions) => Promise<void>;
|
package/dist/client/index.js
CHANGED
|
@@ -30,6 +30,7 @@ export class ChordAnalytics {
|
|
|
30
30
|
* Promise that resolves when CDP is ready
|
|
31
31
|
*/
|
|
32
32
|
this.cdpReadyPromise = null;
|
|
33
|
+
this.resetInProgress = false;
|
|
33
34
|
/**
|
|
34
35
|
* Set debug mode for Chord Analytics
|
|
35
36
|
* @param enabled - Whether debug mode should be enabled
|
|
@@ -68,9 +69,9 @@ export class ChordAnalytics {
|
|
|
68
69
|
// eslint-disable-next-line no-console
|
|
69
70
|
console.log(message, ...optionalParams);
|
|
70
71
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
this.isResetting = () => {
|
|
73
|
+
return this.resetInProgress;
|
|
74
|
+
};
|
|
74
75
|
this.validate = (event, props) => {
|
|
75
76
|
if (!event) {
|
|
76
77
|
this.logger('No event name provided');
|
|
@@ -207,10 +208,8 @@ export class ChordAnalytics {
|
|
|
207
208
|
b.identify(...props, () => resolve());
|
|
208
209
|
}));
|
|
209
210
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.logger('identify event sent', results);
|
|
213
|
-
});
|
|
211
|
+
const results = yield Promise.allSettled(identifyPromises);
|
|
212
|
+
this.logger('identify event sent', results);
|
|
214
213
|
}
|
|
215
214
|
catch (error) {
|
|
216
215
|
this.logger(error);
|
|
@@ -247,32 +246,46 @@ export class ChordAnalytics {
|
|
|
247
246
|
this.logger(error);
|
|
248
247
|
}
|
|
249
248
|
});
|
|
250
|
-
this.reset = () => {
|
|
249
|
+
this.reset = () => __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
var _d;
|
|
251
251
|
try {
|
|
252
|
-
|
|
252
|
+
this.resetInProgress = true;
|
|
253
253
|
const a = this.ccdp();
|
|
254
254
|
if (a && typeof a.reset === 'function') {
|
|
255
|
-
|
|
256
|
-
a.reset(() => resolve());
|
|
257
|
-
}));
|
|
255
|
+
a.reset();
|
|
258
256
|
}
|
|
259
257
|
const b = this.cdp();
|
|
260
258
|
if (b && typeof b.reset === 'function') {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
259
|
+
b.reset();
|
|
260
|
+
}
|
|
261
|
+
const maxAttempts = 50;
|
|
262
|
+
let attempts = 0;
|
|
263
|
+
while (attempts < maxAttempts) {
|
|
264
|
+
// eslint-disable-next-line
|
|
265
|
+
yield new Promise((resolve) => setTimeout(resolve, 10));
|
|
266
|
+
try {
|
|
267
|
+
const userState = ((_d = a === null || a === void 0 ? void 0 : a.user) === null || _d === void 0 ? void 0 : _d.call(a)) || {};
|
|
268
|
+
if (userState.userId === null || userState.userId === undefined) {
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
catch (_e) {
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
attempts++;
|
|
264
276
|
}
|
|
265
|
-
// We don't return the promise to maintain the return type
|
|
266
|
-
Promise.allSettled(resetPromises).catch(this.logger);
|
|
267
277
|
}
|
|
268
278
|
catch (error) {
|
|
269
279
|
this.logger(error);
|
|
270
280
|
}
|
|
271
|
-
|
|
281
|
+
finally {
|
|
282
|
+
this.resetInProgress = false;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
272
285
|
// TODO: Add support for props.products
|
|
273
286
|
this.trackCartViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
274
|
-
var
|
|
275
|
-
const cart = (
|
|
287
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
288
|
+
const cart = (_j = (_h = (_g = (_f = this.options) === null || _f === void 0 ? void 0 : _f.formatters) === null || _g === void 0 ? void 0 : _g.objects) === null || _h === void 0 ? void 0 : _h.cart) === null || _j === void 0 ? void 0 : _j.call(_h, {
|
|
276
289
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
277
290
|
});
|
|
278
291
|
const payload = {
|
|
@@ -281,17 +294,17 @@ export class ChordAnalytics {
|
|
|
281
294
|
products: cart === null || cart === void 0 ? void 0 : cart.products,
|
|
282
295
|
value: cart === null || cart === void 0 ? void 0 : cart.value,
|
|
283
296
|
};
|
|
284
|
-
if ((
|
|
285
|
-
const formattedPayload = (
|
|
297
|
+
if ((_m = (_l = (_k = this.options) === null || _k === void 0 ? void 0 : _k.formatters) === null || _l === void 0 ? void 0 : _l.events) === null || _m === void 0 ? void 0 : _m.cartViewed) {
|
|
298
|
+
const formattedPayload = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.formatters) === null || _p === void 0 ? void 0 : _p.events) === null || _q === void 0 ? void 0 : _q.cartViewed(props, payload);
|
|
286
299
|
return this.track('Cart Viewed', formattedPayload, options);
|
|
287
300
|
}
|
|
288
301
|
return this.track('Cart Viewed', payload, options);
|
|
289
302
|
});
|
|
290
303
|
// TODO: Add support for props.products
|
|
291
304
|
this.trackCheckoutStarted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
var
|
|
293
|
-
const formatter = (
|
|
294
|
-
const checkout = (
|
|
305
|
+
var _r, _s, _t, _u, _v, _w, _x;
|
|
306
|
+
const formatter = (_t = (_s = (_r = this.options) === null || _r === void 0 ? void 0 : _r.formatters) === null || _s === void 0 ? void 0 : _s.events) === null || _t === void 0 ? void 0 : _t.checkoutStarted;
|
|
307
|
+
const checkout = (_x = (_w = (_v = (_u = this.options) === null || _u === void 0 ? void 0 : _u.formatters) === null || _v === void 0 ? void 0 : _v.objects) === null || _w === void 0 ? void 0 : _w.checkout) === null || _x === void 0 ? void 0 : _x.call(_w, {
|
|
295
308
|
checkout: props === null || props === void 0 ? void 0 : props.checkout,
|
|
296
309
|
});
|
|
297
310
|
const payload = checkout;
|
|
@@ -302,8 +315,8 @@ export class ChordAnalytics {
|
|
|
302
315
|
return this.track('Checkout Started', payload, options);
|
|
303
316
|
});
|
|
304
317
|
this.trackCheckoutStepCompleted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
305
|
-
var
|
|
306
|
-
const formatter = (
|
|
318
|
+
var _y, _z, _0;
|
|
319
|
+
const formatter = (_0 = (_z = (_y = this.options) === null || _y === void 0 ? void 0 : _y.formatters) === null || _z === void 0 ? void 0 : _z.events) === null || _0 === void 0 ? void 0 : _0.checkoutStepCompleted;
|
|
307
320
|
const payload = {
|
|
308
321
|
checkout_id: props === null || props === void 0 ? void 0 : props.checkoutId,
|
|
309
322
|
payment_method: props === null || props === void 0 ? void 0 : props.paymentMethod,
|
|
@@ -317,8 +330,8 @@ export class ChordAnalytics {
|
|
|
317
330
|
return this.track('Checkout Step Completed', payload, options);
|
|
318
331
|
});
|
|
319
332
|
this.trackCheckoutStepViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
320
|
-
var
|
|
321
|
-
const formatter = (
|
|
333
|
+
var _1, _2, _3;
|
|
334
|
+
const formatter = (_3 = (_2 = (_1 = this.options) === null || _1 === void 0 ? void 0 : _1.formatters) === null || _2 === void 0 ? void 0 : _2.events) === null || _3 === void 0 ? void 0 : _3.checkoutStepViewed;
|
|
322
335
|
const payload = {
|
|
323
336
|
checkout_id: props === null || props === void 0 ? void 0 : props.checkoutId,
|
|
324
337
|
payment_method: props === null || props === void 0 ? void 0 : props.paymentMethod,
|
|
@@ -332,8 +345,8 @@ export class ChordAnalytics {
|
|
|
332
345
|
return this.track('Checkout Step Viewed', payload, options);
|
|
333
346
|
});
|
|
334
347
|
this.trackCouponApplied = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
335
|
-
var
|
|
336
|
-
const formatter = (
|
|
348
|
+
var _4, _5, _6;
|
|
349
|
+
const formatter = (_6 = (_5 = (_4 = this.options) === null || _4 === void 0 ? void 0 : _4.formatters) === null || _5 === void 0 ? void 0 : _5.events) === null || _6 === void 0 ? void 0 : _6.couponApplied;
|
|
337
350
|
const payload = {
|
|
338
351
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
339
352
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -348,8 +361,8 @@ export class ChordAnalytics {
|
|
|
348
361
|
return this.track('Coupon Applied', payload, options);
|
|
349
362
|
});
|
|
350
363
|
this.trackCouponDenied = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
351
|
-
var
|
|
352
|
-
const formatter = (
|
|
364
|
+
var _7, _8, _9;
|
|
365
|
+
const formatter = (_9 = (_8 = (_7 = this.options) === null || _7 === void 0 ? void 0 : _7.formatters) === null || _8 === void 0 ? void 0 : _8.events) === null || _9 === void 0 ? void 0 : _9.couponDenied;
|
|
353
366
|
const payload = {
|
|
354
367
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
355
368
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -364,8 +377,8 @@ export class ChordAnalytics {
|
|
|
364
377
|
return this.track('Coupon Denied', payload, options);
|
|
365
378
|
});
|
|
366
379
|
this.trackCouponEntered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
367
|
-
var
|
|
368
|
-
const formatter = (
|
|
380
|
+
var _10, _11, _12;
|
|
381
|
+
const formatter = (_12 = (_11 = (_10 = this.options) === null || _10 === void 0 ? void 0 : _10.formatters) === null || _11 === void 0 ? void 0 : _11.events) === null || _12 === void 0 ? void 0 : _12.couponEntered;
|
|
369
382
|
const payload = {
|
|
370
383
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
371
384
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -379,8 +392,8 @@ export class ChordAnalytics {
|
|
|
379
392
|
return this.track('Coupon Entered', payload, options);
|
|
380
393
|
});
|
|
381
394
|
this.trackCouponRemoved = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
382
|
-
var
|
|
383
|
-
const formatter = (
|
|
395
|
+
var _13, _14, _15;
|
|
396
|
+
const formatter = (_15 = (_14 = (_13 = this.options) === null || _13 === void 0 ? void 0 : _13.formatters) === null || _14 === void 0 ? void 0 : _14.events) === null || _15 === void 0 ? void 0 : _15.couponRemoved;
|
|
384
397
|
const payload = {
|
|
385
398
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
386
399
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -395,8 +408,8 @@ export class ChordAnalytics {
|
|
|
395
408
|
return this.track('Coupon Removed', payload, options);
|
|
396
409
|
});
|
|
397
410
|
this.trackEmailCaptured = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
398
|
-
var
|
|
399
|
-
const formatter = (
|
|
411
|
+
var _16, _17, _18;
|
|
412
|
+
const formatter = (_18 = (_17 = (_16 = this.options) === null || _16 === void 0 ? void 0 : _16.formatters) === null || _17 === void 0 ? void 0 : _17.events) === null || _18 === void 0 ? void 0 : _18.emailCaptured;
|
|
400
413
|
const payload = {
|
|
401
414
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
402
415
|
placement_component: props === null || props === void 0 ? void 0 : props.placementComponent,
|
|
@@ -409,13 +422,13 @@ export class ChordAnalytics {
|
|
|
409
422
|
return this.track('Email Captured', payload, options);
|
|
410
423
|
});
|
|
411
424
|
this.trackProductAdded = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
412
|
-
var
|
|
413
|
-
const formatter = (
|
|
414
|
-
const product = (
|
|
415
|
-
const cart = (
|
|
425
|
+
var _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30;
|
|
426
|
+
const formatter = (_21 = (_20 = (_19 = this.options) === null || _19 === void 0 ? void 0 : _19.formatters) === null || _20 === void 0 ? void 0 : _20.events) === null || _21 === void 0 ? void 0 : _21.productAdded;
|
|
427
|
+
const product = (_25 = (_24 = (_23 = (_22 = this.options) === null || _22 === void 0 ? void 0 : _22.formatters) === null || _23 === void 0 ? void 0 : _23.objects) === null || _24 === void 0 ? void 0 : _24.product) === null || _25 === void 0 ? void 0 : _25.call(_24, props === null || props === void 0 ? void 0 : props.product);
|
|
428
|
+
const cart = (_29 = (_28 = (_27 = (_26 = this.options) === null || _26 === void 0 ? void 0 : _26.formatters) === null || _27 === void 0 ? void 0 : _27.objects) === null || _28 === void 0 ? void 0 : _28.cart) === null || _29 === void 0 ? void 0 : _29.call(_28, {
|
|
416
429
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
417
430
|
});
|
|
418
|
-
const quantity = ((
|
|
431
|
+
const quantity = ((_30 = props === null || props === void 0 ? void 0 : props.product) === null || _30 === void 0 ? void 0 : _30.quantity) || 1;
|
|
419
432
|
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, products: [Object.assign(Object.assign({}, product), { quantity })], total: product.price * (quantity || 1), value: product.price * (quantity || 1) });
|
|
420
433
|
if (typeof formatter === 'function') {
|
|
421
434
|
const formattedPayload = formatter(props, payload);
|
|
@@ -424,14 +437,14 @@ export class ChordAnalytics {
|
|
|
424
437
|
return this.track('Product Added', payload, options);
|
|
425
438
|
});
|
|
426
439
|
this.trackProductClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
427
|
-
var
|
|
428
|
-
const formatter = (
|
|
429
|
-
const product = (
|
|
430
|
-
const cart = (
|
|
440
|
+
var _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43;
|
|
441
|
+
const formatter = (_33 = (_32 = (_31 = this.options) === null || _31 === void 0 ? void 0 : _31.formatters) === null || _32 === void 0 ? void 0 : _32.events) === null || _33 === void 0 ? void 0 : _33.productClicked;
|
|
442
|
+
const product = (_37 = (_36 = (_35 = (_34 = this.options) === null || _34 === void 0 ? void 0 : _34.formatters) === null || _35 === void 0 ? void 0 : _35.objects) === null || _36 === void 0 ? void 0 : _36.product) === null || _37 === void 0 ? void 0 : _37.call(_36, props === null || props === void 0 ? void 0 : props.product);
|
|
443
|
+
const cart = (_41 = (_40 = (_39 = (_38 = this.options) === null || _38 === void 0 ? void 0 : _38.formatters) === null || _39 === void 0 ? void 0 : _39.objects) === null || _40 === void 0 ? void 0 : _40.cart) === null || _41 === void 0 ? void 0 : _41.call(_40, {
|
|
431
444
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
432
445
|
});
|
|
433
|
-
const quantity = ((
|
|
434
|
-
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, item_list_id: (
|
|
446
|
+
const quantity = ((_42 = props === null || props === void 0 ? void 0 : props.product) === null || _42 === void 0 ? void 0 : _42.quantity) || 1;
|
|
447
|
+
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, item_list_id: (_43 = props === null || props === void 0 ? void 0 : props.listId) === null || _43 === void 0 ? void 0 : _43.toString(), item_list_name: props === null || props === void 0 ? void 0 : props.listName, products: [Object.assign(Object.assign({}, product), { quantity })] });
|
|
435
448
|
if (typeof formatter === 'function') {
|
|
436
449
|
const formattedPayload = formatter(props, payload);
|
|
437
450
|
return this.track('Product Clicked', formattedPayload, options);
|
|
@@ -439,13 +452,13 @@ export class ChordAnalytics {
|
|
|
439
452
|
return this.track('Product Clicked', payload, options);
|
|
440
453
|
});
|
|
441
454
|
this.trackVariantClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
442
|
-
var
|
|
443
|
-
const formatter = (
|
|
444
|
-
const product = (
|
|
445
|
-
const cart = (
|
|
455
|
+
var _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55;
|
|
456
|
+
const formatter = (_46 = (_45 = (_44 = this.options) === null || _44 === void 0 ? void 0 : _44.formatters) === null || _45 === void 0 ? void 0 : _45.events) === null || _46 === void 0 ? void 0 : _46.variantClicked;
|
|
457
|
+
const product = (_50 = (_49 = (_48 = (_47 = this.options) === null || _47 === void 0 ? void 0 : _47.formatters) === null || _48 === void 0 ? void 0 : _48.objects) === null || _49 === void 0 ? void 0 : _49.product) === null || _50 === void 0 ? void 0 : _50.call(_49, props === null || props === void 0 ? void 0 : props.product);
|
|
458
|
+
const cart = (_54 = (_53 = (_52 = (_51 = this.options) === null || _51 === void 0 ? void 0 : _51.formatters) === null || _52 === void 0 ? void 0 : _52.objects) === null || _53 === void 0 ? void 0 : _53.cart) === null || _54 === void 0 ? void 0 : _54.call(_53, {
|
|
446
459
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
447
460
|
});
|
|
448
|
-
const quantity = ((
|
|
461
|
+
const quantity = ((_55 = props === null || props === void 0 ? void 0 : props.product) === null || _55 === void 0 ? void 0 : _55.quantity) || 1;
|
|
449
462
|
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, quantity: quantity, line_item_id: props === null || props === void 0 ? void 0 : props.lineItemId, coupon: props === null || props === void 0 ? void 0 : props.coupon });
|
|
450
463
|
if (typeof formatter === 'function') {
|
|
451
464
|
const formattedPayload = formatter(props, payload);
|
|
@@ -454,13 +467,13 @@ export class ChordAnalytics {
|
|
|
454
467
|
return this.track('Variant Clicked', payload, options);
|
|
455
468
|
});
|
|
456
469
|
this.trackProductListFiltered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
457
|
-
var
|
|
458
|
-
const formatter = (
|
|
470
|
+
var _56, _57, _58, _59, _60;
|
|
471
|
+
const formatter = (_58 = (_57 = (_56 = this.options) === null || _56 === void 0 ? void 0 : _56.formatters) === null || _57 === void 0 ? void 0 : _57.events) === null || _58 === void 0 ? void 0 : _58.productListFiltered;
|
|
459
472
|
const payload = {
|
|
460
473
|
category: props === null || props === void 0 ? void 0 : props.category,
|
|
461
474
|
filters: props === null || props === void 0 ? void 0 : props.filters,
|
|
462
|
-
list_id: (
|
|
463
|
-
item_list_id: (
|
|
475
|
+
list_id: (_59 = props === null || props === void 0 ? void 0 : props.listId) === null || _59 === void 0 ? void 0 : _59.toString(),
|
|
476
|
+
item_list_id: (_60 = props === null || props === void 0 ? void 0 : props.listId) === null || _60 === void 0 ? void 0 : _60.toString(),
|
|
464
477
|
item_list_name: props === null || props === void 0 ? void 0 : props.listName,
|
|
465
478
|
sorts: props === null || props === void 0 ? void 0 : props.sorts,
|
|
466
479
|
};
|
|
@@ -471,14 +484,14 @@ export class ChordAnalytics {
|
|
|
471
484
|
return this.track('Product List Filtered', payload, options);
|
|
472
485
|
});
|
|
473
486
|
this.trackProductListViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
474
|
-
var
|
|
475
|
-
const formatter = (
|
|
487
|
+
var _61, _62, _63, _64, _65, _66;
|
|
488
|
+
const formatter = (_63 = (_62 = (_61 = this.options) === null || _61 === void 0 ? void 0 : _61.formatters) === null || _62 === void 0 ? void 0 : _62.events) === null || _63 === void 0 ? void 0 : _63.productListViewed;
|
|
476
489
|
const payload = {
|
|
477
490
|
category: props === null || props === void 0 ? void 0 : props.category,
|
|
478
|
-
list_id: (
|
|
479
|
-
item_list_id: (
|
|
491
|
+
list_id: (_64 = props === null || props === void 0 ? void 0 : props.listId) === null || _64 === void 0 ? void 0 : _64.toString(),
|
|
492
|
+
item_list_id: (_65 = props === null || props === void 0 ? void 0 : props.listId) === null || _65 === void 0 ? void 0 : _65.toString(),
|
|
480
493
|
item_list_name: props === null || props === void 0 ? void 0 : props.listName,
|
|
481
|
-
products: (
|
|
494
|
+
products: (_66 = props === null || props === void 0 ? void 0 : props.products) === null || _66 === void 0 ? void 0 : _66.map((p, i) => {
|
|
482
495
|
var _a, _b, _c, _d;
|
|
483
496
|
return (_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.product) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign(Object.assign({}, p), { position: i + 1 }));
|
|
484
497
|
}),
|
|
@@ -491,8 +504,8 @@ export class ChordAnalytics {
|
|
|
491
504
|
return this.track('Product List Viewed', payload, options);
|
|
492
505
|
});
|
|
493
506
|
this.trackProductRemoved = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
494
|
-
var
|
|
495
|
-
const formatter = (
|
|
507
|
+
var _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81;
|
|
508
|
+
const formatter = (_69 = (_68 = (_67 = this.options) === null || _67 === void 0 ? void 0 : _67.formatters) === null || _68 === void 0 ? void 0 : _68.events) === null || _69 === void 0 ? void 0 : _69.productRemoved;
|
|
496
509
|
/*
|
|
497
510
|
const product = this.options?.formatters?.objects?.product?.({
|
|
498
511
|
position: props?.position,
|
|
@@ -501,13 +514,13 @@ export class ChordAnalytics {
|
|
|
501
514
|
variantId: props?.variantId,
|
|
502
515
|
})
|
|
503
516
|
*/
|
|
504
|
-
const lineItem = (
|
|
517
|
+
const lineItem = (_73 = (_72 = (_71 = (_70 = this.options) === null || _70 === void 0 ? void 0 : _70.formatters) === null || _71 === void 0 ? void 0 : _71.objects) === null || _72 === void 0 ? void 0 : _72.lineItem) === null || _73 === void 0 ? void 0 : _73.call(_72, {
|
|
505
518
|
lineItem: props === null || props === void 0 ? void 0 : props.lineItem,
|
|
506
519
|
});
|
|
507
|
-
const cart = (
|
|
520
|
+
const cart = (_77 = (_76 = (_75 = (_74 = this.options) === null || _74 === void 0 ? void 0 : _74.formatters) === null || _75 === void 0 ? void 0 : _75.objects) === null || _76 === void 0 ? void 0 : _76.cart) === null || _77 === void 0 ? void 0 : _77.call(_76, {
|
|
508
521
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
509
522
|
});
|
|
510
|
-
const payload = Object.assign(Object.assign({}, lineItem), { cart_id: cart.cart_id, currency: cart.currency, products: [lineItem], total: ((
|
|
523
|
+
const payload = Object.assign(Object.assign({}, lineItem), { cart_id: cart.cart_id, currency: cart.currency, products: [lineItem], total: ((_78 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _78 !== void 0 ? _78 : 0) * ((_79 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _79 !== void 0 ? _79 : 1), value: ((_80 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _80 !== void 0 ? _80 : 0) * ((_81 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _81 !== void 0 ? _81 : 1) });
|
|
511
524
|
if (typeof formatter === 'function') {
|
|
512
525
|
const formattedPayload = formatter(props, payload);
|
|
513
526
|
return this.track('Product Removed', formattedPayload, options);
|
|
@@ -515,14 +528,14 @@ export class ChordAnalytics {
|
|
|
515
528
|
return this.track('Product Removed', payload, options);
|
|
516
529
|
});
|
|
517
530
|
this.trackProductViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
518
|
-
var
|
|
519
|
-
const formatter = (
|
|
520
|
-
const product = (
|
|
521
|
-
const cart = (
|
|
531
|
+
var _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94;
|
|
532
|
+
const formatter = (_84 = (_83 = (_82 = this.options) === null || _82 === void 0 ? void 0 : _82.formatters) === null || _83 === void 0 ? void 0 : _83.events) === null || _84 === void 0 ? void 0 : _84.productViewed;
|
|
533
|
+
const product = (_88 = (_87 = (_86 = (_85 = this.options) === null || _85 === void 0 ? void 0 : _85.formatters) === null || _86 === void 0 ? void 0 : _86.objects) === null || _87 === void 0 ? void 0 : _87.product) === null || _88 === void 0 ? void 0 : _88.call(_87, props === null || props === void 0 ? void 0 : props.product);
|
|
534
|
+
const cart = (_92 = (_91 = (_90 = (_89 = this.options) === null || _89 === void 0 ? void 0 : _89.formatters) === null || _90 === void 0 ? void 0 : _90.objects) === null || _91 === void 0 ? void 0 : _91.cart) === null || _92 === void 0 ? void 0 : _92.call(_91, {
|
|
522
535
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
523
536
|
});
|
|
524
|
-
const quantity = ((
|
|
525
|
-
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, products: [Object.assign(Object.assign({}, product), { quantity })], value: product.price * (((
|
|
537
|
+
const quantity = ((_93 = props === null || props === void 0 ? void 0 : props.product) === null || _93 === void 0 ? void 0 : _93.quantity) || 1;
|
|
538
|
+
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, products: [Object.assign(Object.assign({}, product), { quantity })], value: product.price * (((_94 = props === null || props === void 0 ? void 0 : props.product) === null || _94 === void 0 ? void 0 : _94.quantity) || 1) });
|
|
526
539
|
if (typeof formatter === 'function') {
|
|
527
540
|
const formattedPayload = formatter(props, payload);
|
|
528
541
|
return this.track('Product Viewed', formattedPayload, options);
|
|
@@ -530,12 +543,12 @@ export class ChordAnalytics {
|
|
|
530
543
|
return this.track('Product Viewed', payload, options);
|
|
531
544
|
});
|
|
532
545
|
this.trackProductsSearched = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
533
|
-
var
|
|
534
|
-
const formatter = (
|
|
546
|
+
var _95, _96, _97, _98;
|
|
547
|
+
const formatter = (_97 = (_96 = (_95 = this.options) === null || _95 === void 0 ? void 0 : _95.formatters) === null || _96 === void 0 ? void 0 : _96.events) === null || _97 === void 0 ? void 0 : _97.productsSearched;
|
|
535
548
|
const payload = {
|
|
536
549
|
currency: props === null || props === void 0 ? void 0 : props.currency,
|
|
537
550
|
price: typeof (props === null || props === void 0 ? void 0 : props.price) !== 'undefined' ? Number(props === null || props === void 0 ? void 0 : props.price) : undefined,
|
|
538
|
-
product_id: (
|
|
551
|
+
product_id: (_98 = props === null || props === void 0 ? void 0 : props.productId) === null || _98 === void 0 ? void 0 : _98.toString(),
|
|
539
552
|
quantity: props === null || props === void 0 ? void 0 : props.quantity,
|
|
540
553
|
query: props === null || props === void 0 ? void 0 : props.query,
|
|
541
554
|
};
|
|
@@ -546,8 +559,8 @@ export class ChordAnalytics {
|
|
|
546
559
|
return this.track('Products Searched', payload, options);
|
|
547
560
|
});
|
|
548
561
|
this.trackSignedIn = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
549
|
-
var
|
|
550
|
-
const formatter = (
|
|
562
|
+
var _99, _100, _101;
|
|
563
|
+
const formatter = (_101 = (_100 = (_99 = this.options) === null || _99 === void 0 ? void 0 : _99.formatters) === null || _100 === void 0 ? void 0 : _100.events) === null || _101 === void 0 ? void 0 : _101.signedIn;
|
|
551
564
|
const payload = {
|
|
552
565
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
553
566
|
method: props === null || props === void 0 ? void 0 : props.method,
|
|
@@ -559,8 +572,8 @@ export class ChordAnalytics {
|
|
|
559
572
|
return this.track('Signed In', payload, options);
|
|
560
573
|
});
|
|
561
574
|
this.trackSignedOut = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
562
|
-
var
|
|
563
|
-
const formatter = (
|
|
575
|
+
var _102, _103, _104;
|
|
576
|
+
const formatter = (_104 = (_103 = (_102 = this.options) === null || _102 === void 0 ? void 0 : _102.formatters) === null || _103 === void 0 ? void 0 : _103.events) === null || _104 === void 0 ? void 0 : _104.signedOut;
|
|
564
577
|
const payload = {
|
|
565
578
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
566
579
|
};
|
|
@@ -571,8 +584,8 @@ export class ChordAnalytics {
|
|
|
571
584
|
return this.track('Signed Out', payload, options);
|
|
572
585
|
});
|
|
573
586
|
this.trackSignedUp = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
574
|
-
var
|
|
575
|
-
const formatter = (
|
|
587
|
+
var _105, _106, _107;
|
|
588
|
+
const formatter = (_107 = (_106 = (_105 = this.options) === null || _105 === void 0 ? void 0 : _105.formatters) === null || _106 === void 0 ? void 0 : _106.events) === null || _107 === void 0 ? void 0 : _107.signedUp;
|
|
576
589
|
const payload = {
|
|
577
590
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
578
591
|
method: props === null || props === void 0 ? void 0 : props.method,
|
|
@@ -584,8 +597,8 @@ export class ChordAnalytics {
|
|
|
584
597
|
return this.track('Signed Up', payload, options);
|
|
585
598
|
});
|
|
586
599
|
this.trackLoginStarted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
587
|
-
var
|
|
588
|
-
const formatter = (
|
|
600
|
+
var _108, _109, _110;
|
|
601
|
+
const formatter = (_110 = (_109 = (_108 = this.options) === null || _108 === void 0 ? void 0 : _108.formatters) === null || _109 === void 0 ? void 0 : _109.events) === null || _110 === void 0 ? void 0 : _110.loginStarted;
|
|
589
602
|
const payload = {
|
|
590
603
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
591
604
|
};
|
|
@@ -596,8 +609,8 @@ export class ChordAnalytics {
|
|
|
596
609
|
return this.track('Login Started', payload, options);
|
|
597
610
|
});
|
|
598
611
|
this.trackSubscriptionCancelled = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
599
|
-
var
|
|
600
|
-
const formatter = (
|
|
612
|
+
var _111, _112, _113, _114;
|
|
613
|
+
const formatter = (_113 = (_112 = (_111 = this.options) === null || _111 === void 0 ? void 0 : _111.formatters) === null || _112 === void 0 ? void 0 : _112.events) === null || _113 === void 0 ? void 0 : _113.subscriptionCancelled;
|
|
601
614
|
const payload = {
|
|
602
615
|
actionable_date: props === null || props === void 0 ? void 0 : props.actionableDate,
|
|
603
616
|
address: props === null || props === void 0 ? void 0 : props.address,
|
|
@@ -606,7 +619,7 @@ export class ChordAnalytics {
|
|
|
606
619
|
end_date: props === null || props === void 0 ? void 0 : props.endDate,
|
|
607
620
|
interval_length: props === null || props === void 0 ? void 0 : props.intervalLength,
|
|
608
621
|
interval_units: props === null || props === void 0 ? void 0 : props.intervalUnits,
|
|
609
|
-
products: (
|
|
622
|
+
products: (_114 = props === null || props === void 0 ? void 0 : props.products) === null || _114 === void 0 ? void 0 : _114.map((p, i) => {
|
|
610
623
|
var _a, _b, _c, _d;
|
|
611
624
|
return (_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.product) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign(Object.assign({}, p), { position: i + 1 }));
|
|
612
625
|
}),
|
|
@@ -621,8 +634,8 @@ export class ChordAnalytics {
|
|
|
621
634
|
return this.track('Subscription Cancelled', payload, options);
|
|
622
635
|
});
|
|
623
636
|
this.trackNavigationClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
624
|
-
var
|
|
625
|
-
const formatter = (
|
|
637
|
+
var _115, _116, _117;
|
|
638
|
+
const formatter = (_117 = (_116 = (_115 = this.options) === null || _115 === void 0 ? void 0 : _115.formatters) === null || _116 === void 0 ? void 0 : _116.events) === null || _117 === void 0 ? void 0 : _117.navigationClicked;
|
|
626
639
|
const payload = {
|
|
627
640
|
category: props === null || props === void 0 ? void 0 : props.category,
|
|
628
641
|
label: props === null || props === void 0 ? void 0 : props.label,
|
|
@@ -637,15 +650,15 @@ export class ChordAnalytics {
|
|
|
637
650
|
return this.track('Navigation Clicked', payload, options);
|
|
638
651
|
});
|
|
639
652
|
this.trackPaymentInfoEntered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
640
|
-
var
|
|
641
|
-
const formatter = (
|
|
653
|
+
var _118, _119, _120, _121;
|
|
654
|
+
const formatter = (_120 = (_119 = (_118 = this.options) === null || _118 === void 0 ? void 0 : _118.formatters) === null || _119 === void 0 ? void 0 : _119.events) === null || _120 === void 0 ? void 0 : _120.paymentInfoEntered;
|
|
642
655
|
const payload = {
|
|
643
656
|
checkout_id: props === null || props === void 0 ? void 0 : props.checkoutId,
|
|
644
657
|
coupon: props === null || props === void 0 ? void 0 : props.coupon,
|
|
645
658
|
currency: props === null || props === void 0 ? void 0 : props.currency,
|
|
646
659
|
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
647
660
|
payment_method: props === null || props === void 0 ? void 0 : props.paymentMethod,
|
|
648
|
-
products: (
|
|
661
|
+
products: (_121 = props === null || props === void 0 ? void 0 : props.products) === null || _121 === void 0 ? void 0 : _121.map((p, i) => {
|
|
649
662
|
var _a, _b, _c, _d;
|
|
650
663
|
return (_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.product) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign(Object.assign({}, p), { position: i + 1 }));
|
|
651
664
|
}),
|
package/package.json
CHANGED