@braze/web-sdk 4.6.2 → 4.7.0

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 (97) hide show
  1. package/index.d.ts +13 -8
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +2 -2
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +18 -17
  6. package/shared-lib/indexed-db-adapter.js +2 -2
  7. package/shared-lib/logger.js +2 -2
  8. package/shared-lib/supported-options.js +15 -15
  9. package/src/Core/handle-braze-action.js +40 -34
  10. package/src/Core/log-custom-event.js +2 -7
  11. package/src/Core/log-purchase.js +3 -3
  12. package/src/Core/wipe-data.js +2 -2
  13. package/src/FeatureFlags/feature-flag.js +33 -16
  14. package/src/FeatureFlags/feature-flags-provider.js +86 -75
  15. package/src/FeatureFlags/get-all-feature-flags.js +5 -5
  16. package/src/FeatureFlags/get-feature-flag.js +6 -6
  17. package/src/FeatureFlags/refresh-feature-flags.js +1 -1
  18. package/src/FeatureFlags/types.js +1 -0
  19. package/src/Feed/feed-provider.js +17 -17
  20. package/src/Feed/get-cached-feed.js +1 -1
  21. package/src/Feed/ui/show-feed.js +1 -1
  22. package/src/InAppMessage/display/html-message-to-html.js +135 -120
  23. package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
  24. package/src/InAppMessage/display/modal-utils.js +6 -6
  25. package/src/InAppMessage/in-app-message-factory.js +3 -3
  26. package/src/InAppMessage/in-app-message-manager-factory.js +3 -3
  27. package/src/InAppMessage/in-app-message-manager.js +65 -65
  28. package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
  29. package/src/InAppMessage/log-in-app-message-click.js +4 -4
  30. package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
  31. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  32. package/src/InAppMessage/models/full-screen-message.js +1 -1
  33. package/src/InAppMessage/models/html-message.js +1 -1
  34. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  35. package/src/InAppMessage/models/in-app-message.js +80 -80
  36. package/src/InAppMessage/models/modal-message.js +2 -2
  37. package/src/InAppMessage/models/slide-up-message.js +8 -8
  38. package/src/InAppMessage/models/templated-in-app-message.js +4 -4
  39. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  40. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  41. package/src/InAppMessage/ui/show-in-app-message.js +20 -20
  42. package/src/Push/push-manager.js +216 -209
  43. package/src/Push/utils/push-utils.js +4 -4
  44. package/src/User/user-manager.js +11 -8
  45. package/src/User/user.js +52 -41
  46. package/src/common/base-feed.js +1 -1
  47. package/src/common/base-provider.js +1 -1
  48. package/src/common/constants.js +2 -0
  49. package/src/common/feed-display.js +6 -6
  50. package/src/l10n/l10n-manager-factory.js +1 -1
  51. package/src/managers/auth-manager.js +24 -24
  52. package/src/managers/braze-instance.js +120 -120
  53. package/src/managers/device-manager.js +11 -11
  54. package/src/managers/network-manager.js +63 -54
  55. package/src/managers/server-config-manager.js +20 -20
  56. package/src/managers/session-manager.js +29 -29
  57. package/src/managers/storage-manager-factory.js +4 -4
  58. package/src/managers/storage-manager.js +104 -104
  59. package/src/managers/subscription-manager.js +6 -6
  60. package/src/models/backend-errors.js +5 -5
  61. package/src/models/braze-event.js +7 -7
  62. package/src/models/device.js +1 -1
  63. package/src/models/identifier.js +6 -6
  64. package/src/models/push-token.js +3 -3
  65. package/src/models/server-config.js +15 -15
  66. package/src/request-controller.js +92 -88
  67. package/src/triggers/models/custom-event-data.js +4 -4
  68. package/src/triggers/models/custom-event-property-data.js +9 -9
  69. package/src/triggers/models/filter-set.js +9 -9
  70. package/src/triggers/models/filter.js +63 -63
  71. package/src/triggers/models/in-app-message-click-data.js +5 -5
  72. package/src/triggers/models/purchase-data.js +3 -3
  73. package/src/triggers/models/purchase-property-data.js +9 -9
  74. package/src/triggers/models/push-click-data.js +5 -5
  75. package/src/triggers/models/trigger-condition.js +48 -48
  76. package/src/triggers/models/trigger-events.js +1 -1
  77. package/src/triggers/models/trigger.js +29 -29
  78. package/src/triggers/triggers-provider-factory.js +2 -2
  79. package/src/triggers/triggers-provider.js +87 -89
  80. package/src/ui/js/attach-css.js +1 -1
  81. package/src/ui/js/feed-css.js +4 -4
  82. package/src/ui/js/iam-css.js +4 -4
  83. package/src/ui/js/load-font-awesome.js +1 -1
  84. package/src/util/base-device-parser.js +2 -2
  85. package/src/util/braze-actions.js +8 -8
  86. package/src/util/browser-detector.js +8 -8
  87. package/src/util/client-hints-parser.js +3 -3
  88. package/src/util/code-utils.js +10 -3
  89. package/src/util/component-utils.js +1 -1
  90. package/src/util/date-utils.js +2 -2
  91. package/src/util/device-constants.js +1 -1
  92. package/src/util/dom-utils.js +9 -9
  93. package/src/util/key-codes.js +1 -1
  94. package/src/util/net.js +3 -3
  95. package/src/util/user-agent-parser.js +4 -4
  96. package/src/util/validation-utils.js +155 -74
  97. package/src/util/window-utils.js +1 -1
