@chordcommerce/analytics 1.18.1 → 1.18.2

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.
@@ -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>;
@@ -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
- * Validate the body of a `track` event against the Chord tracking plan.
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
- try {
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
- }));
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
- catch (error) {
292
- this.logger(error);
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 [2 /*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
- try {
345
- var resetPromises = [];
346
- var a_4 = _this.ccdp();
347
- if (a_4 && typeof a_4.reset === 'function') {
348
- resetPromises.push(new Promise(function (resolve) {
349
- a_4.reset(function () { return resolve(); });
350
- }));
351
- }
352
- var b_4 = _this.cdp();
353
- if (b_4 && typeof b_4.reset === 'function') {
354
- resetPromises.push(new Promise(function (resolve) {
355
- b_4.reset(function () { return resolve(); });
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
- // We don't return the promise to maintain the return type
359
- Promise.allSettled(resetPromises).catch(_this.logger);
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 error_1;
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
- error_1 = _a.sent();
852
- console.error('CDP initialization failed:', error_1);
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
  }
@@ -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>;
@@ -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
- * Validate the body of a `track` event against the Chord tracking plan.
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
- // We don't return the promise to maintain the void return type
211
- Promise.allSettled(identifyPromises).then((results) => {
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
- const resetPromises = [];
252
+ this.resetInProgress = true;
253
253
  const a = this.ccdp();
254
254
  if (a && typeof a.reset === 'function') {
255
- resetPromises.push(new Promise((resolve) => {
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
- resetPromises.push(new Promise((resolve) => {
262
- b.reset(() => resolve());
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 _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
275
- const cart = (_g = (_f = (_e = (_d = this.options) === null || _d === void 0 ? void 0 : _d.formatters) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.cart) === null || _g === void 0 ? void 0 : _g.call(_f, {
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 ((_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.events) === null || _k === void 0 ? void 0 : _k.cartViewed) {
285
- const formattedPayload = (_o = (_m = (_l = this.options) === null || _l === void 0 ? void 0 : _l.formatters) === null || _m === void 0 ? void 0 : _m.events) === null || _o === void 0 ? void 0 : _o.cartViewed(props, payload);
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 _p, _q, _r, _s, _t, _u, _v;
293
- const formatter = (_r = (_q = (_p = this.options) === null || _p === void 0 ? void 0 : _p.formatters) === null || _q === void 0 ? void 0 : _q.events) === null || _r === void 0 ? void 0 : _r.checkoutStarted;
294
- const checkout = (_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.formatters) === null || _t === void 0 ? void 0 : _t.objects) === null || _u === void 0 ? void 0 : _u.checkout) === null || _v === void 0 ? void 0 : _v.call(_u, {
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 _w, _x, _y;
306
- const formatter = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.formatters) === null || _x === void 0 ? void 0 : _x.events) === null || _y === void 0 ? void 0 : _y.checkoutStepCompleted;
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 _z, _0, _1;
321
- const formatter = (_1 = (_0 = (_z = this.options) === null || _z === void 0 ? void 0 : _z.formatters) === null || _0 === void 0 ? void 0 : _0.events) === null || _1 === void 0 ? void 0 : _1.checkoutStepViewed;
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 _2, _3, _4;
336
- const formatter = (_4 = (_3 = (_2 = this.options) === null || _2 === void 0 ? void 0 : _2.formatters) === null || _3 === void 0 ? void 0 : _3.events) === null || _4 === void 0 ? void 0 : _4.couponApplied;
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 _5, _6, _7;
352
- const formatter = (_7 = (_6 = (_5 = this.options) === null || _5 === void 0 ? void 0 : _5.formatters) === null || _6 === void 0 ? void 0 : _6.events) === null || _7 === void 0 ? void 0 : _7.couponDenied;
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 _8, _9, _10;
368
- const formatter = (_10 = (_9 = (_8 = this.options) === null || _8 === void 0 ? void 0 : _8.formatters) === null || _9 === void 0 ? void 0 : _9.events) === null || _10 === void 0 ? void 0 : _10.couponEntered;
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 _11, _12, _13;
383
- const formatter = (_13 = (_12 = (_11 = this.options) === null || _11 === void 0 ? void 0 : _11.formatters) === null || _12 === void 0 ? void 0 : _12.events) === null || _13 === void 0 ? void 0 : _13.couponRemoved;
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 _14, _15, _16;
399
- const formatter = (_16 = (_15 = (_14 = this.options) === null || _14 === void 0 ? void 0 : _14.formatters) === null || _15 === void 0 ? void 0 : _15.events) === null || _16 === void 0 ? void 0 : _16.emailCaptured;
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 _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
413
- const formatter = (_19 = (_18 = (_17 = this.options) === null || _17 === void 0 ? void 0 : _17.formatters) === null || _18 === void 0 ? void 0 : _18.events) === null || _19 === void 0 ? void 0 : _19.productAdded;
414
- const product = (_23 = (_22 = (_21 = (_20 = this.options) === null || _20 === void 0 ? void 0 : _20.formatters) === null || _21 === void 0 ? void 0 : _21.objects) === null || _22 === void 0 ? void 0 : _22.product) === null || _23 === void 0 ? void 0 : _23.call(_22, props === null || props === void 0 ? void 0 : props.product);
415
- const cart = (_27 = (_26 = (_25 = (_24 = this.options) === null || _24 === void 0 ? void 0 : _24.formatters) === null || _25 === void 0 ? void 0 : _25.objects) === null || _26 === void 0 ? void 0 : _26.cart) === null || _27 === void 0 ? void 0 : _27.call(_26, {
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 = ((_28 = props === null || props === void 0 ? void 0 : props.product) === null || _28 === void 0 ? void 0 : _28.quantity) || 1;
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 _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41;
428
- const formatter = (_31 = (_30 = (_29 = this.options) === null || _29 === void 0 ? void 0 : _29.formatters) === null || _30 === void 0 ? void 0 : _30.events) === null || _31 === void 0 ? void 0 : _31.productClicked;
429
- const product = (_35 = (_34 = (_33 = (_32 = this.options) === null || _32 === void 0 ? void 0 : _32.formatters) === null || _33 === void 0 ? void 0 : _33.objects) === null || _34 === void 0 ? void 0 : _34.product) === null || _35 === void 0 ? void 0 : _35.call(_34, props === null || props === void 0 ? void 0 : props.product);
430
- const cart = (_39 = (_38 = (_37 = (_36 = this.options) === null || _36 === void 0 ? void 0 : _36.formatters) === null || _37 === void 0 ? void 0 : _37.objects) === null || _38 === void 0 ? void 0 : _38.cart) === null || _39 === void 0 ? void 0 : _39.call(_38, {
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 = ((_40 = props === null || props === void 0 ? void 0 : props.product) === null || _40 === void 0 ? void 0 : _40.quantity) || 1;
434
- const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, item_list_id: (_41 = props === null || props === void 0 ? void 0 : props.listId) === null || _41 === void 0 ? void 0 : _41.toString(), item_list_name: props === null || props === void 0 ? void 0 : props.listName, products: [Object.assign(Object.assign({}, product), { quantity })] });
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 _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53;
443
- const formatter = (_44 = (_43 = (_42 = this.options) === null || _42 === void 0 ? void 0 : _42.formatters) === null || _43 === void 0 ? void 0 : _43.events) === null || _44 === void 0 ? void 0 : _44.variantClicked;
444
- const product = (_48 = (_47 = (_46 = (_45 = this.options) === null || _45 === void 0 ? void 0 : _45.formatters) === null || _46 === void 0 ? void 0 : _46.objects) === null || _47 === void 0 ? void 0 : _47.product) === null || _48 === void 0 ? void 0 : _48.call(_47, props === null || props === void 0 ? void 0 : props.product);
445
- const cart = (_52 = (_51 = (_50 = (_49 = this.options) === null || _49 === void 0 ? void 0 : _49.formatters) === null || _50 === void 0 ? void 0 : _50.objects) === null || _51 === void 0 ? void 0 : _51.cart) === null || _52 === void 0 ? void 0 : _52.call(_51, {
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 = ((_53 = props === null || props === void 0 ? void 0 : props.product) === null || _53 === void 0 ? void 0 : _53.quantity) || 1;
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 _54, _55, _56, _57, _58;
458
- const formatter = (_56 = (_55 = (_54 = this.options) === null || _54 === void 0 ? void 0 : _54.formatters) === null || _55 === void 0 ? void 0 : _55.events) === null || _56 === void 0 ? void 0 : _56.productListFiltered;
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: (_57 = props === null || props === void 0 ? void 0 : props.listId) === null || _57 === void 0 ? void 0 : _57.toString(),
463
- item_list_id: (_58 = props === null || props === void 0 ? void 0 : props.listId) === null || _58 === void 0 ? void 0 : _58.toString(),
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 _59, _60, _61, _62, _63, _64;
475
- const formatter = (_61 = (_60 = (_59 = this.options) === null || _59 === void 0 ? void 0 : _59.formatters) === null || _60 === void 0 ? void 0 : _60.events) === null || _61 === void 0 ? void 0 : _61.productListViewed;
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: (_62 = props === null || props === void 0 ? void 0 : props.listId) === null || _62 === void 0 ? void 0 : _62.toString(),
479
- item_list_id: (_63 = props === null || props === void 0 ? void 0 : props.listId) === null || _63 === void 0 ? void 0 : _63.toString(),
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: (_64 = props === null || props === void 0 ? void 0 : props.products) === null || _64 === void 0 ? void 0 : _64.map((p, i) => {
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 _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79;
495
- const formatter = (_67 = (_66 = (_65 = this.options) === null || _65 === void 0 ? void 0 : _65.formatters) === null || _66 === void 0 ? void 0 : _66.events) === null || _67 === void 0 ? void 0 : _67.productRemoved;
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 = (_71 = (_70 = (_69 = (_68 = this.options) === null || _68 === void 0 ? void 0 : _68.formatters) === null || _69 === void 0 ? void 0 : _69.objects) === null || _70 === void 0 ? void 0 : _70.lineItem) === null || _71 === void 0 ? void 0 : _71.call(_70, {
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 = (_75 = (_74 = (_73 = (_72 = this.options) === null || _72 === void 0 ? void 0 : _72.formatters) === null || _73 === void 0 ? void 0 : _73.objects) === null || _74 === void 0 ? void 0 : _74.cart) === null || _75 === void 0 ? void 0 : _75.call(_74, {
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: ((_76 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _76 !== void 0 ? _76 : 0) * ((_77 = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _77 !== void 0 ? _77 : 1), value: ((_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) });
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 _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92;
519
- const formatter = (_82 = (_81 = (_80 = this.options) === null || _80 === void 0 ? void 0 : _80.formatters) === null || _81 === void 0 ? void 0 : _81.events) === null || _82 === void 0 ? void 0 : _82.productViewed;
520
- const product = (_86 = (_85 = (_84 = (_83 = this.options) === null || _83 === void 0 ? void 0 : _83.formatters) === null || _84 === void 0 ? void 0 : _84.objects) === null || _85 === void 0 ? void 0 : _85.product) === null || _86 === void 0 ? void 0 : _86.call(_85, props === null || props === void 0 ? void 0 : props.product);
521
- const cart = (_90 = (_89 = (_88 = (_87 = this.options) === null || _87 === void 0 ? void 0 : _87.formatters) === null || _88 === void 0 ? void 0 : _88.objects) === null || _89 === void 0 ? void 0 : _89.cart) === null || _90 === void 0 ? void 0 : _90.call(_89, {
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 = ((_91 = props === null || props === void 0 ? void 0 : props.product) === null || _91 === void 0 ? void 0 : _91.quantity) || 1;
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 * (((_92 = props === null || props === void 0 ? void 0 : props.product) === null || _92 === void 0 ? void 0 : _92.quantity) || 1) });
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 _93, _94, _95, _96;
534
- const formatter = (_95 = (_94 = (_93 = this.options) === null || _93 === void 0 ? void 0 : _93.formatters) === null || _94 === void 0 ? void 0 : _94.events) === null || _95 === void 0 ? void 0 : _95.productsSearched;
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: (_96 = props === null || props === void 0 ? void 0 : props.productId) === null || _96 === void 0 ? void 0 : _96.toString(),
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 _97, _98, _99;
550
- const formatter = (_99 = (_98 = (_97 = this.options) === null || _97 === void 0 ? void 0 : _97.formatters) === null || _98 === void 0 ? void 0 : _98.events) === null || _99 === void 0 ? void 0 : _99.signedIn;
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 _100, _101, _102;
563
- const formatter = (_102 = (_101 = (_100 = this.options) === null || _100 === void 0 ? void 0 : _100.formatters) === null || _101 === void 0 ? void 0 : _101.events) === null || _102 === void 0 ? void 0 : _102.signedOut;
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 _103, _104, _105;
575
- const formatter = (_105 = (_104 = (_103 = this.options) === null || _103 === void 0 ? void 0 : _103.formatters) === null || _104 === void 0 ? void 0 : _104.events) === null || _105 === void 0 ? void 0 : _105.signedUp;
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 _106, _107, _108;
588
- const formatter = (_108 = (_107 = (_106 = this.options) === null || _106 === void 0 ? void 0 : _106.formatters) === null || _107 === void 0 ? void 0 : _107.events) === null || _108 === void 0 ? void 0 : _108.loginStarted;
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 _109, _110, _111, _112;
600
- const formatter = (_111 = (_110 = (_109 = this.options) === null || _109 === void 0 ? void 0 : _109.formatters) === null || _110 === void 0 ? void 0 : _110.events) === null || _111 === void 0 ? void 0 : _111.subscriptionCancelled;
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: (_112 = props === null || props === void 0 ? void 0 : props.products) === null || _112 === void 0 ? void 0 : _112.map((p, i) => {
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 _113, _114, _115;
625
- const formatter = (_115 = (_114 = (_113 = this.options) === null || _113 === void 0 ? void 0 : _113.formatters) === null || _114 === void 0 ? void 0 : _114.events) === null || _115 === void 0 ? void 0 : _115.navigationClicked;
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 _116, _117, _118, _119;
641
- const formatter = (_118 = (_117 = (_116 = this.options) === null || _116 === void 0 ? void 0 : _116.formatters) === null || _117 === void 0 ? void 0 : _117.events) === null || _118 === void 0 ? void 0 : _118.paymentInfoEntered;
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: (_119 = props === null || props === void 0 ? void 0 : props.products) === null || _119 === void 0 ? void 0 : _119.map((p, i) => {
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chordcommerce/analytics",
3
3
  "description": "Chord Commerce event tracking",
4
- "version": "1.18.1",
4
+ "version": "1.18.2",
5
5
  "author": "Chord Commerce <help@chord.co> (https://www.chord.co)",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",