@zonos/elements 1.3.46 → 1.3.47

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.
Files changed (86) hide show
  1. package/dist/cjs/{cart-7a79bccc.js → cart-85870c2e.js} +41 -19
  2. package/dist/cjs/{createCustomEvent-2fe80338.js → createCustomEvent-aacc2833.js} +1 -1
  3. package/dist/cjs/index.cjs.js +7 -6
  4. package/dist/cjs/{paypal-eb07e9f5.js → paypal-e4428dbf.js} +1 -1
  5. package/dist/cjs/zonos-address_8.cjs.entry.js +1 -1
  6. package/dist/cjs/zonos-cart-items_12.cjs.entry.js +3 -3
  7. package/dist/cjs/zonos-checkout.cjs.entry.js +3 -3
  8. package/dist/cjs/zonos-controller.cjs.entry.js +1 -1
  9. package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
  10. package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
  11. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
  12. package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
  13. package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
  14. package/dist/cjs/zonos-notification_3.cjs.entry.js +2 -2
  15. package/dist/collection/components/utils/handleFetch.js +14 -4
  16. package/dist/collection/components/utils/logging/sendErrorLog.js +14 -1
  17. package/dist/collection/environment.js +2 -0
  18. package/dist/collection/scripts/_zonosBase.js +1 -0
  19. package/dist/esm/{cart-2198741e.js → cart-3aae6236.js} +41 -19
  20. package/dist/esm/{createCustomEvent-451d7879.js → createCustomEvent-ccb20b48.js} +1 -1
  21. package/dist/esm/index.js +7 -6
  22. package/dist/esm/{paypal-2890968d.js → paypal-b1589e7b.js} +1 -1
  23. package/dist/esm/zonos-address_8.entry.js +1 -1
  24. package/dist/esm/zonos-cart-items_12.entry.js +3 -3
  25. package/dist/esm/zonos-checkout.entry.js +3 -3
  26. package/dist/esm/zonos-controller.entry.js +1 -1
  27. package/dist/esm/zonos-country-flag.entry.js +1 -1
  28. package/dist/esm/zonos-country-select_4.entry.js +1 -1
  29. package/dist/esm/zonos-hello-dialog.entry.js +1 -1
  30. package/dist/esm/zonos-hello.entry.js +1 -1
  31. package/dist/esm/zonos-language-select_2.entry.js +1 -1
  32. package/dist/esm/zonos-notification_3.entry.js +2 -2
  33. package/dist/esm-es5/{cart-2198741e.js → cart-3aae6236.js} +1 -1
  34. package/dist/esm-es5/{createCustomEvent-451d7879.js → createCustomEvent-ccb20b48.js} +1 -1
  35. package/dist/esm-es5/index.js +1 -1
  36. package/dist/esm-es5/{paypal-2890968d.js → paypal-b1589e7b.js} +1 -1
  37. package/dist/esm-es5/zonos-address_8.entry.js +1 -1
  38. package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
  39. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  40. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  41. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  42. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  43. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  44. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  45. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  46. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  47. package/dist/scripts/index.d.ts +8 -0
  48. package/dist/scripts/index.js +1 -1
  49. package/dist/scripts/loadZonos.js +1 -1
  50. package/dist/scripts/zonos.js +1 -1
  51. package/dist/types/components/utils/logging/sendErrorLog.d.ts +7 -1
  52. package/dist/types/environment.d.ts +4 -0
  53. package/dist/types/scripts/_zonosBase.d.ts +5 -0
  54. package/dist/zonos-elements/index.esm.js +1 -1
  55. package/dist/zonos-elements/{p-84e5636c.js → p-08a43211.js} +1 -1
  56. package/dist/zonos-elements/{p-52c2fb9d.entry.js → p-1738fe3f.entry.js} +1 -1
  57. package/dist/zonos-elements/{p-b06704a9.js → p-284520ae.js} +1 -1
  58. package/dist/zonos-elements/{p-40e8f3bd.entry.js → p-3225705b.entry.js} +1 -1
  59. package/dist/zonos-elements/{p-85b297d3.system.entry.js → p-3403a81a.system.entry.js} +1 -1
  60. package/dist/zonos-elements/{p-2f24a1f7.system.js → p-3fb9e320.system.js} +1 -1
  61. package/dist/zonos-elements/{p-7b9ed9ed.system.entry.js → p-3fd66f5b.system.entry.js} +1 -1
  62. package/dist/zonos-elements/{p-fb6c529a.entry.js → p-57c67bbf.entry.js} +1 -1
  63. package/dist/zonos-elements/{p-b066612a.system.entry.js → p-6d613cee.system.entry.js} +1 -1
  64. package/dist/zonos-elements/{p-8b2486b7.system.entry.js → p-7d0663ab.system.entry.js} +1 -1
  65. package/dist/zonos-elements/{p-a28492ca.system.entry.js → p-8949d4a2.system.entry.js} +1 -1
  66. package/dist/zonos-elements/{p-c3bb224b.entry.js → p-8b02985f.entry.js} +1 -1
  67. package/dist/zonos-elements/{p-467cdce8.system.entry.js → p-90935326.system.entry.js} +1 -1
  68. package/dist/zonos-elements/{p-e43bbfe1.entry.js → p-9c9e8288.entry.js} +1 -1
  69. package/dist/zonos-elements/{p-ac01a4fe.system.js → p-a576cbb8.system.js} +1 -1
  70. package/dist/zonos-elements/p-aa0127b3.system.js +1 -0
  71. package/dist/zonos-elements/{p-cfbcfd4b.entry.js → p-b9815df4.entry.js} +1 -1
  72. package/dist/zonos-elements/{p-ff10609a.system.entry.js → p-c035c64f.system.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-3b116246.system.entry.js → p-c3ca9e48.system.entry.js} +1 -1
  74. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  75. package/dist/zonos-elements/{p-65efc406.system.entry.js → p-d5741e4e.system.entry.js} +1 -1
  76. package/dist/zonos-elements/{p-6b868590.entry.js → p-d5b21512.entry.js} +1 -1
  77. package/dist/zonos-elements/{p-bfe85ef2.system.entry.js → p-e4033aa7.system.entry.js} +1 -1
  78. package/dist/zonos-elements/{p-e69e429d.entry.js → p-ea58a4a6.entry.js} +1 -1
  79. package/dist/zonos-elements/{p-791d240f.entry.js → p-ed496e98.entry.js} +1 -1
  80. package/dist/zonos-elements/p-eefeab02.js +1 -0
  81. package/dist/zonos-elements/{p-18f46c3f.entry.js → p-f25559fd.entry.js} +1 -1
  82. package/dist/zonos-elements/{p-f9aa9bd8.system.js → p-f9b50965.system.js} +1 -1
  83. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  84. package/package.json +1 -1
  85. package/dist/zonos-elements/p-2b25ac5e.system.js +0 -1
  86. package/dist/zonos-elements/p-f12c159e.js +0 -1
