@zonos/elements 1.2.4-alpha.4 → 1.2.4-alpha.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.
@@ -63,6 +63,8 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
63
63
  }
64
64
  _a.zonosApiKey = zonosApiKey;
65
65
  log('init zonos');
66
+ // add sentry to the project
67
+ _a.injectSentryScript();
66
68
  // inject zonos cdn
67
69
  _a.injectZonosCdn();
68
70
  // inject css for zonos elements
@@ -160,6 +162,56 @@ Zonos.injectController = ({ config, zonosApiKey, }) => {
160
162
  _a.zonosController = zonosController;
161
163
  log('Zonos controller injected!');
162
164
  };
165
+ Zonos.injectSentryScript = () => {
166
+ const scriptUrl = 'https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js';
167
+ const findScript = () => {
168
+ const script = document.querySelector(`script[src="${scriptUrl}"]`);
169
+ return !!script;
170
+ };
171
+ if (findScript()) {
172
+ // eslint-disable-next-line no-console
173
+ log('Sentry script already exists in the document', 'warn');
174
+ return;
175
+ }
176
+ const headOrBody = document.head || document.body;
177
+ // init zonos elements when the zonosKey is valid
178
+ // inject esmodule cdn for zonos elements
179
+ const script = document.createElement('script');
180
+ script.crossOrigin = 'anonymous';
181
+ script.src = scriptUrl;
182
+ script.integrity =
183
+ 'sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l';
184
+ script.setAttribute('data-lazy', 'no');
185
+ script.onerror = () => {
186
+ logError(`Failed to load ${script.src}`);
187
+ };
188
+ script.onload = () => {
189
+ var _b;
190
+ (_b = window.Sentry) === null || _b === void 0 ? void 0 : _b.init({
191
+ denyUrls: [
192
+ // Facebook flakiness
193
+ /graph\.facebook\.com/i,
194
+ // Facebook blocked
195
+ /connect\.facebook\.net\/en_US\/all\.js/i,
196
+ // Woopra flakiness
197
+ /eatdifferent\.com\.woopra-ns\.com/i,
198
+ /static\.woopra\.com\/js\/woopra\.js/i,
199
+ // Chrome extensions
200
+ /extensions\//i,
201
+ /^chrome:\/\//i,
202
+ /^chrome-extension:\/\//i,
203
+ // Other plugins
204
+ /webappstoolbarba\.texthelp\.com\//i,
205
+ /metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
206
+ /dev.elements.zonos.com/i,
207
+ /js.zonos.com/,
208
+ ],
209
+ dsn: 'https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760',
210
+ release: `zonos-elements@${_a.version}`,
211
+ });
212
+ };
213
+ headOrBody.appendChild(script);
214
+ };
163
215
  Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) => {
164
216
  const fullScriptUrl = `${scriptDomain}/${theRestUrl}`;
165
217
  const findScript = () => {
@@ -182,6 +234,7 @@ Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) =
182
234
  script.noModule = true;
183
235
  }
184
236
  script.src = fullScriptUrl;
237
+ script.crossOrigin = 'anonymous';
185
238
  script.onerror = () => {
186
239
  // only fallback if the stylesheetDomain is versioned. (https://v1.2.3.something.com || https://v1.something.com)
187
240
  const isVersioned = /\/\/v\d+\./g.test(scriptDomain);
@@ -198,8 +198,8 @@ const zonosQaUrl = (() => {
198
198
  });
199
199
  return fullUrl;
200
200
  })();
201
- const ZONOS_URL = zonosQaUrl || "https://v1.2.4-alpha.4.js.zonos.com";
202
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.4-alpha.4";
201
+ const ZONOS_URL = zonosQaUrl || "https://v1.2.4-alpha.5.js.zonos.com";
202
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.4-alpha.5";
203
203
  const INTER_FONT_URL = 'https://rsms.me';
204
204
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
205
205
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -212,7 +212,7 @@ Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
212
212
  Zonos.isBigCommerce = false;
213
213
  Zonos.internationalHideSelector = '';
214
214
  Zonos.zonosQaUrl = zonosQaUrl;
215
- Zonos.version = `v${"1.2.4-alpha.4"}`;
215
+ Zonos.version = `v${"1.2.4-alpha.5"}`;
216
216
  Zonos.modeAlerted = false;
217
217
  Zonos.getCurrentTimestamp = () => new Date().getTime();
218
218
  Zonos.zonosController = null;
@@ -228,6 +228,8 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
228
228
  }
229
229
  _a.zonosApiKey = zonosApiKey;
230
230
  log('init zonos');
231
+ // add sentry to the project
232
+ _a.injectSentryScript();
231
233
  // inject zonos cdn
232
234
  _a.injectZonosCdn();
