@suprsend/web-sdk 4.3.0 → 4.3.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/dist/es/index.js CHANGED
@@ -6,7 +6,7 @@ import L from "jwt-decode";
6
6
  import { createStore as G } from "zustand/vanilla";
7
7
  import { io as J } from "socket.io-client";
8
8
  var p = /* @__PURE__ */ ((i) => (i.OPT_IN = "opt_in", i.OPT_OUT = "opt_out", i))(p || {}), w = /* @__PURE__ */ ((i) => (i.ALL = "all", i.REQUIRED = "required", i))(w || {}), d = /* @__PURE__ */ ((i) => (i.VALIDATION_ERROR = "VALIDATION_ERROR", i.NETWORK_ERROR = "NETWORK_ERROR", i.UNKNOWN_ERROR = "UNKNOWN_ERROR", i.PERMISSION_DENIED = "PERMISSION_DENIED", i.UNSUPPORTED_ACTION = "UNSUPPORTED_ACTION", i.NOT_FOUND = "NOT_FOUND", i))(d || {}), a = /* @__PURE__ */ ((i) => (i.SUCCESS = "success", i.ERROR = "error", i))(a || {}), S = /* @__PURE__ */ ((i) => (i.INITIAL = "INITIAL", i.LOADING = "LOADING", i.SUCCESS = "SUCCESS", i.ERROR = "ERROR", i.FETCHING_MORE = "FETCHING_MORE", i))(S || {});
9
- const X = "@suprsend/web-sdk", Z = "4.3.0";
9
+ const X = "@suprsend/web-sdk", Z = "4.3.1";
10
10
  function D() {
11
11
  let i = (/* @__PURE__ */ new Date()).getTime();
12
12
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
@@ -936,10 +936,10 @@ class he {
936
936
  this.config = e;
937
937
  }
938
938
  async getPushSubscription() {
939
- if (!N()) return;
939
+ if (!N() || !("serviceWorker" in navigator)) return;
940
940
  const e = await navigator.serviceWorker.getRegistration();
941
941
  if (!e) return;
942
- const t = e.pushManager.getSubscription();
942
+ const t = await e.pushManager.getSubscription();
943
943
  if (t)
944
944
  return t;
945
945
  }
@@ -1596,7 +1596,8 @@ class be {
1596
1596
  W
1597
1597
  );
1598
1598
  if (s != null && s.refreshUserToken && this.handleRefreshUserToken(s.refreshUserToken), r == this.distinctId)
1599
- return this.webpush.updatePushSubscription(), o({ status: a.SUCCESS });
1599
+ return this.webpush.updatePushSubscription().catch(() => {
1600
+ }), o({ status: a.SUCCESS });
1600
1601
  let n;
1601
1602
  return (s == null ? void 0 : s.createUser) !== !1 ? n = await this.eventApi({
1602
1603
  event: "$identify",
@@ -1605,7 +1606,8 @@ class be {
1605
1606
  properties: {
1606
1607
  $identified_id: e
1607
1608
  }
1608
- }) : n = { status: a.SUCCESS }, n.status === a.SUCCESS ? (this.webpush.updatePushSubscription(), $(W, this.distinctId)) : this.reset({ unsubscribePush: !1 }), n;
1609
+ }) : n = { status: a.SUCCESS }, n.status === a.SUCCESS ? (this.webpush.updatePushSubscription().catch(() => {
1610
+ }), $(W, this.distinctId)) : this.reset({ unsubscribePush: !1 }), n;
1609
1611
  }
1610
1612
  /**
1611
1613
  * Check's if SuprSend instance is authenticated. To check if userToken is also present pass true.