@@ -7192,7 +7192,34 @@ const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
7192
7192
  return nextFallbackApiType;
7193
7193
  };
7194
7194
 
7195
- const sendErrorLog = async ({ endpoint, errors, metadata }) => {
7195
+ const jsonParse = (_data) => {
7196
+ if (typeof _data === 'string') {
7197
+ try {
7198
+ // eslint-disable-next-line no-restricted-syntax
7199
+ const json = JSON.parse(_data);
7200
+ return json;
7201
+ }
7202
+ catch (_error) {
7203
+ return null;
7204
+ }
7205
+ }
7206
+ return null;
7207
+ };
7208
+
7209
+ /**
7210
+ * This is the time in milliseconds after release time that we will start sending error logs to the new API
7211
+ * @default 1 hour
7212
+ */
7213
+ const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
7214
+ const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
7215
+ if (shouldPostReleaseErrorReporting) {
7216
+ // We only want to report errors that happened if current time is less than 2 hours after release time
7217
+ const releaseTime = Number(window.Zonos.releaseDate);
7218
+ const currentTime = new Date().getTime();
7219
+ if (currentTime - releaseTime > postReleaseReportingDuration) {
7220
+ return;
7221
+ }
7222
+ }
7196
7223
  const userAgentData = 'userAgentData' in window.navigator
7197
7224
  ? // userAgentData is not yet supported in all browsers
7198
7225
  window.navigator.userAgentData
@@ -7339,27 +7366,36 @@ const handleRequest = async ({ basePathType, options, path, }) => {
7339
7366
  }
7340
7367
  };
