@blotoutio/providers-blotout-wallet-sdk 0.59.0 → 0.60.1

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/index.cjs.js CHANGED
@@ -429,6 +429,11 @@ const circleCross = (attrs) => b `<svg class=${attrs === null || attrs === void
429
429
  * Sets the max-age for the dismissed popup cookie
430
430
  */
431
431
  const DISMISSED_COOKIE_LIFETIME = 1800;
432
+ /**
433
+ * The delay applied when the page becomes visible before fetching expired carts
434
+ * and possibly displaying the popup
435
+ */
436
+ const POPUP_IMPRESSION_DELAY = 1000;
432
437
  const formatString = (str) => {
433
438
  const parts = str.split(/<\s*br\s*\/?\s*>/);
434
439
  return o(parts, x `<br />`);
@@ -467,7 +472,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
467
472
  this.email.value = '';
468
473
  this.hasEmail = true;
469
474
  this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
470
- window.edgetag('tag', 'WalletEmailSaved', {}, {}, { destination: this.edgeURL });
475
+ window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
471
476
  }
472
477
  if (this.lastExpiredCart) {
473
478
  await this.storeApi.addItems(this.lastExpiredCart.items);
@@ -491,7 +496,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
491
496
  throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
492
497
  }
493
498
  // Send the request as beacon as there could be a immediate redirect in the next step
494
- window.edgetag('tag', 'WalletCartRestored', {}, {}, { method: 'beacon' });
499
+ window.edgetag('tag', 'CartRecovery_CartRestored', {}, {}, { method: 'beacon' });
495
500
  // Redirect to custom path
496
501
  if (this.restoreRedirect) {
497
502
  try {
@@ -617,6 +622,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
617
622
  this.shadowRoot.adoptedStyleSheets.push(sheet);
618
623
  this.isStylesheetInjected = true;
619
624
  }
625
+ if (document.hidden) {
626
+ document.addEventListener('visibilitychange', () => this.initialize(), {
627
+ once: true,
628
+ });
629
+ }
630
+ else {
631
+ this.initialize();
632
+ }
633
+ }
634
+ async initialize() {
620
635
  if (!this.userId) {
621
636
  logger.error('No UserId set');
622
637
  return;
@@ -624,6 +639,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
624
639
  if (this.isPopUpDismissed) {
625
640
  return;
626
641
  }
642
+ await delay(POPUP_IMPRESSION_DELAY);
627
643
  fetch(this.getUrl('/cart/expired'), {
628
644
  method: 'GET',
629
645
  headers: this.getHeaders(),
@@ -637,10 +653,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
637
653
  this.hasEmail = result.email;
638
654
  this.lastExpiredCart = result.carts[0];
639
655
  if (result.carts && result.carts.length && !this.isPopUpDismissed) {
640
- setTimeout(() => {
641
- this.showModal();
642
- }, 1000);
643
- window.edgetag('tag', 'WalletCartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
656
+ this.showModal();
657
+ window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
644
658
  }
645
659
  })
646
660
  .catch(logger.error);
@@ -686,7 +700,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
686
700
  if (!response.ok) {
687
701
  throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
688
702
  }
689
- window.edgetag('tag', 'WalletCartDeclined', {}, {}, { destination: this.edgeURL });
703
+ window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
690
704
  this.lastExpiredCart = undefined;
691
705
  })
692
706
  .catch(logger.error);
package/index.js CHANGED
@@ -430,6 +430,11 @@ var ProvidersBlotoutWalletSdk = (function () {
430
430
  * Sets the max-age for the dismissed popup cookie
431
431
  */
432
432
  const DISMISSED_COOKIE_LIFETIME = 1800;
433
+ /**
434
+ * The delay applied when the page becomes visible before fetching expired carts
435
+ * and possibly displaying the popup
436
+ */
437
+ const POPUP_IMPRESSION_DELAY = 1000;
433
438
  const formatString = (str) => {
434
439
  const parts = str.split(/<\s*br\s*\/?\s*>/);
435
440
  return o(parts, x `<br />`);
@@ -468,7 +473,7 @@ var ProvidersBlotoutWalletSdk = (function () {
468
473
  this.email.value = '';
469
474
  this.hasEmail = true;
470
475
  this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
471
- window.edgetag('tag', 'WalletEmailSaved', {}, {}, { destination: this.edgeURL });
476
+ window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
472
477
  }
473
478
  if (this.lastExpiredCart) {
474
479
  await this.storeApi.addItems(this.lastExpiredCart.items);
@@ -492,7 +497,7 @@ var ProvidersBlotoutWalletSdk = (function () {
492
497
  throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
493
498
  }
494
499
  // Send the request as beacon as there could be a immediate redirect in the next step
495
- window.edgetag('tag', 'WalletCartRestored', {}, {}, { method: 'beacon' });
500
+ window.edgetag('tag', 'CartRecovery_CartRestored', {}, {}, { method: 'beacon' });
496
501
  // Redirect to custom path
497
502
  if (this.restoreRedirect) {
498
503
  try {
@@ -618,6 +623,16 @@ var ProvidersBlotoutWalletSdk = (function () {
618
623
  this.shadowRoot.adoptedStyleSheets.push(sheet);
619
624
  this.isStylesheetInjected = true;
620
625
  }
626
+ if (document.hidden) {
627
+ document.addEventListener('visibilitychange', () => this.initialize(), {
628
+ once: true,
629
+ });
630
+ }
631
+ else {
632
+ this.initialize();
633
+ }
634
+ }
635
+ async initialize() {
621
636
  if (!this.userId) {
622
637
  logger.error('No UserId set');
623
638
  return;
@@ -625,6 +640,7 @@ var ProvidersBlotoutWalletSdk = (function () {
625
640
  if (this.isPopUpDismissed) {
626
641
  return;
627
642
  }
643
+ await delay(POPUP_IMPRESSION_DELAY);
628
644
  fetch(this.getUrl('/cart/expired'), {
629
645
  method: 'GET',
630
646
  headers: this.getHeaders(),
@@ -638,10 +654,8 @@ var ProvidersBlotoutWalletSdk = (function () {
638
654
  this.hasEmail = result.email;
639
655
  this.lastExpiredCart = result.carts[0];
640
656
  if (result.carts && result.carts.length && !this.isPopUpDismissed) {
641
- setTimeout(() => {
642
- this.showModal();
643
- }, 1000);
644
- window.edgetag('tag', 'WalletCartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
657
+ this.showModal();
658
+ window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
645
659
  }
646
660
  })
647
661
  .catch(logger.error);
@@ -687,7 +701,7 @@ var ProvidersBlotoutWalletSdk = (function () {
687
701
  if (!response.ok) {
688
702
  throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
689
703
  }
690
- window.edgetag('tag', 'WalletCartDeclined', {}, {}, { destination: this.edgeURL });
704
+ window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
691
705
  this.lastExpiredCart = undefined;
692
706
  })
693
707
  .catch(logger.error);
package/index.mjs CHANGED
@@ -427,6 +427,11 @@ const circleCross = (attrs) => b `<svg class=${attrs === null || attrs === void
427
427
  * Sets the max-age for the dismissed popup cookie
428
428
  */
429
429
  const DISMISSED_COOKIE_LIFETIME = 1800;
430
+ /**
431
+ * The delay applied when the page becomes visible before fetching expired carts
432
+ * and possibly displaying the popup
433
+ */
434
+ const POPUP_IMPRESSION_DELAY = 1000;
430
435
  const formatString = (str) => {
431
436
  const parts = str.split(/<\s*br\s*\/?\s*>/);
432
437
  return o(parts, x `<br />`);
@@ -465,7 +470,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
465
470
  this.email.value = '';
466
471
  this.hasEmail = true;
467
472
  this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
468
- window.edgetag('tag', 'WalletEmailSaved', {}, {}, { destination: this.edgeURL });
473
+ window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
469
474
  }
470
475
  if (this.lastExpiredCart) {
471
476
  await this.storeApi.addItems(this.lastExpiredCart.items);
@@ -489,7 +494,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
489
494
  throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
490
495
  }
491
496
  // Send the request as beacon as there could be a immediate redirect in the next step
492
- window.edgetag('tag', 'WalletCartRestored', {}, {}, { method: 'beacon' });
497
+ window.edgetag('tag', 'CartRecovery_CartRestored', {}, {}, { method: 'beacon' });
493
498
  // Redirect to custom path
494
499
  if (this.restoreRedirect) {
495
500
  try {
@@ -615,6 +620,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
615
620
  this.shadowRoot.adoptedStyleSheets.push(sheet);
616
621
  this.isStylesheetInjected = true;
617
622
  }
623
+ if (document.hidden) {
624
+ document.addEventListener('visibilitychange', () => this.initialize(), {
625
+ once: true,
626
+ });
627
+ }
628
+ else {
629
+ this.initialize();
630
+ }
631
+ }
632
+ async initialize() {
618
633
  if (!this.userId) {
619
634
  logger.error('No UserId set');
620
635
  return;
@@ -622,6 +637,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
622
637
  if (this.isPopUpDismissed) {
623
638
  return;
624
639
  }
640
+ await delay(POPUP_IMPRESSION_DELAY);
625
641
  fetch(this.getUrl('/cart/expired'), {
626
642
  method: 'GET',
627
643
  headers: this.getHeaders(),
@@ -635,10 +651,8 @@ let BlotoutWallet = class BlotoutWallet extends s {
635
651
  this.hasEmail = result.email;
636
652
  this.lastExpiredCart = result.carts[0];
637
653
  if (result.carts && result.carts.length && !this.isPopUpDismissed) {
638
- setTimeout(() => {
639
- this.showModal();
640
- }, 1000);
641
- window.edgetag('tag', 'WalletCartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
654
+ this.showModal();
655
+ window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
642
656
  }
643
657
  })
644
658
  .catch(logger.error);
@@ -684,7 +698,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
684
698
  if (!response.ok) {
685
699
  throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
686
700
  }
687
- window.edgetag('tag', 'WalletCartDeclined', {}, {}, { destination: this.edgeURL });
701
+ window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
688
702
  this.lastExpiredCart = undefined;
689
703
  })
690
704
  .catch(logger.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-blotout-wallet-sdk",
3
- "version": "0.59.0",
3
+ "version": "0.60.1",
4
4
  "description": "Blotout Wallet SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",