233
235
  // inject css for zonos elements
@@ -325,6 +327,56 @@ Zonos.injectController = ({ config, zonosApiKey, }) => {
325
327
  _a.zonosController = zonosController;
326
328
  log('Zonos controller injected!');
327
329
  };
330
+ Zonos.injectSentryScript = () => {
331
+ const scriptUrl = 'https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js';
332
+ const findScript = () => {
333
+ const script = document.querySelector(`script[src="${scriptUrl}"]`);
334
+ return !!script;
335
+ };
336
+ if (findScript()) {
337
+ // eslint-disable-next-line no-console
338
+ log('Sentry script already exists in the document', 'warn');
339
+ return;
340
+ }
341
+ const headOrBody = document.head || document.body;
342
+ // init zonos elements when the zonosKey is valid
343
+ // inject esmodule cdn for zonos elements
344
+ const script = document.createElement('script');
345
+ script.crossOrigin = 'anonymous';
346
+ script.src = scriptUrl;
347
+ script.integrity =
348
+ 'sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l';
349
+ script.setAttribute('data-lazy', 'no');
350
+ script.onerror = () => {
351
+ logError(`Failed to load ${script.src}`);
352
+ };
353
+ script.onload = () => {
354
+ var _b;
355
+ (_b = window.Sentry) === null || _b === void 0 ? void 0 : _b.init({
356
+ denyUrls: [
357
+ // Facebook flakiness
358
+ /graph\.facebook\.com/i,
359
+ // Facebook blocked
360
+ /connect\.facebook\.net\/en_US\/all\.js/i,
361
+ // Woopra flakiness
362
+ /eatdifferent\.com\.woopra-ns\.com/i,
363
+ /static\.woopra\.com\/js\/woopra\.js/i,
364
+ // Chrome extensions
365
+ /extensions\//i,
366
+ /^chrome:\/\//i,
367
+ /^chrome-extension:\/\//i,
368
+ // Other plugins
369
+ /webappstoolbarba\.texthelp\.com\//i,
370
+ /metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
371
+ /dev.elements.zonos.com/i,
372
+ /js.zonos.com/,
373
+ ],
374
+ dsn: 'https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760',
375
+ release: `zonos-elements@${_a.version}`,
376
+ });
377
+ };
378
+ headOrBody.appendChild(script);
379
+ };
328
380
  Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) => {
329
381
  const fullScriptUrl = `${scriptDomain}/${theRestUrl}`;
330
382
  const findScript = () => {
@@ -347,6 +399,7 @@ Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) =
347
399
  script.noModule = true;
348
400
  }
349
401
  script.src = fullScriptUrl;
402
+ script.crossOrigin = 'anonymous';
350
403
  script.onerror = () => {
351
404
  // only fallback if the stylesheetDomain is versioned. (https://v1.2.3.something.com || https://v1.something.com)
352
405
  const isVersioned = /\/\/v\d+\./g.test(scriptDomain);
@@ -198,8 +198,8 @@ const zonosQaUrl = (() => {
198
198
  });
199
199
  return fullUrl;
200
200
  })();
201
- const ZONOS_URL = zonosQaUrl || "https://v1.2.4-alpha.4.js.zonos.com";
202
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.4-alpha.4";
201
+ const ZONOS_URL = zonosQaUrl || "https://v1.2.4-alpha.5.js.zonos.com";
202
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.2.4-alpha.5";
203
203
  const INTER_FONT_URL = 'https://rsms.me';
204
204
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
205
205
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -212,7 +212,7 @@ Zonos.debug = !!window.location.search.match(/\?.*(&*)zonosDebug=1/);
212
212
  Zonos.isBigCommerce = false;
213
213
  Zonos.internationalHideSelector = '';
214
214
  Zonos.zonosQaUrl = zonosQaUrl;
215
- Zonos.version = `v${"1.2.4-alpha.4"}`;
215
+ Zonos.version = `v${"1.2.4-alpha.5"}`;
216
216
  Zonos.modeAlerted = false;
217
217
  Zonos.getCurrentTimestamp = () => new Date().getTime();
218
218
  Zonos.zonosController = null;
@@ -228,6 +228,8 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
228
228
  }
229
229
  _a.zonosApiKey = zonosApiKey;
230
230
  log('init zonos');
231
+ // add sentry to the project
232
+ _a.injectSentryScript();
231
233
  // inject zonos cdn
232
234
  _a.injectZonosCdn();
233
235
  // inject css for zonos elements
@@ -325,6 +327,56 @@ Zonos.injectController = ({ config, zonosApiKey, }) => {
325
327
  _a.zonosController = zonosController;
326
328
  log('Zonos controller injected!');
327
329
  };
