@zonos/elements 1.3.247 → 1.3.248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cart-97a2d20a.js → cart-28310848.js} +2 -0
- package/dist/cjs/index.cjs.js +14 -7
- package/dist/cjs/{invoice-05a10ee1.js → invoice-2e8e5879.js} +1 -1
- package/dist/cjs/{isCollectMobileTablet-edd4804c.js → isCollectMobileTablet-bd0f4556.js} +1 -1
- package/dist/cjs/{paypal-0b4b352b.js → paypal-3019ae94.js} +21 -18
- package/dist/cjs/{placeTestOrder-07b46688.js → placeTestOrder-b0369cfd.js} +1 -1
- package/dist/cjs/{renderCheckoutCurrency-dd3b0609.js → renderCheckoutCurrency-9e919b9f.js} +1 -1
- package/dist/cjs/submitGtag-a50ab32e.js +116 -0
- package/dist/cjs/zonos-address-display_9.cjs.entry.js +1 -1
- package/dist/cjs/zonos-address_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-card_5.cjs.entry.js +3 -2
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +109 -17
- package/dist/cjs/zonos-checkout.cjs.entry.js +27 -6
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +1 -1
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +12 -11
- package/dist/cjs/zonos-collect.cjs.entry.js +4 -3
- package/dist/cjs/zonos-controller.cjs.entry.js +5 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +3 -3
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +12 -11
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +88 -9
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-payment/zonos-checkout-payment.js +9 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +24 -4
- package/dist/collection/components/checkout/zonos-checkout/zonos-shipping/zonos-shipping.js +9 -3
- package/dist/collection/components/checkout/zonos-collect/zonos-collect-finish/zonos-collect-finish.js +5 -5
- package/dist/collection/components/checkout/zonos-collect/zonos-collect-payment/zonos-collect-payment.js +1 -1
- package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-finish/zonos-invoice-finish.js +5 -5
- package/dist/collection/components/checkout/zonos-invoice/zonos-invoice-payment/zonos-invoice-payment.js +1 -1
- package/dist/collection/components/main/zonos-controller.js +4 -1
- package/dist/collection/components/store/checkout/paypal.js +19 -1
- package/dist/collection/components/store/checkout/stripe.js +2 -0
- package/dist/collection/components/utils/submitGtag.js +90 -2
- package/dist/collection/scripts/_zonosBase.js +7 -0
- package/dist/collection/types/analyticsRelay.js +6 -0
- package/dist/esm/{cart-99ec4a3d.js → cart-ba8f3890.js} +2 -0
- package/dist/esm/index.js +14 -7
- package/dist/esm/{invoice-44e97c22.js → invoice-055bb6e5.js} +1 -1
- package/dist/esm/{isCollectMobileTablet-566ff0aa.js → isCollectMobileTablet-797cea8b.js} +1 -1
- package/dist/esm/{paypal-56534e48.js → paypal-8d8518c0.js} +23 -19
- package/dist/esm/{placeTestOrder-9e0ab5fd.js → placeTestOrder-0a74923e.js} +1 -1
- package/dist/esm/{renderCheckoutCurrency-1bd40006.js → renderCheckoutCurrency-bd059ecf.js} +1 -1
- package/dist/esm/submitGtag-89d6e9cb.js +113 -0
- package/dist/esm/zonos-address-display_9.entry.js +1 -1
- package/dist/esm/zonos-address_4.entry.js +1 -1
- package/dist/esm/zonos-card_5.entry.js +3 -2
- package/dist/esm/zonos-cart-items_12.entry.js +109 -17
- package/dist/esm/zonos-checkout.entry.js +27 -6
- package/dist/esm/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm/zonos-collect-finish_6.entry.js +12 -11
- package/dist/esm/zonos-collect.entry.js +4 -3
- package/dist/esm/zonos-controller.entry.js +5 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +3 -3
- package/dist/esm/zonos-invoice-finish_5.entry.js +12 -11
- package/dist/esm/zonos-invoice.entry.js +4 -3
- package/dist/esm-es5/{cart-99ec4a3d.js → cart-ba8f3890.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-44e97c22.js → invoice-055bb6e5.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-566ff0aa.js → isCollectMobileTablet-797cea8b.js} +1 -1
- package/dist/esm-es5/paypal-8d8518c0.js +17 -0
- package/dist/esm-es5/{placeTestOrder-9e0ab5fd.js → placeTestOrder-0a74923e.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-1bd40006.js → renderCheckoutCurrency-bd059ecf.js} +1 -1
- package/dist/esm-es5/submitGtag-89d6e9cb.js +1 -0
- package/dist/esm-es5/zonos-address-display_9.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/scripts/analyticsRelayOnInit.js +1 -0
- package/dist/scripts/index.d.ts +11 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.d.ts +4 -0
- package/dist/types/components/store/checkout/stripe.d.ts +6 -0
- package/dist/types/components/utils/submitGtag.d.ts +32 -2
- package/dist/types/scripts/_zonosBase.d.ts +11 -0
- package/dist/types/types/analyticsRelay.d.ts +12 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-002e45f9.system.js +17 -0
- package/dist/zonos-elements/p-0792688d.system.entry.js +1 -0
- package/dist/zonos-elements/p-0b7beb16.system.entry.js +1 -0
- package/dist/zonos-elements/p-0f787f5d.entry.js +1 -0
- package/dist/zonos-elements/{p-2e8f842c.entry.js → p-0ff93ca6.entry.js} +1 -1
- package/dist/zonos-elements/{p-10355cf6.system.entry.js → p-1acf0a71.system.entry.js} +1 -1
- package/dist/zonos-elements/p-291f7ccb.system.entry.js +1 -0
- package/dist/zonos-elements/p-3972663a.system.entry.js +1 -0
- package/dist/zonos-elements/{p-53a9da45.entry.js → p-39fa55c7.entry.js} +1 -1
- package/dist/zonos-elements/{p-f6f1d779.system.entry.js → p-3e85b9f5.system.entry.js} +1 -1
- package/dist/zonos-elements/p-48475755.entry.js +1 -0
- package/dist/zonos-elements/{p-d0411b2d.entry.js → p-58248f03.entry.js} +1 -1
- package/dist/zonos-elements/p-5edef7c3.system.js +1 -0
- package/dist/zonos-elements/{p-678331f0.system.js → p-63a3d3b9.system.js} +1 -1
- package/dist/zonos-elements/p-64661dd1.js +1 -0
- package/dist/zonos-elements/p-69212d0f.entry.js +1 -0
- package/dist/zonos-elements/{p-71185d24.system.js → p-719403e0.system.js} +1 -1
- package/dist/zonos-elements/{p-382601a9.system.entry.js → p-71a8d971.system.entry.js} +1 -1
- package/dist/zonos-elements/p-71d855b8.system.entry.js +1 -0
- package/dist/zonos-elements/p-71f10bf0.entry.js +1 -0
- package/dist/zonos-elements/p-72ff005c.entry.js +1 -0
- package/dist/zonos-elements/{p-08365fdb.system.js → p-7dba5f23.system.js} +1 -1
- package/dist/zonos-elements/p-85e59f3a.system.entry.js +1 -0
- package/dist/zonos-elements/{p-ce98e472.js → p-866afec1.js} +1 -1
- package/dist/zonos-elements/p-942358eb.system.js +1 -0
- package/dist/zonos-elements/{p-2c10b067.system.entry.js → p-94c5fbfc.system.entry.js} +1 -1
- package/dist/zonos-elements/p-a12cb7ce.entry.js +1 -0
- package/dist/zonos-elements/p-abf38ed6.js +1 -0
- package/dist/zonos-elements/{p-df6e62f8.system.js → p-ae16dda9.system.js} +1 -1
- package/dist/zonos-elements/{p-46ece7ae.js → p-bc4bfa06.js} +1 -1
- package/dist/zonos-elements/p-bf5e47e2.entry.js +1 -0
- package/dist/zonos-elements/{p-dca14319.system.js → p-c027a832.system.js} +1 -1
- package/dist/zonos-elements/p-c2442878.system.js +1 -1
- package/dist/zonos-elements/p-c2f34b10.system.entry.js +1 -0
- package/dist/zonos-elements/p-c36696f9.js +1 -0
- package/dist/zonos-elements/p-c7311ce5.system.entry.js +1 -0
- package/dist/zonos-elements/{p-1b86711b.js → p-de8899bc.js} +1 -1
- package/dist/zonos-elements/p-e17bbcee.entry.js +1 -0
- package/dist/zonos-elements/{p-e458f737.entry.js → p-f6c2c743.entry.js} +1 -1
- package/dist/zonos-elements/p-fe06c9ea.js +17 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/paypal-56534e48.js +0 -17
- package/dist/zonos-elements/p-0c201c39.system.entry.js +0 -1
- package/dist/zonos-elements/p-0cb5f151.system.entry.js +0 -1
- package/dist/zonos-elements/p-3e2f175c.entry.js +0 -1
- package/dist/zonos-elements/p-5295d36e.entry.js +0 -1
- package/dist/zonos-elements/p-64870563.entry.js +0 -1
- package/dist/zonos-elements/p-695e0803.system.entry.js +0 -1
- package/dist/zonos-elements/p-6e3cf6eb.entry.js +0 -1
- package/dist/zonos-elements/p-6f430d6f.system.entry.js +0 -1
- package/dist/zonos-elements/p-794d29dc.entry.js +0 -1
- package/dist/zonos-elements/p-8defdf0d.system.js +0 -17
- package/dist/zonos-elements/p-8e98a7c8.js +0 -1
- package/dist/zonos-elements/p-95348ebf.system.entry.js +0 -1
- package/dist/zonos-elements/p-9a066833.system.entry.js +0 -1
- package/dist/zonos-elements/p-aa6c2348.system.entry.js +0 -1
- package/dist/zonos-elements/p-ada8841a.js +0 -1
- package/dist/zonos-elements/p-c75b7c47.entry.js +0 -1
- package/dist/zonos-elements/p-caff391d.system.entry.js +0 -1
- package/dist/zonos-elements/p-dd19d9d8.js +0 -17
- package/dist/zonos-elements/p-df90bccf.entry.js +0 -1
- package/dist/zonos-elements/p-e07aaf09.system.js +0 -1
- package/dist/zonos-elements/p-f8eb618b.entry.js +0 -1
|
@@ -146,7 +146,7 @@ export class ZonosCollectFinish {
|
|
|
146
146
|
window.history.replaceState({}, '', url.toString());
|
|
147
147
|
// Payment doesn't go through
|
|
148
148
|
if (error && (messages === null || messages === void 0 ? void 0 : messages.length)) {
|
|
149
|
-
submitGtag('zonos-checkout-payment-fail');
|
|
149
|
+
submitGtag({ event: 'zonos-checkout-payment-fail' });
|
|
150
150
|
void sendErrorLog({
|
|
151
151
|
endpoint: 'Stripe payment failed',
|
|
152
152
|
errors: [
|
|
@@ -159,7 +159,7 @@ export class ZonosCollectFinish {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
else {
|
|
162
|
-
submitGtag('zonos-checkout-success');
|
|
162
|
+
submitGtag({ event: 'zonos-checkout-success' });
|
|
163
163
|
const checkoutSessionId = storageStore.checkoutSessionId;
|
|
164
164
|
void trackConversionEvent({
|
|
165
165
|
checkoutSessionId,
|
|
@@ -204,7 +204,7 @@ export class ZonosCollectFinish {
|
|
|
204
204
|
// show success message right away when order id is already created
|
|
205
205
|
this.isLoading = false;
|
|
206
206
|
if (paypalStore.orderIdCreated) {
|
|
207
|
-
submitGtag('zonos-checkout-success');
|
|
207
|
+
submitGtag({ event: 'zonos-checkout-success' });
|
|
208
208
|
const checkoutSessionId = storageStore.checkoutSessionId;
|
|
209
209
|
void trackConversionEvent({
|
|
210
210
|
checkoutSessionId,
|
|
@@ -260,11 +260,11 @@ export class ZonosCollectFinish {
|
|
|
260
260
|
}
|
|
261
261
|
render() {
|
|
262
262
|
const cartId = window.Zonos.cartId;
|
|
263
|
-
return (h(Host, { key: '
|
|
263
|
+
return (h(Host, { key: 'c085862ecf1f50752634fb44f99b5cb5d82a9e24', class: "zonos--checkout-finish zonos--elements", style: {
|
|
264
264
|
'--zonos--border-radius': getBorderRadius({
|
|
265
265
|
overrideBorderStyle: this.borderRadius,
|
|
266
266
|
}),
|
|
267
|
-
} }, !this.isLoading && (h("div", { key: '
|
|
267
|
+
} }, !this.isLoading && (h("div", { key: '9b30b12c817c3422b355a2f544bbf2908f736c80', class: "zonos--finish-details" }, h("div", { key: '697fff3258a6e74d99500ec25f5d3923f8c7cfc2', class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { "aria-label": "Order success", content: SuccessIcon, iconColor: 'blue-800', size: 50 })) : (h("zonos-icon", { "aria-label": "Order failed", content: RemoveIcon, iconColor: 'red-800', size: 50 })), h("zonos-text", { key: '8457c0c9b22c2fb6374b60e492099981026d2690', class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), this.confirmationId && (h("zonos-badge", { key: '21ab18878abb37a2c37d873c494d71aee3d4ed71', badgeColor: "gray" }, this.confirmationId)), h("zonos-text", { key: '389918dd57e6ce5744b7192baa3c06c6db3f70cd', class: "zonos--subtitle", textColor: "gray-600" }, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), this.order && cartId && (h("div", { key: 'cca6b625a6bea62b788cf8dd6bb9e03e6505d81c', class: "zonos--button-container" }, h("zonos-button", { key: '0f45987515ae99045e5b449b5b1aaae11d70d9fb', onClick: () => {
|
|
268
268
|
window.open(this.getReceiptUrl({ cartId }), '_blank');
|
|
269
269
|
}, size: "lg", variant: "primary" }, translate('View receipt')))))))));
|
|
270
270
|
}
|
|
@@ -64,7 +64,7 @@ export class ZonosCollectPayment {
|
|
|
64
64
|
}
|
|
65
65
|
stripeStore.checkoutSettlementCurrency = currencyCode;
|
|
66
66
|
// submit google tag when the form is complete
|
|
67
|
-
submitGtag('zonos-checkout-payment-info');
|
|
67
|
+
submitGtag({ event: 'zonos-checkout-payment-info' });
|
|
68
68
|
this.continueClicked.emit();
|
|
69
69
|
};
|
|
70
70
|
this.copyCardToClipboard = async (cardNumber) => {
|
|
@@ -146,7 +146,7 @@ export class ZonosInvoiceFinish {
|
|
|
146
146
|
window.history.replaceState({}, '', url.toString());
|
|
147
147
|
// Payment doesn't go through
|
|
148
148
|
if (error && (messages === null || messages === void 0 ? void 0 : messages.length)) {
|
|
149
|
-
submitGtag('zonos-checkout-payment-fail');
|
|
149
|
+
submitGtag({ event: 'zonos-checkout-payment-fail' });
|
|
150
150
|
void sendErrorLog({
|
|
151
151
|
endpoint: 'Stripe payment failed',
|
|
152
152
|
errors: [
|
|
@@ -159,7 +159,7 @@ export class ZonosInvoiceFinish {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
else {
|
|
162
|
-
submitGtag('zonos-checkout-success');
|
|
162
|
+
submitGtag({ event: 'zonos-checkout-success' });
|
|
163
163
|
const checkoutSessionId = storageStore.checkoutSessionId;
|
|
164
164
|
void trackConversionEvent({
|
|
165
165
|
checkoutSessionId,
|
|
@@ -204,7 +204,7 @@ export class ZonosInvoiceFinish {
|
|
|
204
204
|
// show success message right away when order id is already created
|
|
205
205
|
this.isLoading = false;
|
|
206
206
|
if (paypalStore.orderIdCreated) {
|
|
207
|
-
submitGtag('zonos-checkout-success');
|
|
207
|
+
submitGtag({ event: 'zonos-checkout-success' });
|
|
208
208
|
const checkoutSessionId = storageStore.checkoutSessionId;
|
|
209
209
|
void trackConversionEvent({
|
|
210
210
|
checkoutSessionId,
|
|
@@ -260,11 +260,11 @@ export class ZonosInvoiceFinish {
|
|
|
260
260
|
}
|
|
261
261
|
render() {
|
|
262
262
|
const cartId = window.Zonos.cartId;
|
|
263
|
-
return (h(Host, { key: '
|
|
263
|
+
return (h(Host, { key: '5d2fc87bc549fa2cb6d622e664043bbfe55f8b0e', class: "zonos--checkout-finish zonos--elements", style: {
|
|
264
264
|
'--zonos--border-radius': getBorderRadius({
|
|
265
265
|
overrideBorderStyle: this.borderRadius,
|
|
266
266
|
}),
|
|
267
|
-
} }, !this.isLoading && (h("div", { key: '
|
|
267
|
+
} }, !this.isLoading && (h("div", { key: '1268de9e5be1edc4cbe2e7e2f1d2590b168d8c7b', class: "zonos--finish-details" }, h("div", { key: 'ce63ee565c176ea5687fc1c0f721932e26b93ebd', class: "zonos--group" }, this.notificationType === 'success' ? (h("zonos-icon", { "aria-label": "Order success", content: SuccessIcon, iconColor: 'blue-800', size: 50 })) : (h("zonos-icon", { "aria-label": "Order failed", content: RemoveIcon, iconColor: 'red-800', size: 50 })), h("zonos-text", { key: 'a073858eac699426dc5947b85d3b3665868f164e', class: "zonos--title", type: "semiBoldSubheader" }, this.notificationTitle), this.confirmationId && (h("zonos-badge", { key: 'a96c40f5cc977de82585f7827d6bc6aef55ba873', badgeColor: "gray" }, this.confirmationId)), h("zonos-text", { key: 'd97bc54085b9fe69eb05b44042deae25c379ee3a', class: "zonos--subtitle", textColor: "gray-600" }, this.notificationMessages.map(message => (h(Fragment, null, message, h("br", null))))), this.order && cartId && (h("div", { key: '488c3442e40fedf65caedbd3e098bd8b95976aab', class: "zonos--button-container" }, h("zonos-button", { key: '9a01b9cca0e3747548d386345015ecea80dc29d3', onClick: () => {
|
|
268
268
|
window.open(this.getReceiptUrl({ cartId }), '_blank');
|
|
269
269
|
}, size: "lg", variant: "primary" }, translate('View receipt')))))))));
|
|
270
270
|
}
|
|
@@ -64,7 +64,7 @@ export class ZonosInvoicePayment {
|
|
|
64
64
|
}
|
|
65
65
|
stripeStore.checkoutSettlementCurrency = currencyCode;
|
|
66
66
|
// submit google tag when the form is complete
|
|
67
|
-
submitGtag('zonos-checkout-payment-info');
|
|
67
|
+
submitGtag({ event: 'zonos-checkout-payment-info' });
|
|
68
68
|
this.continueClicked.emit();
|
|
69
69
|
};
|
|
70
70
|
this.copyCardToClipboard = async (cardNumber) => {
|
|
@@ -12,6 +12,7 @@ import { initHello } from "../utils/hello/initHello";
|
|
|
12
12
|
import { CheckoutAddressService } from "../utils/iframe/CheckoutAddressService";
|
|
13
13
|
import { iframeServices, injectPrivateIframe, } from "../utils/iframe/IframeHelpers";
|
|
14
14
|
import { log } from "../utils/logging/log";
|
|
15
|
+
import { ensureAnalyticsRelayPing } from "../utils/submitGtag";
|
|
15
16
|
export class ZonosController {
|
|
16
17
|
/**
|
|
17
18
|
* Method to initialize checkout element
|
|
@@ -142,6 +143,8 @@ export class ZonosController {
|
|
|
142
143
|
}
|
|
143
144
|
document.body.appendChild(scriptToInject);
|
|
144
145
|
});
|
|
146
|
+
// Custom HTML may set window.Zonos.googleAnalyticId; trigger relay ping so parent configures GA
|
|
147
|
+
ensureAnalyticsRelayPing();
|
|
145
148
|
}
|
|
146
149
|
async initGooglePlacesService(settings) {
|
|
147
150
|
const genericSettings = settings === null || settings === void 0 ? void 0 : settings.genericSettings;
|
|
@@ -328,7 +331,7 @@ export class ZonosController {
|
|
|
328
331
|
zonosStore.organizationName = organizationName;
|
|
329
332
|
}
|
|
330
333
|
render() {
|
|
331
|
-
return h(Host, { key: '
|
|
334
|
+
return h(Host, { key: '92e1eae13d0b13f91098ea110203b6c7a7f67c3e', class: "zonos--elements" });
|
|
332
335
|
}
|
|
333
336
|
static get is() { return "zonos-controller"; }
|
|
334
337
|
static get encapsulation() { return "shadow"; }
|
|
@@ -94,6 +94,12 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
94
94
|
// reset stripe error message
|
|
95
95
|
stripeStore.hasPaymentError = false;
|
|
96
96
|
stripeStore.customErrorMessage = null;
|
|
97
|
+
submitGtag({
|
|
98
|
+
event: 'zonos-checkout-payment-fail',
|
|
99
|
+
metadata: {
|
|
100
|
+
checkoutSessionId,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
97
103
|
onPaypalFail === null || onPaypalFail === void 0 ? void 0 : onPaypalFail();
|
|
98
104
|
return '';
|
|
99
105
|
}
|
|
@@ -126,6 +132,12 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
126
132
|
// reset stripe error message
|
|
127
133
|
stripeStore.hasPaymentError = false;
|
|
128
134
|
stripeStore.customErrorMessage = null;
|
|
135
|
+
submitGtag({
|
|
136
|
+
event: 'zonos-checkout-payment-fail',
|
|
137
|
+
metadata: {
|
|
138
|
+
checkoutSessionId,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
129
141
|
// trigger fail event
|
|
130
142
|
onPaypalFail === null || onPaypalFail === void 0 ? void 0 : onPaypalFail();
|
|
131
143
|
return '';
|
|
@@ -136,7 +148,13 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
136
148
|
// reset paypal error banner
|
|
137
149
|
paypalStore.paypalErrorMessage = null;
|
|
138
150
|
// submit google tag when the form is complete
|
|
139
|
-
submitGtag(
|
|
151
|
+
submitGtag({
|
|
152
|
+
event: 'zonos-checkout-payment-info',
|
|
153
|
+
metadata: {
|
|
154
|
+
checkoutSessionId,
|
|
155
|
+
paymentMethod: 'paypal',
|
|
156
|
+
},
|
|
157
|
+
});
|
|
140
158
|
const orderId = await paypalStoreCaptureOrder({
|
|
141
159
|
checkoutSessionId,
|
|
142
160
|
paypalMockResponse: window.Zonos._paypalMockResponse,
|
|
@@ -810,6 +810,8 @@ const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybo
|
|
|
810
810
|
const status = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status;
|
|
811
811
|
const { isError, messages } = stripeStoreMessageBasedOnStatus(status);
|
|
812
812
|
return {
|
|
813
|
+
amount: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.amount,
|
|
814
|
+
currency: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.currency,
|
|
813
815
|
error: isError,
|
|
814
816
|
messages,
|
|
815
817
|
paymentIntentId: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.id,
|
|
@@ -1,16 +1,104 @@
|
|
|
1
1
|
import { zonosStore } from "../store/zonosStore";
|
|
2
|
+
import { getIsTestMode } from "./checkout/getIsTestMode";
|
|
2
3
|
import { log } from "./logging/log";
|
|
4
|
+
import { RELAY_PING_TYPE, RELAY_READY_TYPE, ZONOS_ANALYTIC_TYPE, } from "../../types/analyticsRelay";
|
|
5
|
+
let parentGtagReady = false;
|
|
6
|
+
let relayListenerAdded = false;
|
|
7
|
+
const queuedEvents = [];
|
|
8
|
+
function flushQueuedEvents() {
|
|
9
|
+
while (queuedEvents.length > 0) {
|
|
10
|
+
const { event, payload } = queuedEvents.shift();
|
|
11
|
+
try {
|
|
12
|
+
window.parent.postMessage({
|
|
13
|
+
event,
|
|
14
|
+
metadata: payload,
|
|
15
|
+
type: ZONOS_ANALYTIC_TYPE,
|
|
16
|
+
}, '*');
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
// Ignore postMessage failures
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function ensureRelayListener() {
|
|
24
|
+
if (relayListenerAdded)
|
|
25
|
+
return;
|
|
26
|
+
relayListenerAdded = true;
|
|
27
|
+
window.addEventListener('message', (e) => {
|
|
28
|
+
var _a;
|
|
29
|
+
if (((_a = e.data) === null || _a === void 0 ? void 0 : _a.type) === RELAY_READY_TYPE) {
|
|
30
|
+
parentGtagReady = true;
|
|
31
|
+
if (typeof window.Zonos !== 'undefined') {
|
|
32
|
+
window.Zonos.googleAnalyticReady = true;
|
|
33
|
+
}
|
|
34
|
+
flushQueuedEvents();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function sendPingToParent() {
|
|
39
|
+
try {
|
|
40
|
+
const googleAnalyticId = typeof window.Zonos !== 'undefined'
|
|
41
|
+
? window.Zonos.googleAnalyticId
|
|
42
|
+
: undefined;
|
|
43
|
+
window.parent.postMessage({ googleAnalyticId, type: RELAY_PING_TYPE }, '*');
|
|
44
|
+
}
|
|
45
|
+
catch (_a) {
|
|
46
|
+
// Ignore postMessage failures
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sends ping to parent with googleAnalyticId so parent can inject/configure GA and respond with ready.
|
|
51
|
+
* Call after customHTML or custom script sets window.Zonos.googleAnalyticId.
|
|
52
|
+
*/
|
|
53
|
+
export function ensureAnalyticsRelayPing() {
|
|
54
|
+
if (typeof window === 'undefined' ||
|
|
55
|
+
window.parent === window ||
|
|
56
|
+
parentGtagReady) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
ensureRelayListener();
|
|
60
|
+
sendPingToParent();
|
|
61
|
+
}
|
|
3
62
|
/**
|
|
4
63
|
* Submit a gtag event if the gtag function is available.
|
|
64
|
+
* When running inside an iframe, only posts to parent after the parent has
|
|
65
|
+
* confirmed (via analyticsRelayOnInit) that gtag is available.
|
|
5
66
|
*/
|
|
6
|
-
export const submitGtag = (event) => {
|
|
67
|
+
export const submitGtag = ({ event, metadata }) => {
|
|
7
68
|
const googleAnalyticSetting = zonosStore.checkoutSettings.analyticsProviders.find(item => item.type === 'GOOGLE_ANALYTICS');
|
|
8
69
|
// only submit if googleAnalytic in checkout setting is on.
|
|
9
70
|
if (!googleAnalyticSetting || (googleAnalyticSetting === null || googleAnalyticSetting === void 0 ? void 0 : googleAnalyticSetting.status) === 'DISABLED') {
|
|
10
71
|
return;
|
|
11
72
|
}
|
|
73
|
+
const isTestMode = getIsTestMode();
|
|
74
|
+
const payload = Object.assign(Object.assign({}, metadata), (isTestMode && { isTestMode: true }));
|
|
75
|
+
// filter null key
|
|
76
|
+
const filteredPayload = Object.fromEntries(Object.entries(payload).filter(([_, value]) => value !== null));
|
|
77
|
+
const isInIframe = typeof window !== 'undefined' && window.parent !== window;
|
|
78
|
+
if (isInIframe) {
|
|
79
|
+
// gtag does not work in iframe; must relay to parent via postMessage
|
|
80
|
+
ensureRelayListener();
|
|
81
|
+
if (parentGtagReady) {
|
|
82
|
+
try {
|
|
83
|
+
window.parent.postMessage({
|
|
84
|
+
event,
|
|
85
|
+
metadata: filteredPayload,
|
|
86
|
+
type: ZONOS_ANALYTIC_TYPE,
|
|
87
|
+
}, '*');
|
|
88
|
+
}
|
|
89
|
+
catch (_a) {
|
|
90
|
+
// Ignore postMessage failures
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
queuedEvents.push({ event, payload: filteredPayload });
|
|
95
|
+
sendPingToParent();
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Not in iframe: call gtag directly
|
|
12
100
|
if (typeof window.gtag === 'function') {
|
|
13
101
|
log('Zonos submits gtag event', 'log', event);
|
|
14
|
-
window.gtag('event', event,
|
|
102
|
+
window.gtag('event', event, filteredPayload);
|
|
15
103
|
}
|
|
16
104
|
};
|
|
@@ -51,6 +51,8 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
51
51
|
Zonos.isBigCommerce = false;
|
|
52
52
|
Zonos.releaseDate = process.env.NEXT_PUBLIC_RELEASE_DATE;
|
|
53
53
|
Zonos.isLegacyCheckout = false;
|
|
54
|
+
Zonos.googleAnalyticId = null;
|
|
55
|
+
Zonos.googleAnalyticReady = false;
|
|
54
56
|
Zonos.startLoadTime = startLoadTime;
|
|
55
57
|
Zonos.domain = typeof window !== 'undefined'
|
|
56
58
|
? // domain that embeds the iframe
|
|
@@ -90,6 +92,10 @@ Zonos.init = async (params) => {
|
|
|
90
92
|
log(`====== ZONOS DEBUG MODE: on (${_a.version}) ======`);
|
|
91
93
|
_a.zonosApiKey = zonosApiKey;
|
|
92
94
|
_a.storeId = storeId;
|
|
95
|
+
// When not in iframe, GA is ready (gtag works directly). When in iframe, relay will set this after parent configures.
|
|
96
|
+
if (typeof window !== 'undefined' && window.parent === window) {
|
|
97
|
+
_a.googleAnalyticReady = true;
|
|
98
|
+
}
|
|
93
99
|
if (_a.isNpm) {
|
|
94
100
|
log('====== ZONOS LOADING FROM NPM ======');
|
|
95
101
|
const zonosQaUrl = getZonosQaUrl();
|
|
@@ -194,6 +200,7 @@ Zonos.injectCustomScriptForHostedCheckout = () => {
|
|
|
194
200
|
const metadata = (cartData === null || cartData === void 0 ? void 0 : cartData.metadata) || [];
|
|
195
201
|
const headerScript = metadata.find(meta => meta.key === 'customHeaderScript');
|
|
196
202
|
const footerScript = metadata.find(meta => meta.key === 'customFooterScript');
|
|
203
|
+
// googleAnalyticId is set by customHTML in checkoutSettings (e.g. <script>window.Zonos.googleAnalyticId = "G-XXX";</script>), injected by zonos-controller
|
|
197
204
|
// Only inject the script if checkout is on Zonos hosted checkout and custom script is available
|
|
198
205
|
if (!window.Zonos.isLegacyCheckout || (!headerScript && !footerScript)) {
|
|
199
206
|
log('Skip injecting custom script for hosted checkout', 'info', {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Message type for zonos-analytic events sent from iframe to parent. */
|
|
2
|
+
export const ZONOS_ANALYTIC_TYPE = 'zonos-analytic';
|
|
3
|
+
/** Ping sent by iframe to configure parent's analytics relay (e.g. GA) and get ready signal. */
|
|
4
|
+
export const RELAY_PING_TYPE = 'zonos-analytics-relay-ping';
|
|
5
|
+
/** Response from parent when analytics relay (e.g. gtag) is ready. */
|
|
6
|
+
export const RELAY_READY_TYPE = 'zonos-analytics-relay-ready';
|
|
@@ -1421,6 +1421,8 @@ const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybo
|
|
|
1421
1421
|
const status = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status;
|
|
1422
1422
|
const { isError, messages } = stripeStoreMessageBasedOnStatus(status);
|
|
1423
1423
|
return {
|
|
1424
|
+
amount: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.amount,
|
|
1425
|
+
currency: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.currency,
|
|
1424
1426
|
error: isError,
|
|
1425
1427
|
messages,
|
|
1426
1428
|
paymentIntentId: paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.id,
|
package/dist/esm/index.js
CHANGED
|
@@ -131,7 +131,7 @@ const getZonosQaUrl = () => {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
134
|
-
const cdnUrl = "https://v1.3.
|
|
134
|
+
const cdnUrl = "https://v1.3.248.js.zonos.com";
|
|
135
135
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
136
136
|
if (!qaUrl &&
|
|
137
137
|
(cdnUrl.includes('test.') ||
|
|
@@ -379,10 +379,10 @@ const zonosLoadUrl = (() => {
|
|
|
379
379
|
return null;
|
|
380
380
|
})();
|
|
381
381
|
const startLoadTime = Date.now();
|
|
382
|
-
const ZONOS_URL = "https://v1.3.
|
|
383
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.
|
|
384
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.
|
|
385
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.
|
|
382
|
+
const ZONOS_URL = "https://v1.3.248.js.zonos.com";
|
|
383
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.248";
|
|
384
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.248";
|
|
385
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.248";
|
|
386
386
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
387
387
|
const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
|
|
388
388
|
class Zonos {
|
|
@@ -400,8 +400,10 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
400
400
|
? new URLSearchParams(window.location.search).get('iframeLogType')
|
|
401
401
|
: null;
|
|
402
402
|
Zonos.isBigCommerce = false;
|
|
403
|
-
Zonos.releaseDate = "
|
|
403
|
+
Zonos.releaseDate = "1772221080993";
|
|
404
404
|
Zonos.isLegacyCheckout = false;
|
|
405
|
+
Zonos.googleAnalyticId = null;
|
|
406
|
+
Zonos.googleAnalyticReady = false;
|
|
405
407
|
Zonos.startLoadTime = startLoadTime;
|
|
406
408
|
Zonos.domain = typeof window !== 'undefined'
|
|
407
409
|
? // domain that embeds the iframe
|
|
@@ -421,7 +423,7 @@ Zonos.isNpm = true;
|
|
|
421
423
|
Zonos.zonosQaUrl = null;
|
|
422
424
|
Zonos.zonosQaUrlApi = null;
|
|
423
425
|
Zonos.trackEventLogs = [];
|
|
424
|
-
Zonos.version = `v${"1.3.
|
|
426
|
+
Zonos.version = `v${"1.3.248"}`;
|
|
425
427
|
Zonos.modeAlerted = false;
|
|
426
428
|
Zonos.cartData = null;
|
|
427
429
|
Zonos.paypal = null;
|
|
@@ -441,6 +443,10 @@ Zonos.init = async (params) => {
|
|
|
441
443
|
log(`====== ZONOS DEBUG MODE: on (${_a.version}) ======`);
|
|
442
444
|
_a.zonosApiKey = zonosApiKey;
|
|
443
445
|
_a.storeId = storeId;
|
|
446
|
+
// When not in iframe, GA is ready (gtag works directly). When in iframe, relay will set this after parent configures.
|
|
447
|
+
if (typeof window !== 'undefined' && window.parent === window) {
|
|
448
|
+
_a.googleAnalyticReady = true;
|
|
449
|
+
}
|
|
444
450
|
if (_a.isNpm) {
|
|
445
451
|
log('====== ZONOS LOADING FROM NPM ======');
|
|
446
452
|
const zonosQaUrl = getZonosQaUrl();
|
|
@@ -545,6 +551,7 @@ Zonos.injectCustomScriptForHostedCheckout = () => {
|
|
|
545
551
|
const metadata = (cartData === null || cartData === void 0 ? void 0 : cartData.metadata) || [];
|
|
546
552
|
const headerScript = metadata.find(meta => meta.key === 'customHeaderScript');
|
|
547
553
|
const footerScript = metadata.find(meta => meta.key === 'customFooterScript');
|
|
554
|
+
// googleAnalyticId is set by customHTML in checkoutSettings (e.g. <script>window.Zonos.googleAnalyticId = "G-XXX";</script>), injected by zonos-controller
|
|
548
555
|
// Only inject the script if checkout is on Zonos hosted checkout and custom script is available
|
|
549
556
|
if (!window.Zonos.isLegacyCheckout || (!headerScript && !footerScript)) {
|
|
550
557
|
log('Skip injecting custom script for hosted checkout', 'info', {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore } from './zonosStore-b434e436.js';
|
|
2
|
-
import { b as stripeStore, C as stripeStoreBuildAddressForPartyCreate, d as cartStore, D as cartStoreUpdateSelectedShippingOption } from './cart-
|
|
2
|
+
import { b as stripeStore, C as stripeStoreBuildAddressForPartyCreate, d as cartStore, D as cartStoreUpdateSelectedShippingOption } from './cart-ba8f3890.js';
|
|
3
3
|
import { s as storageStore } from './localization-853b48a9.js';
|
|
4
4
|
import { h as handleFetch, s as sendErrorLog, l as logError } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { b as allLogs } from './VarianceTest-572cecf5.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore } from './zonosStore-b434e436.js';
|
|
2
|
-
import { b as stripeStore, C as stripeStoreBuildAddressForPartyCreate, d as cartStore, D as cartStoreUpdateSelectedShippingOption } from './cart-
|
|
2
|
+
import { b as stripeStore, C as stripeStoreBuildAddressForPartyCreate, d as cartStore, D as cartStoreUpdateSelectedShippingOption } from './cart-ba8f3890.js';
|
|
3
3
|
import { s as storageStore } from './localization-853b48a9.js';
|
|
4
4
|
import { h as handleFetch, s as sendErrorLog, l as logError } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { b as allLogs } from './VarianceTest-572cecf5.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as trackConversionEvent, A as validateCheckoutSession, b as stripeStore, d as cartStore, v as stripeStoreHandleInventoryCheck, r as cartStoreNextStep, h as cartStoreClearCheckoutInterval } from './cart-
|
|
1
|
+
import { c as createStore, z as zonosStore } from './zonosStore-b434e436.js';
|
|
2
|
+
import { t as trackConversionEvent, A as validateCheckoutSession, b as stripeStore, d as cartStore, v as stripeStoreHandleInventoryCheck, r as cartStoreNextStep, h as cartStoreClearCheckoutInterval } from './cart-ba8f3890.js';
|
|
3
3
|
import { t as translate, s as storageStore } from './localization-853b48a9.js';
|
|
4
4
|
import { h as handleFetch, l as logError, j as jsonParse } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { i as isContrastColor } from './isContrastColor-69778cea.js';
|
|
6
6
|
import { l as log } from './VarianceTest-572cecf5.js';
|
|
7
|
+
import { s as submitGtag } from './submitGtag-89d6e9cb.js';
|
|
7
8
|
|
|
8
9
|
/*!
|
|
9
10
|
* paypal-js v8.1.0 (2024-06-07T16:55:00.122Z)
|
|
@@ -224,21 +225,6 @@ const paypalCreateOrder = async ({ checkoutSessionId, intent, }) => {
|
|
|
224
225
|
return { errors, json };
|
|
225
226
|
};
|
|
226
227
|
|
|
227
|
-
/**
|
|
228
|
-
* Submit a gtag event if the gtag function is available.
|
|
229
|
-
*/
|
|
230
|
-
const submitGtag = (event) => {
|
|
231
|
-
const googleAnalyticSetting = zonosStore.checkoutSettings.analyticsProviders.find(item => item.type === 'GOOGLE_ANALYTICS');
|
|
232
|
-
// only submit if googleAnalytic in checkout setting is on.
|
|
233
|
-
if (!googleAnalyticSetting || (googleAnalyticSetting === null || googleAnalyticSetting === void 0 ? void 0 : googleAnalyticSetting.status) === 'DISABLED') {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (typeof window.gtag === 'function') {
|
|
237
|
-
log('Zonos submits gtag event', 'log', event);
|
|
238
|
-
window.gtag('event', event, {});
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
228
|
const { onChange: paypalStoreOnChange, reset: paypalStoreReset, state: paypalStore, } = createStore(() => ({
|
|
243
229
|
intent: 'capture',
|
|
244
230
|
orderIdCreated: null,
|
|
@@ -319,6 +305,12 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
319
305
|
// reset stripe error message
|
|
320
306
|
stripeStore.hasPaymentError = false;
|
|
321
307
|
stripeStore.customErrorMessage = null;
|
|
308
|
+
submitGtag({
|
|
309
|
+
event: 'zonos-checkout-payment-fail',
|
|
310
|
+
metadata: {
|
|
311
|
+
checkoutSessionId,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
322
314
|
onPaypalFail === null || onPaypalFail === void 0 ? void 0 : onPaypalFail();
|
|
323
315
|
return '';
|
|
324
316
|
}
|
|
@@ -351,6 +343,12 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
351
343
|
// reset stripe error message
|
|
352
344
|
stripeStore.hasPaymentError = false;
|
|
353
345
|
stripeStore.customErrorMessage = null;
|
|
346
|
+
submitGtag({
|
|
347
|
+
event: 'zonos-checkout-payment-fail',
|
|
348
|
+
metadata: {
|
|
349
|
+
checkoutSessionId,
|
|
350
|
+
},
|
|
351
|
+
});
|
|
354
352
|
// trigger fail event
|
|
355
353
|
onPaypalFail === null || onPaypalFail === void 0 ? void 0 : onPaypalFail();
|
|
356
354
|
return '';
|
|
@@ -361,7 +359,13 @@ const paypalButtonOptions = ({ checkoutSessionId, onPaypalFail, onPaypalSessionD
|
|
|
361
359
|
// reset paypal error banner
|
|
362
360
|
paypalStore.paypalErrorMessage = null;
|
|
363
361
|
// submit google tag when the form is complete
|
|
364
|
-
submitGtag(
|
|
362
|
+
submitGtag({
|
|
363
|
+
event: 'zonos-checkout-payment-info',
|
|
364
|
+
metadata: {
|
|
365
|
+
checkoutSessionId,
|
|
366
|
+
paymentMethod: 'paypal',
|
|
367
|
+
},
|
|
368
|
+
});
|
|
365
369
|
const orderId = await paypalStoreCaptureOrder({
|
|
366
370
|
checkoutSessionId,
|
|
367
371
|
paypalMockResponse: window.Zonos._paypalMockResponse,
|
|
@@ -476,4 +480,4 @@ const paypalStoreHasPaypalEnabled = () => {
|
|
|
476
480
|
return paypalEnabledInSetting || !!paypalStore.paypalButtons.length;
|
|
477
481
|
};
|
|
478
482
|
|
|
479
|
-
export { paypalStore as a, paypalInitScript as b, paypalStoreReset as c, paypalStoreInitButtons as d, paypalStoreOnChange as e, paypalStoreHasPaypalEnabled as p
|
|
483
|
+
export { paypalStore as a, paypalInitScript as b, paypalStoreReset as c, paypalStoreInitButtons as d, paypalStoreOnChange as e, paypalStoreHasPaypalEnabled as p };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z as zonosStore } from './zonosStore-b434e436.js';
|
|
2
|
+
import { g as getIsTestMode } from './handleFetch-a844cac1.js';
|
|
3
|
+
import { l as log } from './VarianceTest-572cecf5.js';
|
|
4
|
+
|
|
5
|
+
/** Message type for zonos-analytic events sent from iframe to parent. */
|
|
6
|
+
const ZONOS_ANALYTIC_TYPE = 'zonos-analytic';
|
|
7
|
+
/** Ping sent by iframe to configure parent's analytics relay (e.g. GA) and get ready signal. */
|
|
8
|
+
const RELAY_PING_TYPE = 'zonos-analytics-relay-ping';
|
|
9
|
+
/** Response from parent when analytics relay (e.g. gtag) is ready. */
|
|
10
|
+
const RELAY_READY_TYPE = 'zonos-analytics-relay-ready';
|
|
11
|
+
|
|
12
|
+
let parentGtagReady = false;
|
|
13
|
+
let relayListenerAdded = false;
|
|
14
|
+
const queuedEvents = [];
|
|
15
|
+
function flushQueuedEvents() {
|
|
16
|
+
while (queuedEvents.length > 0) {
|
|
17
|
+
const { event, payload } = queuedEvents.shift();
|
|
18
|
+
try {
|
|
19
|
+
window.parent.postMessage({
|
|
20
|
+
event,
|
|
21
|
+
metadata: payload,
|
|
22
|
+
type: ZONOS_ANALYTIC_TYPE,
|
|
23
|
+
}, '*');
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
// Ignore postMessage failures
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function ensureRelayListener() {
|
|
31
|
+
if (relayListenerAdded)
|
|
32
|
+
return;
|
|
33
|
+
relayListenerAdded = true;
|
|
34
|
+
window.addEventListener('message', (e) => {
|
|
35
|
+
var _a;
|
|
36
|
+
if (((_a = e.data) === null || _a === void 0 ? void 0 : _a.type) === RELAY_READY_TYPE) {
|
|
37
|
+
parentGtagReady = true;
|
|
38
|
+
if (typeof window.Zonos !== 'undefined') {
|
|
39
|
+
window.Zonos.googleAnalyticReady = true;
|
|
40
|
+
}
|
|
41
|
+
flushQueuedEvents();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function sendPingToParent() {
|
|
46
|
+
try {
|
|
47
|
+
const googleAnalyticId = typeof window.Zonos !== 'undefined'
|
|
48
|
+
? window.Zonos.googleAnalyticId
|
|
49
|
+
: undefined;
|
|
50
|
+
window.parent.postMessage({ googleAnalyticId, type: RELAY_PING_TYPE }, '*');
|
|
51
|
+
}
|
|
52
|
+
catch (_a) {
|
|
53
|
+
// Ignore postMessage failures
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sends ping to parent with googleAnalyticId so parent can inject/configure GA and respond with ready.
|
|
58
|
+
* Call after customHTML or custom script sets window.Zonos.googleAnalyticId.
|
|
59
|
+
*/
|
|
60
|
+
function ensureAnalyticsRelayPing() {
|
|
61
|
+
if (typeof window === 'undefined' ||
|
|
62
|
+
window.parent === window ||
|
|
63
|
+
parentGtagReady) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
ensureRelayListener();
|
|
67
|
+
sendPingToParent();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Submit a gtag event if the gtag function is available.
|
|
71
|
+
* When running inside an iframe, only posts to parent after the parent has
|
|
72
|
+
* confirmed (via analyticsRelayOnInit) that gtag is available.
|
|
73
|
+
*/
|
|
74
|
+
const submitGtag = ({ event, metadata }) => {
|
|
75
|
+
const googleAnalyticSetting = zonosStore.checkoutSettings.analyticsProviders.find(item => item.type === 'GOOGLE_ANALYTICS');
|
|
76
|
+
// only submit if googleAnalytic in checkout setting is on.
|
|
77
|
+
if (!googleAnalyticSetting || (googleAnalyticSetting === null || googleAnalyticSetting === void 0 ? void 0 : googleAnalyticSetting.status) === 'DISABLED') {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const isTestMode = getIsTestMode();
|
|
81
|
+
const payload = Object.assign(Object.assign({}, metadata), (isTestMode && { isTestMode: true }));
|
|
82
|
+
// filter null key
|
|
83
|
+
const filteredPayload = Object.fromEntries(Object.entries(payload).filter(([_, value]) => value !== null));
|
|
84
|
+
const isInIframe = typeof window !== 'undefined' && window.parent !== window;
|
|
85
|
+
if (isInIframe) {
|
|
86
|
+
// gtag does not work in iframe; must relay to parent via postMessage
|
|
87
|
+
ensureRelayListener();
|
|
88
|
+
if (parentGtagReady) {
|
|
89
|
+
try {
|
|
90
|
+
window.parent.postMessage({
|
|
91
|
+
event,
|
|
92
|
+
metadata: filteredPayload,
|
|
93
|
+
type: ZONOS_ANALYTIC_TYPE,
|
|
94
|
+
}, '*');
|
|
95
|
+
}
|
|
96
|
+
catch (_a) {
|
|
97
|
+
// Ignore postMessage failures
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
queuedEvents.push({ event, payload: filteredPayload });
|
|
102
|
+
sendPingToParent();
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Not in iframe: call gtag directly
|
|
107
|
+
if (typeof window.gtag === 'function') {
|
|
108
|
+
log('Zonos submits gtag event', 'log', event);
|
|
109
|
+
window.gtag('event', event, filteredPayload);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { ensureAnalyticsRelayPing as e, submitGtag as s };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, c as createEvent, a as getElement } from './index-0bbe9693.js';
|
|
2
2
|
import { t as translate, l as localizationStore, s as storageStore, q as storageStoreOnChange } from './localization-853b48a9.js';
|
|
3
3
|
import { i as isTextContainsNonLatinChars, c as containsNonLatinChars } from './containsNonLatinChars-2d8810c3.js';
|
|
4
|
-
import { K as extractName, b as stripeStore, q as stripeStorePrefetchLandedCost, t as trackConversionEvent } from './cart-
|
|
4
|
+
import { K as extractName, b as stripeStore, q as stripeStorePrefetchLandedCost, t as trackConversionEvent } from './cart-ba8f3890.js';
|
|
5
5
|
import { c as classes } from './classes-0d95c529.js';
|
|
6
6
|
import { g as getBorderRadius } from './getBorderRadius-877f6389.js';
|
|
7
7
|
import { z as zonosStore, f as zonosStoreFontFamily } from './zonosStore-b434e436.js';
|