@chordcommerce/analytics 1.24.4 → 1.24.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/client/cdp.js +2 -2
- package/dist/cjs/client/consent/index.js +2 -2
- package/dist/cjs/client/consent/onetrust-api.d.ts +1 -1
- package/dist/cjs/client/consent/onetrust.d.ts +2 -2
- package/dist/cjs/client/consent/segment.js +19 -6
- package/dist/cjs/client/index.js +16 -8
- package/dist/cjs/client/utils.js +1 -2
- package/dist/cjs/utils.d.ts +1 -1
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/validators/custom.d.ts +4 -38
- package/dist/cjs/validators/custom.js +5 -5
- package/dist/cjs/validators/objects.d.ts +73 -584
- package/dist/cjs/validators/objects.js +110 -111
- package/dist/cjs/validators/tracking-plan-map.d.ts +172 -5126
- package/dist/cjs/validators/tracking-plan.d.ts +272 -7008
- package/dist/cjs/validators/tracking-plan.js +1722 -1649
- package/dist/client/consent/onetrust-api.d.ts +1 -1
- package/dist/client/consent/onetrust.d.ts +2 -2
- package/dist/client/consent/segment.js +1 -1
- package/dist/client/index.js +84 -84
- package/dist/tsconfig-build-cjs.tsbuildinfo +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/validators/custom.d.ts +4 -38
- package/dist/validators/custom.js +1 -1
- package/dist/validators/objects.d.ts +73 -584
- package/dist/validators/objects.js +27 -28
- package/dist/validators/tracking-plan-map.d.ts +172 -5126
- package/dist/validators/tracking-plan.d.ts +272 -7008
- package/dist/validators/tracking-plan.js +219 -146
- package/package.json +4 -4
|
@@ -109,5 +109,5 @@ export declare const getNormalizedCategories: () => Record<string, boolean>;
|
|
|
109
109
|
* @param model - OneTrust consent model name
|
|
110
110
|
* @returns 'opt-in' or 'opt-out'
|
|
111
111
|
*/
|
|
112
|
-
export declare const coerceConsentModel: (model: OtConsentModel | string) =>
|
|
112
|
+
export declare const coerceConsentModel: (model: OtConsentModel | string) => "opt-in" | "opt-out";
|
|
113
113
|
export {};
|
|
@@ -5,6 +5,6 @@ export declare const onetrustConsentAdapter: (options: ChordAnalyticsOptions) =>
|
|
|
5
5
|
userCanBeTracked: () => boolean;
|
|
6
6
|
getCategories: () => Record<string, boolean>;
|
|
7
7
|
isConsentReady: () => boolean;
|
|
8
|
-
getConsentModel: () =>
|
|
9
|
-
getApi: () => import("./onetrust-api.js").OneTrustGlobal;
|
|
8
|
+
getConsentModel: () => "opt-in" | "opt-out";
|
|
9
|
+
getApi: () => import("./onetrust-api.js").OneTrustGlobal | undefined;
|
|
10
10
|
};
|
|
@@ -11,7 +11,7 @@ const getApi = () => window.segmentConsent;
|
|
|
11
11
|
/**
|
|
12
12
|
* Waits for the Segment consent API to be populated with retry logic.
|
|
13
13
|
*/
|
|
14
|
-
const waitForApi = (
|
|
14
|
+
const waitForApi = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (maxRetries = 10, baseDelay = 100) {
|
|
15
15
|
let attempt = 0;
|
|
16
16
|
const checkAndWait = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const api = getApi();
|
package/dist/client/index.js
CHANGED
|
@@ -602,7 +602,7 @@ export class ChordAnalytics {
|
|
|
602
602
|
* Send a `page` event to the CDP.
|
|
603
603
|
* If consent is not ready, the event is queued until consent is available.
|
|
604
604
|
*/
|
|
605
|
-
this.page = (
|
|
605
|
+
this.page = (options_1, ...args_1) => __awaiter(this, [options_1, ...args_1], void 0, function* (options, props = {}) {
|
|
606
606
|
const gate = this.waitForReadyState();
|
|
607
607
|
if (gate)
|
|
608
608
|
yield gate;
|
|
@@ -616,7 +616,7 @@ export class ChordAnalytics {
|
|
|
616
616
|
/**
|
|
617
617
|
* Internal method to actually send a page event to CDP.
|
|
618
618
|
*/
|
|
619
|
-
this.sendPageEvent = (
|
|
619
|
+
this.sendPageEvent = (options_1, ...args_1) => __awaiter(this, [options_1, ...args_1], void 0, function* (options, props = {}) {
|
|
620
620
|
// Configure CDP with fresh consent before sending
|
|
621
621
|
this.configureConsentOnCdp();
|
|
622
622
|
yield new Promise((resolve) => {
|
|
@@ -659,7 +659,7 @@ export class ChordAnalytics {
|
|
|
659
659
|
return this.resetCompletePromise;
|
|
660
660
|
};
|
|
661
661
|
this.performReset = () => __awaiter(this, void 0, void 0, function* () {
|
|
662
|
-
var
|
|
662
|
+
var _a;
|
|
663
663
|
try {
|
|
664
664
|
// The new identity has no consent event of its own yet, so drop the
|
|
665
665
|
// stored signature and let the next init emit a fresh baseline.
|
|
@@ -678,12 +678,12 @@ export class ChordAnalytics {
|
|
|
678
678
|
// eslint-disable-next-line
|
|
679
679
|
yield new Promise((resolve) => setTimeout(resolve, 10));
|
|
680
680
|
try {
|
|
681
|
-
const userState = ((
|
|
681
|
+
const userState = ((_a = a === null || a === void 0 ? void 0 : a.user) === null || _a === void 0 ? void 0 : _a.call(a)) || {};
|
|
682
682
|
if (userState.userId === null || userState.userId === undefined) {
|
|
683
683
|
break;
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
|
-
catch (
|
|
686
|
+
catch (_b) {
|
|
687
687
|
break;
|
|
688
688
|
}
|
|
689
689
|
attempts++;
|
|
@@ -786,8 +786,8 @@ export class ChordAnalytics {
|
|
|
786
786
|
};
|
|
787
787
|
// TODO: Add support for props.products
|
|
788
788
|
this.trackCartViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
789
|
-
var
|
|
790
|
-
const cart = (
|
|
789
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
790
|
+
const cart = (_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.cart) === null || _d === void 0 ? void 0 : _d.call(_c, {
|
|
791
791
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
792
792
|
});
|
|
793
793
|
const payload = {
|
|
@@ -796,17 +796,17 @@ export class ChordAnalytics {
|
|
|
796
796
|
products: cart === null || cart === void 0 ? void 0 : cart.products,
|
|
797
797
|
value: cart === null || cart === void 0 ? void 0 : cart.value,
|
|
798
798
|
};
|
|
799
|
-
if ((
|
|
800
|
-
const formattedPayload = (
|
|
799
|
+
if ((_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.formatters) === null || _f === void 0 ? void 0 : _f.events) === null || _g === void 0 ? void 0 : _g.cartViewed) {
|
|
800
|
+
const formattedPayload = (_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(props, payload);
|
|
801
801
|
return this.track('Cart Viewed', formattedPayload, options);
|
|
802
802
|
}
|
|
803
803
|
return this.track('Cart Viewed', payload, options);
|
|
804
804
|
});
|
|
805
805
|
// TODO: Add support for props.products
|
|
806
806
|
this.trackCheckoutStarted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
807
|
-
var
|
|
808
|
-
const formatter = (
|
|
809
|
-
const checkout = (
|
|
807
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
808
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.checkoutStarted;
|
|
809
|
+
const checkout = (_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.checkout) === null || _g === void 0 ? void 0 : _g.call(_f, {
|
|
810
810
|
checkout: props === null || props === void 0 ? void 0 : props.checkout,
|
|
811
811
|
});
|
|
812
812
|
const payload = checkout;
|
|
@@ -817,8 +817,8 @@ export class ChordAnalytics {
|
|
|
817
817
|
return this.track('Checkout Started', payload, options);
|
|
818
818
|
});
|
|
819
819
|
this.trackCheckoutStepCompleted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
820
|
-
var
|
|
821
|
-
const formatter = (
|
|
820
|
+
var _a, _b, _c;
|
|
821
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.checkoutStepCompleted;
|
|
822
822
|
const payload = {
|
|
823
823
|
checkout_id: props === null || props === void 0 ? void 0 : props.checkoutId,
|
|
824
824
|
payment_method: props === null || props === void 0 ? void 0 : props.paymentMethod,
|
|
@@ -832,8 +832,8 @@ export class ChordAnalytics {
|
|
|
832
832
|
return this.track('Checkout Step Completed', payload, options);
|
|
833
833
|
});
|
|
834
834
|
this.trackCheckoutStepViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
835
|
-
var
|
|
836
|
-
const formatter = (
|
|
835
|
+
var _a, _b, _c;
|
|
836
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.checkoutStepViewed;
|
|
837
837
|
const payload = {
|
|
838
838
|
checkout_id: props === null || props === void 0 ? void 0 : props.checkoutId,
|
|
839
839
|
payment_method: props === null || props === void 0 ? void 0 : props.paymentMethod,
|
|
@@ -847,8 +847,8 @@ export class ChordAnalytics {
|
|
|
847
847
|
return this.track('Checkout Step Viewed', payload, options);
|
|
848
848
|
});
|
|
849
849
|
this.trackCouponApplied = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
850
|
-
var
|
|
851
|
-
const formatter = (
|
|
850
|
+
var _a, _b, _c;
|
|
851
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.couponApplied;
|
|
852
852
|
const payload = {
|
|
853
853
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
854
854
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -863,8 +863,8 @@ export class ChordAnalytics {
|
|
|
863
863
|
return this.track('Coupon Applied', payload, options);
|
|
864
864
|
});
|
|
865
865
|
this.trackCouponDenied = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
866
|
-
var
|
|
867
|
-
const formatter = (
|
|
866
|
+
var _a, _b, _c;
|
|
867
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.couponDenied;
|
|
868
868
|
const payload = {
|
|
869
869
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
870
870
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -879,8 +879,8 @@ export class ChordAnalytics {
|
|
|
879
879
|
return this.track('Coupon Denied', payload, options);
|
|
880
880
|
});
|
|
881
881
|
this.trackCouponEntered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
882
|
-
var
|
|
883
|
-
const formatter = (
|
|
882
|
+
var _a, _b, _c;
|
|
883
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.couponEntered;
|
|
884
884
|
const payload = {
|
|
885
885
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
886
886
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -894,8 +894,8 @@ export class ChordAnalytics {
|
|
|
894
894
|
return this.track('Coupon Entered', payload, options);
|
|
895
895
|
});
|
|
896
896
|
this.trackCouponRemoved = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
897
|
-
var
|
|
898
|
-
const formatter = (
|
|
897
|
+
var _a, _b, _c;
|
|
898
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.couponRemoved;
|
|
899
899
|
const payload = {
|
|
900
900
|
cart_id: props === null || props === void 0 ? void 0 : props.cartId,
|
|
901
901
|
coupon_id: props === null || props === void 0 ? void 0 : props.couponId,
|
|
@@ -910,8 +910,8 @@ export class ChordAnalytics {
|
|
|
910
910
|
return this.track('Coupon Removed', payload, options);
|
|
911
911
|
});
|
|
912
912
|
this.trackEmailCaptured = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
913
|
-
var
|
|
914
|
-
const formatter = (
|
|
913
|
+
var _a, _b, _c;
|
|
914
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.emailCaptured;
|
|
915
915
|
const payload = {
|
|
916
916
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
917
917
|
placement_component: props === null || props === void 0 ? void 0 : props.placementComponent,
|
|
@@ -924,13 +924,13 @@ export class ChordAnalytics {
|
|
|
924
924
|
return this.track('Email Captured', payload, options);
|
|
925
925
|
});
|
|
926
926
|
this.trackProductAdded = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
927
|
-
var
|
|
928
|
-
const formatter = (
|
|
929
|
-
const product = (
|
|
930
|
-
const cart = (
|
|
927
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
928
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productAdded;
|
|
929
|
+
const product = (_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.product) === null || _g === void 0 ? void 0 : _g.call(_f, props === null || props === void 0 ? void 0 : props.product);
|
|
930
|
+
const cart = (_l = (_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.objects) === null || _k === void 0 ? void 0 : _k.cart) === null || _l === void 0 ? void 0 : _l.call(_k, {
|
|
931
931
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
932
932
|
});
|
|
933
|
-
const quantity = ((
|
|
933
|
+
const quantity = ((_m = props === null || props === void 0 ? void 0 : props.product) === null || _m === void 0 ? void 0 : _m.quantity) || 1;
|
|
934
934
|
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) });
|
|
935
935
|
if (typeof formatter === 'function') {
|
|
936
936
|
const formattedPayload = formatter(props, payload);
|
|
@@ -939,14 +939,14 @@ export class ChordAnalytics {
|
|
|
939
939
|
return this.track('Product Added', payload, options);
|
|
940
940
|
});
|
|
941
941
|
this.trackProductClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
942
|
-
var
|
|
943
|
-
const formatter = (
|
|
944
|
-
const product = (
|
|
945
|
-
const cart = (
|
|
942
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
943
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productClicked;
|
|
944
|
+
const product = (_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.product) === null || _g === void 0 ? void 0 : _g.call(_f, props === null || props === void 0 ? void 0 : props.product);
|
|
945
|
+
const cart = (_l = (_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.objects) === null || _k === void 0 ? void 0 : _k.cart) === null || _l === void 0 ? void 0 : _l.call(_k, {
|
|
946
946
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
947
947
|
});
|
|
948
|
-
const quantity = ((
|
|
949
|
-
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, item_list_id: (
|
|
948
|
+
const quantity = ((_m = props === null || props === void 0 ? void 0 : props.product) === null || _m === void 0 ? void 0 : _m.quantity) || 1;
|
|
949
|
+
const payload = Object.assign(Object.assign({}, product), { cart_id: cart.cart_id, currency: cart.currency, item_list_id: (_o = props === null || props === void 0 ? void 0 : props.listId) === null || _o === void 0 ? void 0 : _o.toString(), item_list_name: props === null || props === void 0 ? void 0 : props.listName, products: [Object.assign(Object.assign({}, product), { quantity })] });
|
|
950
950
|
if (typeof formatter === 'function') {
|
|
951
951
|
const formattedPayload = formatter(props, payload);
|
|
952
952
|
return this.track('Product Clicked', formattedPayload, options);
|
|
@@ -954,13 +954,13 @@ export class ChordAnalytics {
|
|
|
954
954
|
return this.track('Product Clicked', payload, options);
|
|
955
955
|
});
|
|
956
956
|
this.trackVariantClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
957
|
-
var
|
|
958
|
-
const formatter = (
|
|
959
|
-
const product = (
|
|
960
|
-
const cart = (
|
|
957
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
958
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.variantClicked;
|
|
959
|
+
const product = (_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.product) === null || _g === void 0 ? void 0 : _g.call(_f, props === null || props === void 0 ? void 0 : props.product);
|
|
960
|
+
const cart = (_l = (_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.objects) === null || _k === void 0 ? void 0 : _k.cart) === null || _l === void 0 ? void 0 : _l.call(_k, {
|
|
961
961
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
962
962
|
});
|
|
963
|
-
const quantity = ((
|
|
963
|
+
const quantity = ((_m = props === null || props === void 0 ? void 0 : props.product) === null || _m === void 0 ? void 0 : _m.quantity) || 1;
|
|
964
964
|
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 });
|
|
965
965
|
if (typeof formatter === 'function') {
|
|
966
966
|
const formattedPayload = formatter(props, payload);
|
|
@@ -969,13 +969,13 @@ export class ChordAnalytics {
|
|
|
969
969
|
return this.track('Variant Clicked', payload, options);
|
|
970
970
|
});
|
|
971
971
|
this.trackProductListFiltered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
972
|
-
var
|
|
973
|
-
const formatter = (
|
|
972
|
+
var _a, _b, _c, _d, _e;
|
|
973
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productListFiltered;
|
|
974
974
|
const payload = {
|
|
975
975
|
category: props === null || props === void 0 ? void 0 : props.category,
|
|
976
976
|
filters: props === null || props === void 0 ? void 0 : props.filters,
|
|
977
|
-
list_id: (
|
|
978
|
-
item_list_id: (
|
|
977
|
+
list_id: (_d = props === null || props === void 0 ? void 0 : props.listId) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
978
|
+
item_list_id: (_e = props === null || props === void 0 ? void 0 : props.listId) === null || _e === void 0 ? void 0 : _e.toString(),
|
|
979
979
|
item_list_name: props === null || props === void 0 ? void 0 : props.listName,
|
|
980
980
|
sorts: props === null || props === void 0 ? void 0 : props.sorts,
|
|
981
981
|
};
|
|
@@ -986,14 +986,14 @@ export class ChordAnalytics {
|
|
|
986
986
|
return this.track('Product List Filtered', payload, options);
|
|
987
987
|
});
|
|
988
988
|
this.trackProductListViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
989
|
-
var
|
|
990
|
-
const formatter = (
|
|
989
|
+
var _a, _b, _c, _d, _e, _f;
|
|
990
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productListViewed;
|
|
991
991
|
const payload = {
|
|
992
992
|
category: props === null || props === void 0 ? void 0 : props.category,
|
|
993
|
-
list_id: (
|
|
994
|
-
item_list_id: (
|
|
993
|
+
list_id: (_d = props === null || props === void 0 ? void 0 : props.listId) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
994
|
+
item_list_id: (_e = props === null || props === void 0 ? void 0 : props.listId) === null || _e === void 0 ? void 0 : _e.toString(),
|
|
995
995
|
item_list_name: props === null || props === void 0 ? void 0 : props.listName,
|
|
996
|
-
products: (
|
|
996
|
+
products: (_f = props === null || props === void 0 ? void 0 : props.products) === null || _f === void 0 ? void 0 : _f.map((p, i) => {
|
|
997
997
|
var _a, _b, _c, _d;
|
|
998
998
|
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 }));
|
|
999
999
|
}),
|
|
@@ -1006,8 +1006,8 @@ export class ChordAnalytics {
|
|
|
1006
1006
|
return this.track('Product List Viewed', payload, options);
|
|
1007
1007
|
});
|
|
1008
1008
|
this.trackProductRemoved = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1009
|
-
var
|
|
1010
|
-
const formatter = (
|
|
1009
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
1010
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productRemoved;
|
|
1011
1011
|
/*
|
|
1012
1012
|
const product = this.options?.formatters?.objects?.product?.({
|
|
1013
1013
|
position: props?.position,
|
|
@@ -1016,13 +1016,13 @@ export class ChordAnalytics {
|
|
|
1016
1016
|
variantId: props?.variantId,
|
|
1017
1017
|
})
|
|
1018
1018
|
*/
|
|
1019
|
-
const lineItem = (
|
|
1019
|
+
const lineItem = (_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.lineItem) === null || _g === void 0 ? void 0 : _g.call(_f, {
|
|
1020
1020
|
lineItem: props === null || props === void 0 ? void 0 : props.lineItem,
|
|
1021
1021
|
});
|
|
1022
|
-
const cart = (
|
|
1022
|
+
const cart = (_l = (_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.objects) === null || _k === void 0 ? void 0 : _k.cart) === null || _l === void 0 ? void 0 : _l.call(_k, {
|
|
1023
1023
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
1024
1024
|
});
|
|
1025
|
-
const payload = Object.assign(Object.assign({}, lineItem), { cart_id: cart.cart_id, currency: cart.currency, products: [lineItem], total: ((
|
|
1025
|
+
const payload = Object.assign(Object.assign({}, lineItem), { cart_id: cart.cart_id, currency: cart.currency, products: [lineItem], total: ((_m = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _m !== void 0 ? _m : 0) * ((_o = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _o !== void 0 ? _o : 1), value: ((_p = lineItem === null || lineItem === void 0 ? void 0 : lineItem.price) !== null && _p !== void 0 ? _p : 0) * ((_q = lineItem === null || lineItem === void 0 ? void 0 : lineItem.quantity) !== null && _q !== void 0 ? _q : 1) });
|
|
1026
1026
|
if (typeof formatter === 'function') {
|
|
1027
1027
|
const formattedPayload = formatter(props, payload);
|
|
1028
1028
|
return this.track('Product Removed', formattedPayload, options);
|
|
@@ -1030,14 +1030,14 @@ export class ChordAnalytics {
|
|
|
1030
1030
|
return this.track('Product Removed', payload, options);
|
|
1031
1031
|
});
|
|
1032
1032
|
this.trackProductViewed = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1033
|
-
var
|
|
1034
|
-
const formatter = (
|
|
1035
|
-
const product = (
|
|
1036
|
-
const cart = (
|
|
1033
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
1034
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productViewed;
|
|
1035
|
+
const product = (_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.product) === null || _g === void 0 ? void 0 : _g.call(_f, props === null || props === void 0 ? void 0 : props.product);
|
|
1036
|
+
const cart = (_l = (_k = (_j = (_h = this.options) === null || _h === void 0 ? void 0 : _h.formatters) === null || _j === void 0 ? void 0 : _j.objects) === null || _k === void 0 ? void 0 : _k.cart) === null || _l === void 0 ? void 0 : _l.call(_k, {
|
|
1037
1037
|
cart: props === null || props === void 0 ? void 0 : props.cart,
|
|
1038
1038
|
});
|
|
1039
|
-
const quantity = ((
|
|
1040
|
-
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 * (((
|
|
1039
|
+
const quantity = ((_m = props === null || props === void 0 ? void 0 : props.product) === null || _m === void 0 ? void 0 : _m.quantity) || 1;
|
|
1040
|
+
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 * (((_o = props === null || props === void 0 ? void 0 : props.product) === null || _o === void 0 ? void 0 : _o.quantity) || 1) });
|
|
1041
1041
|
if (typeof formatter === 'function') {
|
|
1042
1042
|
const formattedPayload = formatter(props, payload);
|
|
1043
1043
|
return this.track('Product Viewed', formattedPayload, options);
|
|
@@ -1045,12 +1045,12 @@ export class ChordAnalytics {
|
|
|
1045
1045
|
return this.track('Product Viewed', payload, options);
|
|
1046
1046
|
});
|
|
1047
1047
|
this.trackProductsSearched = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1048
|
-
var
|
|
1049
|
-
const formatter = (
|
|
1048
|
+
var _a, _b, _c, _d;
|
|
1049
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.productsSearched;
|
|
1050
1050
|
const payload = {
|
|
1051
1051
|
currency: props === null || props === void 0 ? void 0 : props.currency,
|
|
1052
1052
|
price: typeof (props === null || props === void 0 ? void 0 : props.price) !== 'undefined' ? Number(props === null || props === void 0 ? void 0 : props.price) : undefined,
|
|
1053
|
-
product_id: (
|
|
1053
|
+
product_id: (_d = props === null || props === void 0 ? void 0 : props.productId) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
1054
1054
|
quantity: props === null || props === void 0 ? void 0 : props.quantity,
|
|
1055
1055
|
query: props === null || props === void 0 ? void 0 : props.query,
|
|
1056
1056
|
};
|
|
@@ -1061,8 +1061,8 @@ export class ChordAnalytics {
|
|
|
1061
1061
|
return this.track('Products Searched', payload, options);
|
|
1062
1062
|
});
|
|
1063
1063
|
this.trackSignedIn = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1064
|
-
var
|
|
1065
|
-
const formatter = (
|
|
1064
|
+
var _a, _b, _c;
|
|
1065
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.signedIn;
|
|
1066
1066
|
const payload = {
|
|
1067
1067
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
1068
1068
|
method: props === null || props === void 0 ? void 0 : props.method,
|
|
@@ -1074,8 +1074,8 @@ export class ChordAnalytics {
|
|
|
1074
1074
|
return this.track('Signed In', payload, options);
|
|
1075
1075
|
});
|
|
1076
1076
|
this.trackSignedOut = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1077
|
-
var
|
|
1078
|
-
const formatter = (
|
|
1077
|
+
var _a, _b, _c;
|
|
1078
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.signedOut;
|
|
1079
1079
|
const payload = {
|
|
1080
1080
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
1081
1081
|
};
|
|
@@ -1086,8 +1086,8 @@ export class ChordAnalytics {
|
|
|
1086
1086
|
return this.track('Signed Out', payload, options);
|
|
1087
1087
|
});
|
|
1088
1088
|
this.trackSignedUp = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1089
|
-
var
|
|
1090
|
-
const formatter = (
|
|
1089
|
+
var _a, _b, _c;
|
|
1090
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.signedUp;
|
|
1091
1091
|
const payload = {
|
|
1092
1092
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
1093
1093
|
method: props === null || props === void 0 ? void 0 : props.method,
|
|
@@ -1099,8 +1099,8 @@ export class ChordAnalytics {
|
|
|
1099
1099
|
return this.track('Signed Up', payload, options);
|
|
1100
1100
|
});
|
|
1101
1101
|
this.trackLoginStarted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1102
|
-
var
|
|
1103
|
-
const formatter = (
|
|
1102
|
+
var _a, _b, _c;
|
|
1103
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.loginStarted;
|
|
1104
1104
|
const payload = {
|
|
1105
1105
|
email: props === null || props === void 0 ? void 0 : props.email,
|
|
1106
1106
|
};
|
|
@@ -1111,8 +1111,8 @@ export class ChordAnalytics {
|
|
|
1111
1111
|
return this.track('Login Started', payload, options);
|
|
1112
1112
|
});
|
|
1113
1113
|
this.trackSubscriptionCancelled = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1114
|
-
var
|
|
1115
|
-
const formatter = (
|
|
1114
|
+
var _a, _b, _c, _d;
|
|
1115
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.subscriptionCancelled;
|
|
1116
1116
|
const payload = {
|
|
1117
1117
|
actionable_date: props === null || props === void 0 ? void 0 : props.actionableDate,
|
|
1118
1118
|
address: props === null || props === void 0 ? void 0 : props.address,
|
|
@@ -1121,7 +1121,7 @@ export class ChordAnalytics {
|
|
|
1121
1121
|
end_date: props === null || props === void 0 ? void 0 : props.endDate,
|
|
1122
1122
|
interval_length: props === null || props === void 0 ? void 0 : props.intervalLength,
|
|
1123
1123
|
interval_units: props === null || props === void 0 ? void 0 : props.intervalUnits,
|
|
1124
|
-
products: (
|
|
1124
|
+
products: (_d = props === null || props === void 0 ? void 0 : props.products) === null || _d === void 0 ? void 0 : _d.map((p, i) => {
|
|
1125
1125
|
var _a, _b, _c, _d;
|
|
1126
1126
|
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 }));
|
|
1127
1127
|
}),
|
|
@@ -1136,8 +1136,8 @@ export class ChordAnalytics {
|
|
|
1136
1136
|
return this.track('Subscription Cancelled', payload, options);
|
|
1137
1137
|
});
|
|
1138
1138
|
this.trackNavigationClicked = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1139
|
-
var
|
|
1140
|
-
const formatter = (
|
|
1139
|
+
var _a, _b, _c;
|
|
1140
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.navigationClicked;
|
|
1141
1141
|
const payload = {
|
|
1142
1142
|
category: props === null || props === void 0 ? void 0 : props.category,
|
|
1143
1143
|
label: props === null || props === void 0 ? void 0 : props.label,
|
|
@@ -1152,15 +1152,15 @@ export class ChordAnalytics {
|
|
|
1152
1152
|
return this.track('Navigation Clicked', payload, options);
|
|
1153
1153
|
});
|
|
1154
1154
|
this.trackPaymentInfoEntered = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1155
|
-
var
|
|
1156
|
-
const formatter = (
|
|
1155
|
+
var _a, _b, _c, _d;
|
|
1156
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.paymentInfoEntered;
|
|
1157
1157
|
const payload = {
|
|
1158
1158
|
checkout_id: props === null || props === void 0 ? void 0 : props.checkoutId,
|
|
1159
1159
|
coupon: props === null || props === void 0 ? void 0 : props.coupon,
|
|
1160
1160
|
currency: props === null || props === void 0 ? void 0 : props.currency,
|
|
1161
1161
|
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
1162
1162
|
payment_method: props === null || props === void 0 ? void 0 : props.paymentMethod,
|
|
1163
|
-
products: (
|
|
1163
|
+
products: (_d = props === null || props === void 0 ? void 0 : props.products) === null || _d === void 0 ? void 0 : _d.map((p, i) => {
|
|
1164
1164
|
var _a, _b, _c, _d;
|
|
1165
1165
|
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 }));
|
|
1166
1166
|
}),
|
|
@@ -1175,8 +1175,8 @@ export class ChordAnalytics {
|
|
|
1175
1175
|
return this.track('Payment Info Entered', payload, options);
|
|
1176
1176
|
});
|
|
1177
1177
|
this.trackOrderCompleted = (props, options) => __awaiter(this, void 0, void 0, function* () {
|
|
1178
|
-
var
|
|
1179
|
-
const formatter = (
|
|
1178
|
+
var _a, _b, _c, _d;
|
|
1179
|
+
const formatter = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.formatters) === null || _b === void 0 ? void 0 : _b.events) === null || _c === void 0 ? void 0 : _c.orderCompleted;
|
|
1180
1180
|
const payload = {
|
|
1181
1181
|
affiliation: props === null || props === void 0 ? void 0 : props.affiliation,
|
|
1182
1182
|
campaign_id: props === null || props === void 0 ? void 0 : props.campaignId,
|
|
@@ -1196,7 +1196,7 @@ export class ChordAnalytics {
|
|
|
1196
1196
|
order_date: props === null || props === void 0 ? void 0 : props.orderDate,
|
|
1197
1197
|
order_id: props === null || props === void 0 ? void 0 : props.orderId,
|
|
1198
1198
|
phone: props === null || props === void 0 ? void 0 : props.phone,
|
|
1199
|
-
products: (
|
|
1199
|
+
products: (_d = props === null || props === void 0 ? void 0 : props.products) === null || _d === void 0 ? void 0 : _d.map((p, i) => {
|
|
1200
1200
|
var _a;
|
|
1201
1201
|
return ({
|
|
1202
1202
|
affiliation: p === null || p === void 0 ? void 0 : p.affiliation,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts","../src/setupTests.ts","../src/utils.ts","../src/client/cdp.ts","../src/client/index.ts","../src/client/utils.ts","../src/client/consent/cookiebot.ts","../src/client/consent/index.ts","../src/client/consent/ketch.ts","../src/client/consent/onetrust-api.ts","../src/client/consent/onetrust.ts","../src/client/consent/persistence.ts","../src/client/consent/segment.ts","../src/client/consent/shopify.ts","../src/types/client.ts","../src/types/consent.ts","../src/types/formatters.ts","../src/types/index.ts","../src/types/input.ts","../src/types/objects.ts","../src/types/typewriter.ts","../src/validators/custom.ts","../src/validators/index.ts","../src/validators/objects.ts","../src/validators/tracking-plan-map.ts","../src/validators/tracking-plan.ts"],"version":"5.9.3"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -27,4 +27,4 @@ export declare const isPromise: (value: unknown) => value is Promise<unknown>;
|
|
|
27
27
|
* The timer is cleared either way, so a promise that settles quickly does not
|
|
28
28
|
* leave a pending timeout behind.
|
|
29
29
|
*/
|
|
30
|
-
export declare const withTimeout: <T>(promise: Promise<T>, ms: number) => Promise<typeof TIMED_OUT
|
|
30
|
+
export declare const withTimeout: <T>(promise: Promise<T>, ms: number) => Promise<T | typeof TIMED_OUT>;
|
|
@@ -1,43 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const productInProductsSchema: z.
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const productInProductsSchema: z.ZodObject<{
|
|
3
3
|
product_id: z.ZodString;
|
|
4
4
|
sku: z.ZodString;
|
|
5
5
|
products: z.ZodArray<z.ZodObject<{
|
|
6
6
|
product_id: z.ZodString;
|
|
7
7
|
sku: z.ZodString;
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
sku?: string;
|
|
11
|
-
}, {
|
|
12
|
-
product_id?: string;
|
|
13
|
-
sku?: string;
|
|
14
|
-
}>, "many">;
|
|
15
|
-
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
product_id?: string;
|
|
17
|
-
sku?: string;
|
|
18
|
-
products?: {
|
|
19
|
-
product_id?: string;
|
|
20
|
-
sku?: string;
|
|
21
|
-
}[];
|
|
22
|
-
}, {
|
|
23
|
-
product_id?: string;
|
|
24
|
-
sku?: string;
|
|
25
|
-
products?: {
|
|
26
|
-
product_id?: string;
|
|
27
|
-
sku?: string;
|
|
28
|
-
}[];
|
|
29
|
-
}>, {
|
|
30
|
-
product_id?: string;
|
|
31
|
-
sku?: string;
|
|
32
|
-
products?: {
|
|
33
|
-
product_id?: string;
|
|
34
|
-
sku?: string;
|
|
35
|
-
}[];
|
|
36
|
-
}, {
|
|
37
|
-
product_id?: string;
|
|
38
|
-
sku?: string;
|
|
39
|
-
products?: {
|
|
40
|
-
product_id?: string;
|
|
41
|
-
sku?: string;
|
|
42
|
-
}[];
|
|
43
|
-
}>;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
}, z.core.$strip>;
|