330
+ Zonos.injectSentryScript = () => {
331
+ const scriptUrl = 'https://browser.sentry-cdn.com/7.88.0/bundle.tracing.min.js';
332
+ const findScript = () => {
333
+ const script = document.querySelector(`script[src="${scriptUrl}"]`);
334
+ return !!script;
335
+ };
336
+ if (findScript()) {
337
+ // eslint-disable-next-line no-console
338
+ log('Sentry script already exists in the document', 'warn');
339
+ return;
340
+ }
341
+ const headOrBody = document.head || document.body;
342
+ // init zonos elements when the zonosKey is valid
343
+ // inject esmodule cdn for zonos elements
344
+ const script = document.createElement('script');
345
+ script.crossOrigin = 'anonymous';
346
+ script.src = scriptUrl;
347
+ script.integrity =
348
+ 'sha384-z/aQww1Fr6Mes0MO/2wlzQd2nXBCdDcKPXDTsMDMNPgTGRPqii3a4bzH79I+Vo8l';
349
+ script.setAttribute('data-lazy', 'no');
350
+ script.onerror = () => {
351
+ logError(`Failed to load ${script.src}`);
352
+ };
353
+ script.onload = () => {
354
+ var _b;
355
+ (_b = window.Sentry) === null || _b === void 0 ? void 0 : _b.init({
356
+ denyUrls: [
357
+ // Facebook flakiness
358
+ /graph\.facebook\.com/i,
359
+ // Facebook blocked
360
+ /connect\.facebook\.net\/en_US\/all\.js/i,
361
+ // Woopra flakiness
362
+ /eatdifferent\.com\.woopra-ns\.com/i,
363
+ /static\.woopra\.com\/js\/woopra\.js/i,
364
+ // Chrome extensions
365
+ /extensions\//i,
366
+ /^chrome:\/\//i,
367
+ /^chrome-extension:\/\//i,
368
+ // Other plugins
369
+ /webappstoolbarba\.texthelp\.com\//i,
370
+ /metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
371
+ /dev.elements.zonos.com/i,
372
+ /js.zonos.com/,
373
+ ],
374
+ dsn: 'https://19168bd05af0e2e0e7520ad58953e4f2@o446983.ingest.sentry.io/4506400622837760',
375
+ release: `zonos-elements@${_a.version}`,
376
+ });
377
+ };
378
+ headOrBody.appendChild(script);
379
+ };
328
380
  Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) => {
329
381
  const fullScriptUrl = `${scriptDomain}/${theRestUrl}`;
330
382
  const findScript = () => {
@@ -347,6 +399,7 @@ Zonos.injectScript = ({ fallBackDomain, isModule, scriptDomain, theRestUrl, }) =
347
399
  script.noModule = true;
348
400
  }
349
401
  script.src = fullScriptUrl;
402
+ script.crossOrigin = 'anonymous';
350
403
  script.onerror = () => {
351
404
  // only fallback if the stylesheetDomain is versioned. (https://v1.2.3.something.com || https://v1.something.com)
352
405
  const isVersioned = /\/\/v\d+\./g.test(scriptDomain);
@@ -53,6 +53,7 @@ export declare abstract class Zonos {
53
53
  static showNotification: (notification: NotificationInit) => void;
54
54
  private static disablePlaceOrderButtons;
55
55
  private static injectController;
56
+ private static injectSentryScript;
56
57
  private static injectScript;
57
58
  private static injectZonosCdn;
58
59
  private static injectStylesheet;
@@ -8,8 +8,20 @@ import type { Zonos } from '../scripts/zonos';
8
8
  declare global {
9
9
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
10
10
  interface Window {
11
+ Sentry?: {
12
+ init: (config: {
13
+ allowyUrls?: (string | RegExp)[];
14
+ denyUrls?: (string | RegExp)[];
15
+ dsn: string;
16
+ environment?: string;
17
+ integrations?: string[];
18
+ release: string;
19
+ tracesSampleRate?: number;
20
+ }) => void;
21
+ };
11
22
  Stripe?: StripeConstructor;
12
23
  Zonos: Zonos;
24
+ sentryOnLoad?: () => void;
13
25
  }
14
26
 
15
27
  namespace NodeJS {
@@ -1 +1 @@
1
- <svg color="var(--amino-red-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-red-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
1
+ <svg color="var(--amino-gray-800)" fill="none" height="24" viewBox="0 0 24 24" width="24" xmlns="https://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" data-is-secondary-color="true" fill="var(--amino-gray-200)" fill-rule="evenodd"></path><path clip-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" fill="currentColor" fill-rule="evenodd"></path></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonos/elements",
3
- "version": "1.2.4-alpha.4",
3
+ "version": "1.2.4-alpha.5",
4
4
  "description": "Zonos component UI for Stripe elements",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs.js",