7341
7368
  const handleRequestWithFallback = async ({ basePathType, options, path, }) => {
7342
- const _a = await handleRequest({
7369
+ var _a, _b;
7370
+ const _c = await handleRequest({
7343
7371
  basePathType,
7344
7372
  options,
7345
7373
  path,
7346
- }), { errors, response } = _a, rest = __rest(_a, ["errors", "response"]);
7374
+ }), { errors, response } = _c, rest = __rest(_c, ["errors", "response"]);
7347
7375
  const nextFallbackApiType = getNextFallbackApiType(basePathType);
7348
7376
  const unknownError = errors.find(({ type }) => type === 'unknown');
7377
+ const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
7349
7378
  const shouldCallFallback =
7350
7379
  // If next fallback is available, and the error is unknown (fail to fetch) or 404
7351
- nextFallbackApiType && (!!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404);
7352
- if (shouldCallFallback) {
7380
+ nextFallbackApiType && isUnknownError;
7381
+ // Should log the error if it's unknown error
7382
+ if (isUnknownError) {
7353
7383
  void sendErrorLog({
7354
7384
  endpoint: fallbackApiList[basePathType] + path,
7355
7385
  errors: errors.map(({ message }) => message),
7356
7386
  metadata: {
7357
7387
  currentBasePath: basePathType,
7358
7388
  nextFallbackApiType,
7389
+ requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
7390
+ requestPayload: jsonParse((_a = options === null || options === void 0 ? void 0 : options.body) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()),
7359
7391
  status: response === null || response === void 0 ? void 0 : response.status,
7360
7392
  statusText: response === null || response === void 0 ? void 0 : response.statusText,
7361
7393
  },
7394
+ // When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error. We should always report error for the last fallback API fails
7395
+ shouldPostReleaseErrorReporting: !!nextFallbackApiType,
7362
7396
  });
7397
+ }
7398
+ if (shouldCallFallback) {
7363
7399
  logError.log(`=== "${path}" failed to fetch, trying next fallback ${nextFallbackApiType}`);
7364
7400
  return handleRequestWithFallback({
7365
7401
  basePathType: nextFallbackApiType,
@@ -8183,20 +8219,6 @@ const buildTranslateRequestBody = ({ addressInvalidCharactersList, billingAddres
8183
8219
  };
8184
8220
  };
8185
8221
 
8186
- const jsonParse = (_data) => {
8187
- if (typeof _data === 'string') {
8188
- try {
8189
- // eslint-disable-next-line no-restricted-syntax
8190
- const json = JSON.parse(_data);
8191
- return json;
8192
- }
8193
- catch (_error) {
8194
- return null;
8195
- }
8196
- }
8197
- return null;
8198
- };
8199
-
8200
8222
  const addressRuleStyle = ({ theme, }) => {
8201
8223
  const defaultStyle = {
8202
8224
  '.AccordionItem': {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const cart = require('./cart-7a79bccc.js');
3
+ const cart = require('./cart-85870c2e.js');
4
4
  const zonosStore = require('./zonosStore-56401fdb.js');
5
5
 
6
6
  const trackConversionEvent = async (eventName, metadata) => {
@@ -94,7 +94,7 @@ const getZonosQaUrl = () => {
94
94
  return null;
95
95
  }
96
96
  const qaUrl = extractZonosQaUrl(window.location.href);
97
- const cdnUrl = "https://v1.3.46.js.zonos.com";
97
+ const cdnUrl = "https://v1.3.47.js.zonos.com";
98
98
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
99
99
  if (!qaUrl &&
100
100
  (cdnUrl.includes('test.') ||
@@ -268,10 +268,10 @@ const zonosLoadUrl = (() => {
268
268
  }
269
269
  return null;
270
270
  })();
271
- const ZONOS_URL = "https://v1.3.46.js.zonos.com";
272
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.46";
273
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.46";
274
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.46";
271
+ const ZONOS_URL = "https://v1.3.47.js.zonos.com";
272
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.47";
273
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.47";
274
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.47";
275
275
  const MAIN_LOAD_CDN_TYPE = 'jsdelivr';
276
276
  const INTER_FONT_URL = 'https://rsms.me';
277
277
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
@@ -287,12 +287,13 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
287
287
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
288
288
  Zonos._paypalMockResponse = null;
289
289
  Zonos.isBigCommerce = false;
290
+ Zonos.releaseDate = "1726091038924";
290
291
  /**
291
292
  * By default, the package will load from npm
292
293
  */
293
294
  Zonos.isNpm = true;
294
295
  Zonos.zonosQaUrl = null;
295
- Zonos.version = `v${"1.3.46"}`;
296
+ Zonos.version = `v${"1.3.47"}`;
296
297
  Zonos.modeAlerted = false;
297
298
  Zonos.tempCartData = null;
298
299
  Zonos.paypal = null;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const zonosStore = require('./zonosStore-56401fdb.js');
4
- const cart = require('./cart-7a79bccc.js');
4
+ const cart = require('./cart-85870c2e.js');
5
5
  const isDarkColor = require('./isDarkColor-4eb96a1e.js');
6
6
  const logError = require('./logError-4e2f2020.js');
7
7
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
8
8
  const logError = require('./logError-4e2f2020.js');
9
9
  const containsNonLatinChars = require('./containsNonLatinChars-2be5129b.js');
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const classes = require('./classes-b7918f56.js');
8
- const paypal = require('./paypal-eb07e9f5.js');
8
+ const paypal = require('./paypal-e4428dbf.js');
9
9
  const zonosStore = require('./zonosStore-56401fdb.js');
10
- const createCustomEvent = require('./createCustomEvent-2fe80338.js');
10
+ const createCustomEvent = require('./createCustomEvent-aacc2833.js');
11
11
  const getBorderRadius = require('./getBorderRadius-4413e191.js');
12
12
  const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
13
13
  const ILanguage = require('./ILanguage-98b04442.js');
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
7
- const paypal = require('./paypal-eb07e9f5.js');
6
+ const cart = require('./cart-85870c2e.js');
7
+ const paypal = require('./paypal-e4428dbf.js');
8
8
  const zonosStore = require('./zonosStore-56401fdb.js');
9
- const createCustomEvent = require('./createCustomEvent-2fe80338.js');
9
+ const createCustomEvent = require('./createCustomEvent-aacc2833.js');
10
10
  const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
11
11
  const logError = require('./logError-4e2f2020.js');
12
12
  const classes = require('./classes-b7918f56.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const zonosStore = require('./zonosStore-56401fdb.js');
8
8
  const logError = require('./logError-4e2f2020.js');
9
9
  require('./isDarkColor-4eb96a1e.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const zonosStore = require('./zonosStore-56401fdb.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  require('./logError-4e2f2020.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const zonosStore = require('./zonosStore-56401fdb.js');
8
8
  const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
9
9
  const isDarkColor = require('./isDarkColor-4eb96a1e.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const zonosStore = require('./zonosStore-56401fdb.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
6
  const zonosStore = require('./zonosStore-56401fdb.js');
7
- const cart = require('./cart-7a79bccc.js');
7
+ const cart = require('./cart-85870c2e.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  const logError = require('./logError-4e2f2020.js');
10
10
  const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-4c94667f.js');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-7a79bccc.js');
6
+ const cart = require('./cart-85870c2e.js');
7
7
  const zonosStore = require('./zonosStore-56401fdb.js');
8
8
  const ILanguage = require('./ILanguage-98b04442.js');
9
9
  require('./logError-4e2f2020.js');
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-d56e0a8b.js');
6
6
  const zonosStore = require('./zonosStore-56401fdb.js');
7
7
  const classes = require('./classes-b7918f56.js');
8
- const cart = require('./cart-7a79bccc.js');
8
+ const cart = require('./cart-85870c2e.js');
9
9
  const logError = require('./logError-4e2f2020.js');
10
- const paypal = require('./paypal-eb07e9f5.js');
10
+ const paypal = require('./paypal-e4428dbf.js');
11
11
  require('./isDarkColor-4eb96a1e.js');
12
12
  require('./getBorderRadius-4413e191.js');
13
13
 
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  import { fallbackApiList, getNextFallbackApiType, MAIN_BASE_API_TYPE, } from "./getNextFallbackApi";
14
+ import { jsonParse } from "./jsonParse";
14
15
  import { log } from "./logging/log";
15
16
  import { sendErrorLog } from "./logging/sendErrorLog";
16
17
  const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
@@ -117,27 +118,36 @@ const handleRequest = async ({ basePathType, options, path, }) => {
117
118
  }
118
119
  };
119
120
  const handleRequestWithFallback = async ({ basePathType, options, path, }) => {
120
- const _a = await handleRequest({
121
+ var _a, _b;
122
+ const _c = await handleRequest({
121
123
  basePathType,
122
124
  options,
123
125
  path,
124
- }), { errors, response } = _a, rest = __rest(_a, ["errors", "response"]);
126
+ }), { errors, response } = _c, rest = __rest(_c, ["errors", "response"]);
125
127
  const nextFallbackApiType = getNextFallbackApiType(basePathType);
126
128
  const unknownError = errors.find(({ type }) => type === 'unknown');
129
+ const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
127
130
  const shouldCallFallback =
128
131
  // If next fallback is available, and the error is unknown (fail to fetch) or 404
129
- nextFallbackApiType && (!!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404);
130
- if (shouldCallFallback) {
132
+ nextFallbackApiType && isUnknownError;
133
+ // Should log the error if it's unknown error
134
+ if (isUnknownError) {
131
135
  void sendErrorLog({
132
136
  endpoint: fallbackApiList[basePathType] + path,
133
137
  errors: errors.map(({ message }) => message),
134
138
  metadata: {
135
139
  currentBasePath: basePathType,
136
140
  nextFallbackApiType,
141
+ requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
142
+ requestPayload: jsonParse((_a = options === null || options === void 0 ? void 0 : options.body) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()),
137
143
  status: response === null || response === void 0 ? void 0 : response.status,
138
144
  statusText: response === null || response === void 0 ? void 0 : response.statusText,
139
145
  },
146
+ // When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error. We should always report error for the last fallback API fails
147
+ shouldPostReleaseErrorReporting: !!nextFallbackApiType,
140
148
  });
149
+ }
150
+ if (shouldCallFallback) {
141
151
  log(`=== "${path}" failed to fetch, trying next fallback ${nextFallbackApiType}`);
142
152
  return handleRequestWithFallback({
143
153
  basePathType: nextFallbackApiType,
@@ -1,5 +1,18 @@
1
1
  import { fallbackApiList, getNextFallbackApiType, MAIN_BASE_API, } from "../getNextFallbackApi";
2
- export const sendErrorLog = async ({ endpoint, errors, metadata }) => {
2
+ /**
3
+ * This is the time in milliseconds after release time that we will start sending error logs to the new API
4
+ * @default 1 hour
5
+ */
6
+ const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
7
+ export const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
8
+ if (shouldPostReleaseErrorReporting) {
9
+ // We only want to report errors that happened if current time is less than 2 hours after release time
10
+ const releaseTime = Number(window.Zonos.releaseDate);
11
+ const currentTime = new Date().getTime();
12
+ if (currentTime - releaseTime > postReleaseReportingDuration) {
13
+ return;
14
+ }
15
+ }
3
16
  const userAgentData = 'userAgentData' in window.navigator
4
17
  ? // userAgentData is not yet supported in all browsers
5
18
  window.navigator.userAgentData
@@ -50,6 +50,7 @@ else {
50
50
  }
51
51
  const envClient = {
52
52
  NEXT_PUBLIC_FLAG_URL: z.string(),
53
+ NEXT_PUBLIC_RELEASE_DATE: z.string(),
53
54
  NEXT_PUBLIC_ZONOS_API_KEY: z.string(),
54
55
  NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL: z.string(),
55
56
  NEXT_PUBLIC_ZONOS_CDN_URL: z.string(),
@@ -76,6 +77,7 @@ export const env = createEnv({
76
77
  // eslint-disable-next-line sort-keys/sort-keys-fix
77
78
  runtimeEnvStrict: {
78
79
  NEXT_PUBLIC_FLAG_URL: process.env.NEXT_PUBLIC_FLAG_URL,
80
+ NEXT_PUBLIC_RELEASE_DATE: new Date().getTime().toString(),
79
81
  NEXT_PUBLIC_ZONOS_API_KEY: process.env.NEXT_PUBLIC_ZONOS_API_KEY,
80
82
  NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL: CDNJS_ZONOS_URL,
81
83
  /**
@@ -40,6 +40,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
40
40
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
41
41
  Zonos._paypalMockResponse = null;
42
42
  Zonos.isBigCommerce = false;
43
+ Zonos.releaseDate = process.env.NEXT_PUBLIC_RELEASE_DATE;
43
44
  /**
44
45
  * By default, the package will load from npm
45
46
  */
@@ -7190,7 +7190,34 @@ const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
7190
7190
  return nextFallbackApiType;
7191
7191
  };
7192
7192
 
7193
- const sendErrorLog = async ({ endpoint, errors, metadata }) => {
7193
+ const jsonParse = (_data) => {
7194
+ if (typeof _data === 'string') {
7195
+ try {
7196
+ // eslint-disable-next-line no-restricted-syntax
7197
+ const json = JSON.parse(_data);
7198
+ return json;
7199
+ }
7200
+ catch (_error) {
7201
+ return null;
7202
+ }
7203
+ }
7204
+ return null;
7205
+ };
7206
+
7207
+ /**
7208
+ * This is the time in milliseconds after release time that we will start sending error logs to the new API
7209
+ * @default 1 hour
7210
+ */
7211
+ const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
7212
+ const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
7213
+ if (shouldPostReleaseErrorReporting) {
7214
+ // We only want to report errors that happened if current time is less than 2 hours after release time
7215
+ const releaseTime = Number(window.Zonos.releaseDate);
7216
+ const currentTime = new Date().getTime();
7217
+ if (currentTime - releaseTime > postReleaseReportingDuration) {
7218
+ return;
7219
+ }
7220
+ }
7194
7221
  const userAgentData = 'userAgentData' in window.navigator
7195
7222
  ? // userAgentData is not yet supported in all browsers
7196
7223
  window.navigator.userAgentData
@@ -7337,27 +7364,36 @@ const handleRequest = async ({ basePathType, options, path, }) => {
7337
7364
  }
7338
7365
  };
7339
7366
  const handleRequestWithFallback = async ({ basePathType, options, path, }) => {
7340
- const _a = await handleRequest({
7367
+ var _a, _b;
7368
+ const _c = await handleRequest({
7341
7369
  basePathType,
7342
7370
  options,
7343
7371
  path,
7344
- }), { errors, response } = _a, rest = __rest(_a, ["errors", "response"]);
7372
+ }), { errors, response } = _c, rest = __rest(_c, ["errors", "response"]);
7345
7373
  const nextFallbackApiType = getNextFallbackApiType(basePathType);
7346
7374
  const unknownError = errors.find(({ type }) => type === 'unknown');
7375
+ const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
7347
7376
  const shouldCallFallback =
7348
7377
  // If next fallback is available, and the error is unknown (fail to fetch) or 404
7349
- nextFallbackApiType && (!!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404);
7350
- if (shouldCallFallback) {
7378
+ nextFallbackApiType && isUnknownError;
7379
+ // Should log the error if it's unknown error
7380
+ if (isUnknownError) {
7351
7381
  void sendErrorLog({
7352
7382
  endpoint: fallbackApiList[basePathType] + path,
7353
7383
  errors: errors.map(({ message }) => message),
7354
7384
  metadata: {
7355
7385
  currentBasePath: basePathType,
7356
7386
  nextFallbackApiType,
7387
+ requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
7388
+ requestPayload: jsonParse((_a = options === null || options === void 0 ? void 0 : options.body) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()),
7357
7389
  status: response === null || response === void 0 ? void 0 : response.status,
7358
7390
  statusText: response === null || response === void 0 ? void 0 : response.statusText,
7359
7391
  },
7392
+ // When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error. We should always report error for the last fallback API fails
7393
+ shouldPostReleaseErrorReporting: !!nextFallbackApiType,
7360
7394
  });
7395
+ }
7396
+ if (shouldCallFallback) {
7361
7397
  log(`=== "${path}" failed to fetch, trying next fallback ${nextFallbackApiType}`);
7362
7398
  return handleRequestWithFallback({
7363
7399
  basePathType: nextFallbackApiType,
@@ -8181,20 +8217,6 @@ const buildTranslateRequestBody = ({ addressInvalidCharactersList, billingAddres
8181
8217
  };
8182
8218
  };
8183
8219
 
8184
- const jsonParse = (_data) => {
8185
- if (typeof _data === 'string') {
8186
- try {
8187
- // eslint-disable-next-line no-restricted-syntax
8188
- const json = JSON.parse(_data);
8189
- return json;
8190
- }
8191
- catch (_error) {
8192
- return null;
8193
- }
8194
- }
8195
- return null;
8196
- };
8197
-
8198
8220
  const addressRuleStyle = ({ theme, }) => {
8199
8221
  const defaultStyle = {
8200
8222
  '.AccordionItem': {
@@ -1,4 +1,4 @@
1
- import { x as handleFetch, e as cartStore, l as localizationStore } from './cart-2198741e.js';
1
+ import { x as handleFetch, e as cartStore, l as localizationStore } from './cart-3aae6236.js';
2
2
  import { z as zonosStore } from './zonosStore-8fc9ceb2.js';
3
3
 
4
4
  const trackConversionEvent = async (eventName, metadata) => {
package/dist/esm/index.js CHANGED
@@ -90,7 +90,7 @@ const getZonosQaUrl = () => {
90
90
  return null;
91
91
  }
92
92
  const qaUrl = extractZonosQaUrl(window.location.href);
93
- const cdnUrl = "https://v1.3.46.js.zonos.com";
93
+ const cdnUrl = "https://v1.3.47.js.zonos.com";
94
94
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
95
95
  if (!qaUrl &&
96
96
  (cdnUrl.includes('test.') ||
@@ -264,10 +264,10 @@ const zonosLoadUrl = (() => {
264
264
  }
265
265
  return null;
266
266
  })();
267
- const ZONOS_URL = "https://v1.3.46.js.zonos.com";
268
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.46";
269
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.46";
270
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.46";
267
+ const ZONOS_URL = "https://v1.3.47.js.zonos.com";
268
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.47";
269
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.47";
270
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.47";
271
271
  const MAIN_LOAD_CDN_TYPE = 'jsdelivr';
272
272
  const INTER_FONT_URL = 'https://rsms.me';
273
273
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
@@ -283,12 +283,13 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
283
283
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
284
284
  Zonos._paypalMockResponse = null;
285
285
  Zonos.isBigCommerce = false;
286
+ Zonos.releaseDate = "1726091038924";
286
287
  /**
287
288
  * By default, the package will load from npm
288
289
  */
289
290
  Zonos.isNpm = true;
290
291
  Zonos.zonosQaUrl = null;
291
- Zonos.version = `v${"1.3.46"}`;
292
+ Zonos.version = `v${"1.3.47"}`;
292
293
  Zonos.modeAlerted = false;
293
294
  Zonos.tempCartData = null;
294
295
  Zonos.paypal = null;
@@ -1,5 +1,5 @@
1
1
  import { z as zonosStore, c as createStore } from './zonosStore-8fc9ceb2.js';
2
- import { x as handleFetch, e as cartStore, r as stripeStoreHandleInventoryCheck, t as translate, q as cartStoreNextStep, j as cartStoreClearCheckoutInterval, y as jsonParse } from './cart-2198741e.js';
2
+ import { x as handleFetch, e as cartStore, r as stripeStoreHandleInventoryCheck, t as translate, q as cartStoreNextStep, j as cartStoreClearCheckoutInterval, y as jsonParse } from './cart-3aae6236.js';
3
3
  import { t as tinycolor } from './isDarkColor-3119e351.js';
4
4
  import { l as log, a as logError } from './logError-c456c092.js';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, d as getElement } from './index-86b8247e.js';
2
- import { k as stripeStore, l as localizationStore, t as translate } from './cart-2198741e.js';
2
+ import { k as stripeStore, l as localizationStore, t as translate } from './cart-3aae6236.js';
3
3
  import { i as isCheckoutMobile } from './isCheckoutMobile-8846dccb.js';
4
4
  import { a as logError } from './logError-c456c092.js';
5
5
  import { i as isTextContainsNonLatinChars, c as containsNonLatinChars } from './containsNonLatinChars-2d8810c3.js';
@@ -1,9 +1,9 @@
1
1
  import { r as registerInstance, a as getAssetPath, h, H as Host, F as Fragment, c as createEvent, d as getElement } from './index-86b8247e.js';
2
- import { e as cartStore, G as currencyFormat, H as cartStoreHasOneEligibleItem, t as translate, x as handleFetch, v as stripeStoreReset, c as sendErrorLog, k as stripeStore, I as stripeStoreRetrievePayment, J as stripeStoreMessageBasedOnStatus, l as localizationStore, K as stripeStoreTranslateAddressToLatin, L as cartStoreUpdateSelectedShippingOption, M as cartStoreGetShippingTransitInfo } from './cart-2198741e.js';
2
+ import { e as cartStore, G as currencyFormat, H as cartStoreHasOneEligibleItem, t as translate, x as handleFetch, v as stripeStoreReset, c as sendErrorLog, k as stripeStore, I as stripeStoreRetrievePayment, J as stripeStoreMessageBasedOnStatus, l as localizationStore, K as stripeStoreTranslateAddressToLatin, L as cartStoreUpdateSelectedShippingOption, M as cartStoreGetShippingTransitInfo } from './cart-3aae6236.js';
3
3
  import { c as classes } from './classes-0d95c529.js';
4
- import { s as submitGtag, a as paypalStore, b as paypalStoreReset, c as paypalStoreHasPaypalEnabled, i as isContrastColor } from './paypal-2890968d.js';
4
+ import { s as submitGtag, a as paypalStore, b as paypalStoreReset, c as paypalStoreHasPaypalEnabled, i as isContrastColor } from './paypal-b1589e7b.js';
5
5
  import { z as zonosStore, g as getZonosStoreTheme, d as zonosStoreFontFamily } from './zonosStore-8fc9ceb2.js';
6
- import { t as trackConversionEvent, c as createCustomEvent, g as getIsTestMode } from './createCustomEvent-451d7879.js';
6
+ import { t as trackConversionEvent, c as createCustomEvent, g as getIsTestMode } from './createCustomEvent-ccb20b48.js';
7
7
  import { g as getBorderRadius } from './getBorderRadius-3ba98361.js';
8
8
  import { i as isCheckoutMobile } from './isCheckoutMobile-8846dccb.js';
9
9
  import { l as languages } from './ILanguage-cd6acb72.js';
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, h, H as Host, F as Fragment } from './index-86b8247e.js';
2
- import { l as localizationStore, s as stripeStoreGetDomesticShippingSession, a as localizationStoreUpdateSelectedCountryCode, b as stripeStoreCleanupDomesticShippingSession, c as sendErrorLog, d as stripeStoreSaveDomesticShippingSession, i as initStripeElements, e as cartStore, f as cartStoreUpdateItems, g as cartStoreReset, h as cartStoreResetTabItems, j as cartStoreClearCheckoutInterval, k as stripeStore, m as stripeStoreInitCheckoutSession, n as cartStoreStartCheckoutInterval, o as cartStoreUpdateToErrorState, t as translate, p as stripeStorePrefetchLandedCost, q as cartStoreNextStep, r as stripeStoreHandleInventoryCheck, u as stripeStoreConfirmPayment, v as stripeStoreReset, w as localizationStoreOnUpdate } from './cart-2198741e.js';
3
- import { s as submitGtag, p as paypalInitScript } from './paypal-2890968d.js';
2
+ import { l as localizationStore, s as stripeStoreGetDomesticShippingSession, a as localizationStoreUpdateSelectedCountryCode, b as stripeStoreCleanupDomesticShippingSession, c as sendErrorLog, d as stripeStoreSaveDomesticShippingSession, i as initStripeElements, e as cartStore, f as cartStoreUpdateItems, g as cartStoreReset, h as cartStoreResetTabItems, j as cartStoreClearCheckoutInterval, k as stripeStore, m as stripeStoreInitCheckoutSession, n as cartStoreStartCheckoutInterval, o as cartStoreUpdateToErrorState, t as translate, p as stripeStorePrefetchLandedCost, q as cartStoreNextStep, r as stripeStoreHandleInventoryCheck, u as stripeStoreConfirmPayment, v as stripeStoreReset, w as localizationStoreOnUpdate } from './cart-3aae6236.js';
3
+ import { s as submitGtag, p as paypalInitScript } from './paypal-b1589e7b.js';
4
4
  import { z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-8fc9ceb2.js';
5
- import { c as createCustomEvent, t as trackConversionEvent, g as getIsTestMode } from './createCustomEvent-451d7879.js';
5
+ import { c as createCustomEvent, t as trackConversionEvent, g as getIsTestMode } from './createCustomEvent-ccb20b48.js';
6
6
  import { i as isCheckoutMobile } from './isCheckoutMobile-8846dccb.js';
7
7
  import { l as log, a as logError } from './logError-c456c092.js';
8
8
  import { c as classes } from './classes-0d95c529.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host } from './index-86b8247e.js';
2
- import { x as handleFetch, z as isValidSelector, k as stripeStore, A as initLocalizationStore, e as cartStore, a as localizationStoreUpdateSelectedCountryCode } from './cart-2198741e.js';
2
+ import { x as handleFetch, z as isValidSelector, k as stripeStore, A as initLocalizationStore, e as cartStore, a as localizationStoreUpdateSelectedCountryCode } from './cart-3aae6236.js';
3
3
  import { z as zonosStore, b as zonosStoreInitSetting, d as zonosStoreFontFamily } from './zonosStore-8fc9ceb2.js';
4
4
  import { a as logError, l as log } from './logError-c456c092.js';
5
5
  import './isDarkColor-3119e351.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-86b8247e.js';
2
- import { l as localizationStore } from './cart-2198741e.js';
2
+ import { l as localizationStore } from './cart-3aae6236.js';
3
3
  import { d as zonosStoreFontFamily } from './zonosStore-8fc9ceb2.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import './logError-c456c092.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement } from './index-86b8247e.js';
2
- import { a as localizationStoreUpdateSelectedCountryCode, t as translate, l as localizationStore } from './cart-2198741e.js';
2
+ import { a as localizationStoreUpdateSelectedCountryCode, t as translate, l as localizationStore } from './cart-3aae6236.js';
3
3
  import { d as zonosStoreFontFamily } from './zonosStore-8fc9ceb2.js';
4
4
  import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
5
5
  import { i as isDarkColor } from './isDarkColor-3119e351.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, F as Fragment, H as Host } from './index-86b8247e.js';
2
- import { t as translate, l as localizationStore, G as currencyFormat } from './cart-2198741e.js';
2
+ import { t as translate, l as localizationStore, G as currencyFormat } from './cart-3aae6236.js';
3
3
  import { z as zonosStore } from './zonosStore-8fc9ceb2.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-86b8247e.js';
2
2
  import { _ as _root, e as _baseGetTag, i as isObjectLike_1, f as isObject_1, z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-8fc9ceb2.js';
3
- import { x as handleFetch, l as localizationStore, z as isValidSelector, t as translate, B as getZCountryUrlParam, C as setZCountryUrlParam, D as currencyDisplay, E as currencyConvertAndFormat, F as currencyConvert, G as currencyFormat } from './cart-2198741e.js';
3
+ import { x as handleFetch, l as localizationStore, z as isValidSelector, t as translate, B as getZCountryUrlParam, C as setZCountryUrlParam, D as currencyDisplay, E as currencyConvertAndFormat, F as currencyConvert, G as currencyFormat } from './cart-3aae6236.js';
4
4
  import { c as classes } from './classes-0d95c529.js';
5
5
  import { a as logError, l as log } from './logError-c456c092.js';
6
6
  import { g as getHasMoreSpaceOnRight } from './getHasMoreSpaceOnRight-70eb913a.js';
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-86b8247e.js';
2
- import { N as localizationStoreUpdateSelectedLocale, t as translate, l as localizationStore } from './cart-2198741e.js';
2
+ import { N as localizationStoreUpdateSelectedLocale, t as translate, l as localizationStore } from './cart-3aae6236.js';
3
3
  import { d as zonosStoreFontFamily } from './zonosStore-8fc9ceb2.js';
4
4
  import { l as languages } from './ILanguage-cd6acb72.js';
5
5
  import './logError-c456c092.js';
@@ -1,9 +1,9 @@
1
1
  import { r as registerInstance, h, H as Host, d as getElement, c as createEvent } from './index-86b8247e.js';
2
2
  import { d as zonosStoreFontFamily } from './zonosStore-8fc9ceb2.js';
3
3
  import { c as classes } from './classes-0d95c529.js';
4
- import { k as stripeStore } from './cart-2198741e.js';
4
+ import { k as stripeStore } from './cart-3aae6236.js';
5
5
  import { a as logError, l as log } from './logError-c456c092.js';
6
- import { d as paypalStoreInitButtons } from './paypal-2890968d.js';
6
+ import { d as paypalStoreInitButtons } from './paypal-b1589e7b.js';
7
7
  import './isDarkColor-3119e351.js';
8
8
  import './getBorderRadius-3ba98361.js';
9
9