@@ -6,28 +6,28 @@ import { User } from "../User/index.js";
6
6
  import { WindowUtils as H } from "../util/window-utils.js";
7
7
  import dt from "./utils/push-utils.js";
8
8
  export default class aa {
9
- constructor(i, e, t, s, r, n, o, u, a, h) {
9
+ constructor(i, e, t, s, r, n, o, u, a, c) {
10
10
  (this.Sr = i),
11
11
  (this._r = e),
12
12
  (this.Ur = t),
13
13
  (this.Wr = s + "/safari/" + e),
14
- (this.Nr = r || "/service-worker.js"),
15
- (this.Ir = n),
14
+ (this.Vr = r || "/service-worker.js"),
15
+ (this.Or = n),
16
16
  (this.gt = o),
17
- (this.Vr = u || !1),
18
- (this.Or = a || !1),
19
- (this.h = h),
20
- (this.Mr = dt.Yr()),
21
- (this.Gr = dt.Hr());
17
+ (this.Yr = u || !1),
18
+ (this.Gr = a || !1),
19
+ (this.h = c),
20
+ (this.Hr = dt.Jr()),
21
+ (this.Kr = dt.Lr());
22
22
  }
23
- Jr() {
24
- return this.Or;
23
+ Qr() {
24
+ return this.Gr;
25
25
  }
26
- Kr(i, e, t, s, n) {
26
+ Xr(i, e, t, s, n) {
27
27
  i.unsubscribe()
28
28
  .then(i => {
29
29
  i
30
- ? this.Lr(e, t, s, n)
30
+ ? this.Zr(e, t, s, n)
31
31
  : (r.D.error("Failed to unsubscribe device from push."),
32
32
  "function" == typeof n && n(!1));
33
33
  })
@@ -36,16 +36,16 @@ export default class aa {
36
36
  "function" == typeof n && n(!1);
37
37
  });
38
38
  }
39
- Qr(i, e, t) {
39
+ sn(i, e, t) {
40
40
  const s = (i => {
41
41
  if ("string" == typeof i) return i;
42
42
  if (0 !== i.endpoint.indexOf("https://android.googleapis.com/gcm/send"))
43
43
  return i.endpoint;
44
44
  let e = i.endpoint;
45
45
  return (
46
- i.Xr &&
47
- -1 === i.endpoint.indexOf(i.Xr) &&
48
- (e = i.endpoint + "/" + i.Xr),
46
+ i.rn &&
47
+ -1 === i.endpoint.indexOf(i.rn) &&
48
+ (e = i.endpoint + "/" + i.rn),
49
49
  e
50
50
  );
51
51
  })(i);
@@ -73,15 +73,15 @@ export default class aa {
73
73
  .replace(/\//g, "_")
74
74
  : null;
75
75
  })(i);
76
- this.Sr.Zr(s, t, r, n, o), s && "function" == typeof e && e(s, r, n);
76
+ this.Sr.on(s, t, r, n, o), s && "function" == typeof e && e(s, r, n);
77
77
  }
78
- hn() {
79
- this.Sr.fn(!0);
78
+ un() {
79
+ this.Sr.an(!0);
80
80
  }
81
- dn(i, e) {
82
- this.Sr.fn(!1), r.D.info(i), "function" == typeof e && e(!1);
81
+ cn(i, e) {
82
+ this.Sr.an(!1), r.D.info(i), "function" == typeof e && e(!1);
83
83
  }
84
- pn(i, e, t, s) {
84
+ hn(i, e, t, s) {
85
85
  if ("default" === e.permission)
86
86
  try {
87
87
  window.safari.pushNotification.requestPermission(
@@ -93,23 +93,23 @@ export default class aa {
93
93
  this.Sr.setPushNotificationSubscriptionType(
94
94
  User.NotificationSubscriptionTypes.OPTED_IN
95
95
  ),
96
- this.pn(i, e, t, s);
96
+ this.hn(i, e, t, s);
97
97
  }
98
98
  );
99
99
  } catch (i) {
100
- this.dn("Could not request permission for push: " + i, s);
100
+ this.cn("Could not request permission for push: " + i, s);
101
101
  }
102
102
  else
103
103
  "denied" === e.permission
104
- ? this.dn(
104
+ ? this.cn(
105
105
  "The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
106
106
  s
107
107
  )
108
108
  : "granted" === e.permission &&
109
109
  (r.D.info("Device successfully subscribed to push."),
110
- this.Qr(e.deviceToken, t, new Date()));
110
+ this.sn(e.deviceToken, t, new Date()));
111
111
  }
112
- bn(i, e, t) {
112
+ fn(i, e, t) {
113
113
  const s = s => {
114
114
  switch (s) {
115
115
  case "granted":
@@ -132,26 +132,27 @@ export default class aa {
132
132
  })
133
133
  : (n = !0);
134
134
  }
135
- Lr(i, e, t, s) {
135
+ Zr(i, e, t, s) {
136
136
  const n = { userVisibleOnly: !0 };
137
137
  null != e && (n.applicationServerKey = e),
138
138
  i.pushManager
139
139
  .subscribe(n)
140
140
  .then(i => {
141
141
  r.D.info("Device successfully subscribed to push."),
142
- this.Qr(i, t, new Date());
142
+ this.sn(i, t, new Date());
143
143
  })
144
144
  .catch(i => {
145
145
  dt.isPushBlocked()
146
146
  ? (r.D.info("Permission for push notifications was denied."),
147
147
  "function" == typeof s && s(!1))
148
- : r.D.error("Push subscription failed: " + i);
148
+ : (r.D.error("Push subscription failed: " + i),
149
+ "function" == typeof s && s(!0));
149
150
  });
150
151
  }
151
- gn() {
152
- return this.Vr
152
+ ln() {
153
+ return this.Yr
153
154
  ? navigator.serviceWorker.getRegistration()
154
- : navigator.serviceWorker.register(this.Nr).then(() =>
155
+ : navigator.serviceWorker.register(this.Vr).then(() =>
155
156
  navigator.serviceWorker.ready.then(
156
157
  i => (
157
158
  i &&
@@ -164,197 +165,203 @@ export default class aa {
164
165
  )
165
166
  );
166
167
  }
167
- wn(i) {
168
- this.Vr ||
168
+ dn(i) {
169
+ this.Yr ||
169
170
  (i.unregister(), r.D.info("Service worker successfully unregistered."));
170
171
  }
171
172
  subscribe(i, e) {
172
- if (dt.isPushSupported()) {
173
- if (this.Mr) {
174
- if (!this.Vr && null != window.location) {
175
- let i = this.Nr;
176
- -1 === i.indexOf(window.location.host) &&
177
- (i = window.location.host + i),
178
- -1 === i.indexOf(window.location.protocol) &&
179
- (i = window.location.protocol + "//" + i);
180
- const e = i.substr(0, i.lastIndexOf("/") + 1);
181
- if (0 !== H.yn().indexOf(e))
182
- return void r.D.error(
173
+ if (!dt.isPushSupported())
174
+ return r.D.info(aa.pn), void ("function" == typeof e && e(!1));
175
+ if (this.Hr) {
176
+ if (!this.Yr && null != window.location) {
177
+ let i = this.Vr;
178
+ -1 === i.indexOf(window.location.host) &&
179
+ (i = window.location.host + i),
180
+ -1 === i.indexOf(window.location.protocol) &&
181
+ (i = window.location.protocol + "//" + i);
182
+ const t = i.substr(0, i.lastIndexOf("/") + 1);
183
+ if (0 !== H.bn().indexOf(t))
184
+ return (
185
+ r.D.error(
183
186
  "Cannot subscribe to push from a path higher than the service worker location (tried to subscribe from " +
184
187
  window.location.pathname +
185
188
  " but service worker is at " +
186
189
  i +
187
190
  ")"
188
- );
189
- }
190
- if (dt.isPushBlocked())
191
- return void this.dn(
192
- "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
193
- e
194
- );
195
- if (this.gt && !this.gt.vn() && 0 === this.gt.Zs())
196
- return (
197
- r.D.info(
198
- "Waiting for VAPID key from server config before subscribing to push."
199
191
  ),
200
- void this.gt.kn(() => {
201
- this.subscribe(i, e);
202
- })
192
+ void ("function" == typeof e && e(!0))
203
193
  );
204
- const t = () => {
205
- r.D.info("Permission for push notifications was denied."),
206
- "function" == typeof e && e(!1);
207
- },
208
- s = () => {
209
- let i = "Permission for push notifications was ignored.";
210
- dt.isPushBlocked() &&
211
- (i +=
212
- " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
213
- r.D.info(i),
214
- "function" == typeof e && e(!0);
215
- },
216
- n = dt.isPushPermissionGranted(),
217
- u = () => {
218
- n ||
219
- this.Sr.setPushNotificationSubscriptionType(
220
- User.NotificationSubscriptionTypes.OPTED_IN
221
- ),
222
- this.gn()
223
- .then(t => {
224
- if (null == t)
225
- return (
226
- r.D.error(
227
- "No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."
228
- ),
229
- void ("function" == typeof e && e())
230
- );
231
- t.pushManager
232
- .getSubscription()
233
- .then(s => {
234
- let n = null;
235
- if (
236
- (this.gt &&
237
- null != this.gt.vn() &&
238
- (n = r.Dn.Pn(this.gt.vn())),
239
- s)
240
- ) {
241
- let u = null,
242
- a = null;
243
- const h = this.h.I(o.q.Sn);
244
- if (h && !p(h)) {
245
- let i;
246
- try {
247
- i = ei.jn(h)._n;
248
- } catch (e) {
249
- i = null;
250
- }
251
- null == i ||
252
- isNaN(i.getTime()) ||
253
- 0 === i.getTime() ||
254
- ((u = i),
255
- (a = new Date(u)),
256
- a.setMonth(u.getMonth() + 6));
257
- }
258
- null != n &&
259
- s.options &&
260
- s.options.applicationServerKey &&
261
- s.options.applicationServerKey.byteLength &&
262
- s.options.applicationServerKey.byteLength > 0 &&
263
- !ii(n, new Uint8Array(s.options.applicationServerKey))
264
- ? (s.options.applicationServerKey.byteLength > 12
265
- ? r.D.info(
266
- "Device was already subscribed to push using a different VAPID provider, creating new subscription."
267
- )
268
- : r.D.info(
269
- "Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."
270
- ),
271
- this.Kr(s, t, n, i, e))
272
- : s.expirationTime &&
273
- new Date(s.expirationTime) <= new Date().valueOf()
274
- ? (r.D.info(
275
- "Push subscription is expired, creating new subscription."
276
- ),
277
- this.Kr(s, t, n, i, e))
278
- : h && p(h)
279
- ? this.Kr(s, t, n, i, e)
280
- : null == a
281
- ? (r.D.info(
282
- "No push subscription creation date found, creating new subscription."
283
- ),
284
- this.Kr(s, t, n, i, e))
285
- : a <= new Date().valueOf()
286
- ? (r.D.info(
287
- "Push subscription older than 6 months, creating new subscription."
288
- ),
289
- this.Kr(s, t, n, i, e))
290
- : (r.D.info(
291
- "Device already subscribed to push, sending existing subscription to backend."
292
- ),
293
- this.Qr(s, i, u));
294
- } else this.Lr(t, n, i, e);
295
- })
296
- .catch(i => {
297
- r.D.error(
298
- "Error checking current push subscriptions: " + i
299
- );
300
- });
301
- })
302
- .catch(i => {
303
- r.D.error("ServiceWorker registration failed: " + i);
304
- });
305
- };
306
- this.bn(u, s, t);
307
- } else if (this.Gr) {
308
- if (null == this.Ir || "" === this.Ir)
309
- return void r.D.error(
310
- "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari"
311
- );
312
- const t = window.safari.pushNotification.permission(this.Ir);
313
- this.pn(this.Ir, t, i, e);
314
194
  }
315
- } else r.D.info(this.An);
316
- }
317
- unsubscribe(i, e) {
318
- dt.isPushSupported()
319
- ? this.Mr
320
- ? navigator.serviceWorker.getRegistration().then(t => {
321
- t
322
- ? t.pushManager
195
+ if (dt.isPushBlocked())
196
+ return void this.cn(
197
+ "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
198
+ e
199
+ );
200
+ if (this.gt && !this.gt.mn() && 0 === this.gt.Zs())
201
+ return (
202
+ r.D.info(
203
+ "Waiting for VAPID key from server config before subscribing to push."
204
+ ),
205
+ void this.gt.gn(() => {
206
+ this.subscribe(i, e);
207
+ })
208
+ );
209
+ const t = () => {
210
+ r.D.info("Permission for push notifications was denied."),
211
+ "function" == typeof e && e(!1);
212
+ },
213
+ s = () => {
214
+ let i = "Permission for push notifications was ignored.";
215
+ dt.isPushBlocked() &&
216
+ (i +=
217
+ " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
218
+ r.D.info(i),
219
+ "function" == typeof e && e(!0);
220
+ },
221
+ n = dt.isPushPermissionGranted(),
222
+ u = () => {
223
+ n ||
224
+ this.Sr.setPushNotificationSubscriptionType(
225
+ User.NotificationSubscriptionTypes.OPTED_IN
226
+ ),
227
+ this.ln()
228
+ .then(t => {
229
+ if (null == t)
230
+ return (
231
+ r.D.error(
232
+ "No service worker registration. Set the `manageServiceWorkerExternally` initialization option to false or ensure that your service worker is registered before calling registerPush."
233
+ ),
234
+ void ("function" == typeof e && e(!0))
235
+ );
236
+ t.pushManager
323
237
  .getSubscription()
324
238
  .then(s => {
325
- s &&
326
- (this.hn(),
327
- s
328
- .unsubscribe()
329
- .then(s => {
330
- s
331
- ? (r.D.info(
332
- "Device successfully unsubscribed from push."
333
- ),
334
- "function" == typeof i && i())
335
- : (r.D.error(
336
- "Failed to unsubscribe device from push."
239
+ let n = null;
240
+ if (
241
+ (this.gt &&
242
+ null != this.gt.mn() &&
243
+ (n = r.yn.wn(this.gt.mn())),
244
+ s)
245
+ ) {
246
+ let u = null,
247
+ a = null;
248
+ const c = this.h.I(o.q.vn);
249
+ if (c && !p(c)) {
250
+ let i;
251
+ try {
252
+ i = ei.Pn(c).kn;
253
+ } catch (e) {
254
+ i = null;
255
+ }
256
+ null == i ||
257
+ isNaN(i.getTime()) ||
258
+ 0 === i.getTime() ||
259
+ ((u = i),
260
+ (a = new Date(u)),
261
+ a.setMonth(u.getMonth() + 6));
262
+ }
263
+ null != n &&
264
+ s.options &&
265
+ s.options.applicationServerKey &&
266
+ s.options.applicationServerKey.byteLength &&
267
+ s.options.applicationServerKey.byteLength > 0 &&
268
+ !ii(n, new Uint8Array(s.options.applicationServerKey))
269
+ ? (s.options.applicationServerKey.byteLength > 12
270
+ ? r.D.info(
271
+ "Device was already subscribed to push using a different VAPID provider, creating new subscription."
272
+ )
273
+ : r.D.info(
274
+ "Attempting to upgrade a gcm_sender_id-based push registration to VAPID - depending on the browser this may or may not result in the same gcm_sender_id-based subscription."
337
275
  ),
338
- "function" == typeof e && e()),
339
- this.wn(t);
340
- })
341
- .catch(i => {
342
- r.D.error("Push unsubscription error: " + i),
343
- "function" == typeof e && e();
344
- }));
276
+ this.Xr(s, t, n, i, e))
277
+ : s.expirationTime &&
278
+ new Date(s.expirationTime) <= new Date().valueOf()
279
+ ? (r.D.info(
280
+ "Push subscription is expired, creating new subscription."
281
+ ),
282
+ this.Xr(s, t, n, i, e))
283
+ : c && p(c)
284
+ ? this.Xr(s, t, n, i, e)
285
+ : null == a
286
+ ? (r.D.info(
287
+ "No push subscription creation date found, creating new subscription."
288
+ ),
289
+ this.Xr(s, t, n, i, e))
290
+ : a <= new Date().valueOf()
291
+ ? (r.D.info(
292
+ "Push subscription older than 6 months, creating new subscription."
293
+ ),
294
+ this.Xr(s, t, n, i, e))
295
+ : (r.D.info(
296
+ "Device already subscribed to push, sending existing subscription to backend."
297
+ ),
298
+ this.sn(s, i, u));
299
+ } else this.Zr(t, n, i, e);
345
300
  })
346
301
  .catch(i => {
347
- r.D.error("Error unsubscribing from push: " + i),
348
- "function" == typeof e && e();
349
- })
350
- : (r.D.info("Device already unsubscribed from push."),
351
- "function" == typeof i && i());
352
- })
353
- : this.Gr &&
354
- (this.hn(),
355
- r.D.info("Device unsubscribed from push."),
356
- "function" == typeof i && i())
357
- : r.D.info(this.An);
302
+ r.D.error(
303
+ "Error checking current push subscriptions: " + i
304
+ );
305
+ });
306
+ })
307
+ .catch(i => {
308
+ r.D.error("ServiceWorker registration failed: " + i);
309
+ });
310
+ };
311
+ this.fn(u, s, t);
312
+ } else if (this.Kr) {
313
+ if (null == this.Or || "" === this.Or)
314
+ return (
315
+ r.D.error(
316
+ "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari"
317
+ ),
318
+ void ("function" == typeof e && e(!0))
319
+ );
320
+ const t = window.safari.pushNotification.permission(this.Or);
321
+ this.hn(this.Or, t, i, e);
322
+ }
323
+ }
324
+ unsubscribe(i, e) {
325
+ if (!dt.isPushSupported())
326
+ return r.D.info(aa.pn), void ("function" == typeof e && e());
327
+ this.Hr
328
+ ? navigator.serviceWorker.getRegistration().then(t => {
329
+ t
330
+ ? t.pushManager
331
+ .getSubscription()
332
+ .then(s => {
333
+ s &&
334
+ (this.un(),
335
+ s
336
+ .unsubscribe()
337
+ .then(s => {
338
+ s
339
+ ? (r.D.info(
340
+ "Device successfully unsubscribed from push."
341
+ ),
342
+ "function" == typeof i && i())
343
+ : (r.D.error(
344
+ "Failed to unsubscribe device from push."
345
+ ),
346
+ "function" == typeof e && e()),
347
+ this.dn(t);
348
+ })
349
+ .catch(i => {
350
+ r.D.error("Push unsubscription error: " + i),
351
+ "function" == typeof e && e();
352
+ }));
353
+ })
354
+ .catch(i => {
355
+ r.D.error("Error unsubscribing from push: " + i),
356
+ "function" == typeof e && e();
357
+ })
358
+ : (r.D.info("Device already unsubscribed from push."),
359
+ "function" == typeof i && i());
360
+ })
361
+ : this.Kr &&
362
+ (this.un(),
363
+ r.D.info("Device unsubscribed from push."),
364
+ "function" == typeof i && i());
358
365
  }
359
366
  }
360
- aa.An = "Push notifications are not supported in this browser.";
367
+ aa.pn = "Push notifications are not supported in this browser.";
@@ -1,15 +1,15 @@
1
1
  const dt = {
2
- Yr: () =>
2
+ Jr: () =>
3
3
  "serviceWorker" in navigator &&
4
4
  "undefined" != typeof ServiceWorkerRegistration &&
5
5
  "showNotification" in ServiceWorkerRegistration.prototype &&
6
6
  "PushManager" in window,
7
- Hr: () =>
7
+ Lr: () =>
8
8
  "safari" in window &&
9
9
  "pushNotification" in window.safari &&
10
10
  "function" == typeof window.safari.pushNotification.permission &&
11
11
  "function" == typeof window.safari.pushNotification.requestPermission,
12
- isPushSupported: () => dt.Yr() || dt.Hr(),
12
+ isPushSupported: () => dt.Jr() || dt.Lr(),
13
13
  isPushBlocked: () => {
14
14
  const i =
15
15
  dt.isPushSupported() &&
@@ -28,7 +28,7 @@ const dt = {
28
28
  null != window.Notification &&
29
29
  null != window.Notification.permission &&
30
30
  "granted" === window.Notification.permission,
31
- Ti: () =>
31
+ Gi: () =>
32
32
  !dt.isPushBlocked() && dt.isPushSupported() && !dt.isPushPermissionGranted()
33
33
  };
34
34
  export default dt;
@@ -15,13 +15,13 @@ export default class bt {
15
15
  e = U(s);
16
16
  if (e > User.ee) {
17
17
  for (; e > User.ee; ) (s = s.slice(0, s.length - 1)), (e = U(s));
18
- (t.iu = s), this.h.ru(o.eu.su, t);
18
+ (t.iu = s), this.h.uu(o.eu.su, t);
19
19
  }
20
20
  return s;
21
21
  }
22
- uu(t) {
22
+ ru(t) {
23
23
  const s = null == this.getUserId();
24
- this.h.ru(o.eu.su, new _t(t)), s && this.h.ou(t);
24
+ this.h.uu(o.eu.su, new _t(t)), s && this.h.ou(t);
25
25
  }
26
26
  setCustomUserAttribute(t, s) {
27
27
  if (this.gt.hu(t))
@@ -39,12 +39,15 @@ export default class bt {
39
39
  return (
40
40
  e &&
41
41
  ((o = " custom"),
42
- "object" == typeof s && ((h = Object.keys(s)[0]), (n = s[h]))),
42
+ "object" == typeof s &&
43
+ ((h = Object.keys(s)[0]),
44
+ (n = s[h]),
45
+ "object" == typeof n && (n = JSON.stringify(n, null, 2)))),
43
46
  !i && u && r.D.info(`Logged${o} attribute ${h} with value ${n}`),
44
47
  u
45
48
  );
46
49
  }
47
- Zr(t, s, e, i, u) {
50
+ on(t, s, e, i, u) {
48
51
  this.nu("push_token", t, !1, !0),
49
52
  this.nu("custom_push_public_key", e, !1, !0),
50
53
  this.nu("custom_push_user_auth", i, !1, !0),
@@ -52,9 +55,9 @@ export default class bt {
52
55
  const h = r.xt.Ft,
53
56
  n = new r.qt(h, r.D),
54
57
  l = new ei(t, s, e, i, u);
55
- this.h.B(o.q.Sn, l.ss()), n.setItem(h.$t.cu, h.se, !0);
58
+ this.h.B(o.q.vn, l.ss()), n.setItem(h.$t.cu, h.se, !0);
56
59
  }
57
- fn(t) {
60
+ an(t) {
58
61
  if (
59
62
  (this.nu("push_token", null, !1, !0),
60
63
  this.nu("custom_push_public_key", null, !1, !0),
@@ -64,7 +67,7 @@ export default class bt {
64
67
  ) {
65
68
  const t = r.xt.Ft,
66
69
  s = new r.qt(t, r.D);
67
- this.h.B(o.q.Sn, !1), s.setItem(t.$t.cu, t.se, !1);
70
+ this.h.B(o.q.vn, !1), s.setItem(t.$t.cu, t.se, !1);
68
71
  }
69
72
  }
70
73
  }