@braze/web-sdk 5.6.0 → 5.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 (121) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +14 -4
  3. package/package.json +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +20 -20
  6. package/shared-lib/indexed-db-adapter.js +15 -15
  7. package/shared-lib/logger.js +2 -2
  8. package/shared-lib/supported-options.js +14 -14
  9. package/src/Banner/banner-provider.js +53 -50
  10. package/src/Banner/banner.js +1 -1
  11. package/src/Banner/get-all-banners.js +2 -2
  12. package/src/Banner/get-banner.js +2 -2
  13. package/src/Banner/log-banner-click.js +1 -1
  14. package/src/Banner/log-banner-impressions.js +4 -4
  15. package/src/Banner/request-banners-refresh.js +2 -2
  16. package/src/Banner/subscribe-to-banners-updates.js +5 -5
  17. package/src/Card/card-manager.js +10 -10
  18. package/src/Card/models/captioned-image.js +1 -1
  19. package/src/Card/models/card.js +3 -3
  20. package/src/Card/models/classic-card.js +1 -1
  21. package/src/Card/models/control-card.js +1 -1
  22. package/src/Card/models/image-only.js +1 -1
  23. package/src/ContentCards/content-cards-provider.js +139 -180
  24. package/src/ContentCards/get-cached-content-cards.js +1 -1
  25. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  26. package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
  27. package/src/ContentCards/ui/show-content-cards.js +3 -3
  28. package/src/Core/disable-sdk.js +3 -3
  29. package/src/Core/enable-sdk.js +3 -3
  30. package/src/Core/log-custom-event.js +3 -3
  31. package/src/Core/log-purchase.js +1 -1
  32. package/src/Core/open-session.js +6 -6
  33. package/src/Core/wipe-data.js +4 -4
  34. package/src/FeatureFlags/feature-flag.js +1 -1
  35. package/src/FeatureFlags/feature-flags-provider.js +81 -78
  36. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  37. package/src/FeatureFlags/get-feature-flag.js +2 -2
  38. package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
  39. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  40. package/src/Feed/feed-provider.js +34 -34
  41. package/src/Feed/get-cached-feed.js +1 -1
  42. package/src/Feed/request-feed-refresh.js +1 -1
  43. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  44. package/src/Feed/ui/show-feed.js +1 -1
  45. package/src/InAppMessage/defer-in-app-message.js +1 -1
  46. package/src/InAppMessage/display/html-message-to-html.js +9 -9
  47. package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
  48. package/src/InAppMessage/display/modal-utils.js +5 -5
  49. package/src/InAppMessage/in-app-message-factory.js +4 -4
  50. package/src/InAppMessage/in-app-message-manager.js +115 -91
  51. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  52. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  53. package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
  54. package/src/InAppMessage/log-in-app-message-impression.js +2 -2
  55. package/src/InAppMessage/models/full-screen-message.js +5 -5
  56. package/src/InAppMessage/models/html-message.js +10 -10
  57. package/src/InAppMessage/models/in-app-message-button.js +5 -5
  58. package/src/InAppMessage/models/in-app-message.js +37 -37
  59. package/src/InAppMessage/models/modal-message.js +5 -5
  60. package/src/InAppMessage/models/slide-up-message.js +7 -7
  61. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  62. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  63. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  64. package/src/InAppMessage/ui/show-in-app-message.js +14 -14
  65. package/src/Push/is-push-blocked.js +2 -2
  66. package/src/Push/is-push-permission-granted.js +2 -2
  67. package/src/Push/is-push-supported.js +2 -2
  68. package/src/Push/push-manager.js +88 -88
  69. package/src/Push/utils/push-utils.js +12 -12
  70. package/src/User/user-manager.js +10 -10
  71. package/src/User/user.js +46 -34
  72. package/src/common/constants.js +1 -1
  73. package/src/common/event-logger.js +3 -3
  74. package/src/common/feed-display.js +10 -10
  75. package/src/l10n/l10n-manager.js +1 -1
  76. package/src/managers/auth-manager.js +10 -10
  77. package/src/managers/braze-instance.js +110 -110
  78. package/src/managers/device-manager.js +17 -17
  79. package/src/managers/network-manager.js +180 -143
  80. package/src/managers/server-config-manager.js +65 -65
  81. package/src/managers/session-manager.js +22 -22
  82. package/src/managers/storage-manager-factory.js +9 -9
  83. package/src/managers/storage-manager.js +134 -134
  84. package/src/managers/subscription-manager.js +8 -8
  85. package/src/managers/utils.js +1 -1
  86. package/src/models/backend-errors.js +5 -5
  87. package/src/models/braze-event.js +8 -8
  88. package/src/models/device.js +2 -2
  89. package/src/models/identifier.js +10 -10
  90. package/src/models/push-token.js +8 -8
  91. package/src/models/server-config.js +31 -31
  92. package/src/request-controller.js +158 -146
  93. package/src/triggers/models/custom-event-data.js +5 -5
  94. package/src/triggers/models/custom-event-property-data.js +6 -6
  95. package/src/triggers/models/filter-set.js +6 -6
  96. package/src/triggers/models/filter.js +16 -16
  97. package/src/triggers/models/in-app-message-click-data.js +2 -2
  98. package/src/triggers/models/purchase-data.js +2 -2
  99. package/src/triggers/models/purchase-property-data.js +4 -4
  100. package/src/triggers/models/push-click-data.js +2 -2
  101. package/src/triggers/models/trigger-condition.js +36 -36
  102. package/src/triggers/models/trigger-events.js +1 -1
  103. package/src/triggers/models/trigger.js +11 -11
  104. package/src/triggers/triggers-provider-factory.js +2 -2
  105. package/src/triggers/triggers-provider.js +37 -37
  106. package/src/ui/js/attach-css.js +1 -1
  107. package/src/ui/js/iam-css.js +1 -1
  108. package/src/ui/js/load-font-awesome.js +1 -1
  109. package/src/util/base-device-parser.js +1 -1
  110. package/src/util/braze-actions.js +4 -4
  111. package/src/util/browser-detector.js +11 -10
  112. package/src/util/client-hints-parser.js +3 -3
  113. package/src/util/component-utils.js +2 -2
  114. package/src/util/dom-utils.js +3 -3
  115. package/src/util/html-display-utils.js +1 -0
  116. package/src/util/key-codes.js +1 -1
  117. package/src/util/net.js +22 -23
  118. package/src/util/request-header-utils.js +23 -20
  119. package/src/util/user-agent-parser.js +14 -14
  120. package/src/util/validation-utils.js +14 -14
  121. package/src/util/window-utils.js +2 -2
@@ -3,41 +3,41 @@ import ti from "../models/push-token.js";
3
3
  import { logger as N, EncodingUtils as ei } from "../../shared-lib/index.js";
4
4
  import { STORAGE_KEYS as t } from "../managers/storage-manager.js";
5
5
  import { User } from "../User/index.js";
6
- import yt from "./utils/push-utils.js";
6
+ import vt from "./utils/push-utils.js";
7
7
  import { getErrorMessage as si } from "../util/error-utils.js";
8
8
  export default class na {
9
9
  constructor(i, t, e, s, r, n, o, u, a, h, c) {
10
- (this.bn = i),
11
- (this.yn = t),
12
- (this.wn = e),
13
- (this.kn = r),
14
- (this.Pn = n),
15
- (this.Dn = o),
10
+ (this.cn = i),
11
+ (this.fn = t),
12
+ (this.dn = e),
13
+ (this.bn = r),
14
+ (this.yn = n),
15
+ (this.gn = o),
16
16
  (this.B = u),
17
- (this.Sn = a),
18
- (this.An = h),
17
+ (this.vn = a),
18
+ (this.wn = h),
19
19
  (this.C = c),
20
- (this.bn = i),
21
- (this.yn = t),
22
- (this.wn = e),
23
- (this.xn = s + "/safari/" + t),
24
- (this.kn = r || "/service-worker.js"),
25
- (this.Dn = o),
20
+ (this.cn = i),
21
+ (this.fn = t),
22
+ (this.dn = e),
23
+ (this.kn = s + "/safari/" + t),
24
+ (this.bn = r || "/service-worker.js"),
25
+ (this.gn = o),
26
26
  (this.B = u),
27
- (this.Sn = a || !1),
28
- (this.An = h || !1),
27
+ (this.vn = a || !1),
28
+ (this.wn = h || !1),
29
29
  (this.C = c),
30
- (this.Nn = yt.Un()),
31
- (this.Wn = yt._n());
30
+ (this.Pn = vt.Dn()),
31
+ (this.Sn = vt.An());
32
32
  }
33
- Tn() {
34
- return this.An;
33
+ jn() {
34
+ return this.wn;
35
35
  }
36
- In(i, t, e, s, r) {
36
+ xn(i, t, e, s, r) {
37
37
  i.unsubscribe()
38
38
  .then((i) => {
39
39
  i
40
- ? this.Vn(t, e, s, r)
40
+ ? this.Nn(t, e, s, r)
41
41
  : (N.error("Failed to unsubscribe device from push."),
42
42
  "function" == typeof r && r(!1));
43
43
  })
@@ -46,7 +46,7 @@ export default class na {
46
46
  "function" == typeof r && r(!1);
47
47
  });
48
48
  }
49
- qn(i, t, e) {
49
+ Un(i, t, e) {
50
50
  var s;
51
51
  const r = ((i) => {
52
52
  if ("string" == typeof i) return i;
@@ -55,9 +55,9 @@ export default class na {
55
55
  let t = i.endpoint;
56
56
  const e = i;
57
57
  return (
58
- e.zn &&
59
- -1 === i.endpoint.indexOf(e.zn) &&
60
- (t = i.endpoint + "/" + e.zn),
58
+ e.Wn &&
59
+ -1 === i.endpoint.indexOf(e.Wn) &&
60
+ (t = i.endpoint + "/" + e.Wn),
61
61
  t
62
62
  );
63
63
  })(i);
@@ -84,53 +84,53 @@ export default class na {
84
84
  .replace(/\//g, "_")
85
85
  : null;
86
86
  })(u);
87
- null === (s = this.bn) || void 0 === s || s.En(r, t, n, o, a),
87
+ null === (s = this.cn) || void 0 === s || s._n(r, t, n, o, a),
88
88
  r && "function" == typeof e && e(r, n, o);
89
89
  }
90
- Rn() {
90
+ Tn() {
91
91
  var i;
92
- null === (i = this.bn) || void 0 === i || i.Cn(!0);
92
+ null === (i = this.cn) || void 0 === i || i.In(!0);
93
93
  }
94
- Fn(i, t) {
94
+ Vn(i, t) {
95
95
  var e;
96
- null === (e = this.bn) || void 0 === e || e.Cn(!1),
96
+ null === (e = this.cn) || void 0 === e || e.In(!1),
97
97
  N.info(i),
98
98
  "function" == typeof t && t(!1);
99
99
  }
100
- On(i, t, e, s) {
100
+ qn(i, t, e, s) {
101
101
  var r;
102
102
  if ("default" === t.permission)
103
103
  try {
104
104
  window.safari.pushNotification.requestPermission(
105
- this.xn,
105
+ this.kn,
106
106
  i,
107
107
  {
108
- api_key: this.yn,
108
+ api_key: this.fn,
109
109
  device_id:
110
- (null === (r = this.wn) || void 0 === r ? void 0 : r.ce().id) ||
110
+ (null === (r = this.dn) || void 0 === r ? void 0 : r.ce().id) ||
111
111
  "",
112
112
  },
113
113
  (t) => {
114
114
  "granted" === t.permission &&
115
- this.bn &&
116
- this.bn.setPushNotificationSubscriptionType(
115
+ this.cn &&
116
+ this.cn.setPushNotificationSubscriptionType(
117
117
  User.NotificationSubscriptionTypes.OPTED_IN,
118
118
  ),
119
- this.On(i, t, e, s);
119
+ this.qn(i, t, e, s);
120
120
  },
121
121
  );
122
122
  } catch (i) {
123
- this.Fn("Could not request permission for push: " + i, s);
123
+ this.Vn("Could not request permission for push: " + i, s);
124
124
  }
125
125
  else
126
126
  "denied" === t.permission
127
- ? this.Fn(
127
+ ? this.Vn(
128
128
  "The user has blocked notifications from this site, or Safari push is not configured in the Braze dashboard.",
129
129
  s,
130
130
  )
131
131
  : "granted" === t.permission &&
132
132
  (N.info("Device successfully subscribed to push."),
133
- this.qn(t.deviceToken, new Date(), e));
133
+ this.Un(t.deviceToken, new Date(), e));
134
134
  }
135
135
  requestPermission(i, t, e) {
136
136
  const s = (s) => {
@@ -159,27 +159,27 @@ export default class na {
159
159
  : (r = !0);
160
160
  }
161
161
  }
162
- Vn(i, t, e, s) {
162
+ Nn(i, t, e, s) {
163
163
  const r = { userVisibleOnly: !0 };
164
164
  null != t && (r.applicationServerKey = t),
165
165
  i.pushManager
166
166
  .subscribe(r)
167
167
  .then((i) => {
168
168
  N.info("Device successfully subscribed to push."),
169
- this.qn(i, new Date(), e);
169
+ this.Un(i, new Date(), e);
170
170
  })
171
171
  .catch((i) => {
172
- yt.isPushBlocked()
172
+ vt.isPushBlocked()
173
173
  ? (N.info("Permission for push notifications was denied."),
174
174
  "function" == typeof s && s(!1))
175
175
  : (N.error("Push subscription failed: " + i),
176
176
  "function" == typeof s && s(!0));
177
177
  });
178
178
  }
179
- Bn() {
180
- if (this.Sn) return navigator.serviceWorker.getRegistration(this.kn);
181
- const i = this.Pn ? { scope: this.Pn } : void 0;
182
- return navigator.serviceWorker.register(this.kn, i).then(() =>
179
+ zn() {
180
+ if (this.vn) return navigator.serviceWorker.getRegistration(this.bn);
181
+ const i = this.yn ? { scope: this.yn } : void 0;
182
+ return navigator.serviceWorker.register(this.bn, i).then(() =>
183
183
  navigator.serviceWorker.ready.then(
184
184
  (i) => (
185
185
  i &&
@@ -192,32 +192,32 @@ export default class na {
192
192
  ),
193
193
  );
194
194
  }
195
- Mn(i) {
196
- this.Sn ||
195
+ En(i) {
196
+ this.vn ||
197
197
  (i.unregister(), N.info("Service worker successfully unregistered."));
198
198
  }
199
199
  subscribe(i, e) {
200
- if (!yt.isPushSupported())
201
- return N.info(na.Yn), void ("function" == typeof e && e(!1));
202
- if (this.Nn) {
203
- if (!this.Sn && null != window.location) {
204
- let i = this.kn;
200
+ if (!vt.isPushSupported())
201
+ return N.info(na.Rn), void ("function" == typeof e && e(!1));
202
+ if (this.Pn) {
203
+ if (!this.vn && null != window.location) {
204
+ let i = this.bn;
205
205
  -1 === i.indexOf(window.location.host) &&
206
206
  (i = window.location.host + i),
207
207
  -1 === i.indexOf(window.location.protocol) &&
208
208
  (i = window.location.protocol + "//" + i);
209
209
  }
210
- if (yt.isPushBlocked())
211
- return void this.Fn(
210
+ if (vt.isPushBlocked())
211
+ return void this.Vn(
212
212
  "Notifications from this site are blocked. This may be a temporary embargo or a permanent denial.",
213
213
  e,
214
214
  );
215
- if (this.B && !this.B.Gn() && 0 === this.B.Es())
215
+ if (this.B && !this.B.Cn() && 0 === this.B.Us())
216
216
  return (
217
217
  N.info(
218
218
  "Waiting for VAPID key from server config before subscribing to push.",
219
219
  ),
220
- void this.B.Hn(() => {
220
+ void this.B.Fn(() => {
221
221
  this.subscribe(i, e);
222
222
  })
223
223
  );
@@ -227,20 +227,20 @@ export default class na {
227
227
  },
228
228
  r = () => {
229
229
  let i = "Permission for push notifications was ignored.";
230
- yt.isPushBlocked() &&
230
+ vt.isPushBlocked() &&
231
231
  (i +=
232
232
  " The browser has automatically blocked further permission requests for a period (probably 1 week)."),
233
233
  N.info(i),
234
234
  "function" == typeof e && e(!0);
235
235
  },
236
- n = yt.isPushPermissionGranted(),
236
+ n = vt.isPushPermissionGranted(),
237
237
  o = () => {
238
238
  !n &&
239
- this.bn &&
240
- this.bn.setPushNotificationSubscriptionType(
239
+ this.cn &&
240
+ this.cn.setPushNotificationSubscriptionType(
241
241
  User.NotificationSubscriptionTypes.OPTED_IN,
242
242
  ),
243
- this.Bn()
243
+ this.zn()
244
244
  .then((s) => {
245
245
  if (null == s)
246
246
  return (
@@ -258,16 +258,16 @@ export default class na {
258
258
  (null !=
259
259
  (null === (n = this.B) || void 0 === n
260
260
  ? void 0
261
- : n.Gn()) && (o = ei.Jn(this.B.Gn())),
261
+ : n.Cn()) && (o = ei.On(this.B.Cn())),
262
262
  r)
263
263
  ) {
264
264
  let n,
265
265
  u = null,
266
266
  a = null;
267
- if ((this.C && (n = this.C.ps(t.bs.Kn)), n && !w(n))) {
267
+ if ((this.C && (n = this.C.vs(t.gs.Bn)), n && !w(n))) {
268
268
  let i;
269
269
  try {
270
- i = ti.Qn(n).Ln;
270
+ i = ti.Yn(n).Mn;
271
271
  } catch (t) {
272
272
  i = null;
273
273
  }
@@ -291,31 +291,31 @@ export default class na {
291
291
  : N.info(
292
292
  "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.",
293
293
  ),
294
- this.In(r, s, o, i, e))
294
+ this.xn(r, s, o, i, e))
295
295
  : r.expirationTime &&
296
296
  new Date(r.expirationTime).valueOf() <=
297
297
  new Date().valueOf()
298
298
  ? (N.info(
299
299
  "Push subscription is expired, creating new subscription.",
300
300
  ),
301
- this.In(r, s, o, i, e))
301
+ this.xn(r, s, o, i, e))
302
302
  : n && w(n)
303
- ? this.In(r, s, o, i, e)
303
+ ? this.xn(r, s, o, i, e)
304
304
  : null == a
305
305
  ? (N.info(
306
306
  "No push subscription creation date found, creating new subscription.",
307
307
  ),
308
- this.In(r, s, o, i, e))
308
+ this.xn(r, s, o, i, e))
309
309
  : a.valueOf() <= new Date().valueOf()
310
310
  ? (N.info(
311
311
  "Push subscription older than 6 months, creating new subscription.",
312
312
  ),
313
- this.In(r, s, o, i, e))
313
+ this.xn(r, s, o, i, e))
314
314
  : (N.info(
315
315
  "Device already subscribed to push, sending existing subscription to backend.",
316
316
  ),
317
- this.qn(r, u, i));
318
- } else this.Vn(s, o, i, e);
317
+ this.Un(r, u, i));
318
+ } else this.Nn(s, o, i, e);
319
319
  })
320
320
  .catch((i) => {
321
321
  N.error("Error checking current push subscriptions: " + i);
@@ -326,29 +326,29 @@ export default class na {
326
326
  });
327
327
  };
328
328
  this.requestPermission(o, r, s);
329
- } else if (this.Wn) {
330
- if (null == this.Dn || "" === this.Dn)
329
+ } else if (this.Sn) {
330
+ if (null == this.gn || "" === this.gn)
331
331
  return (
332
332
  N.error(
333
333
  "You must supply the safariWebsitePushId initialization option in order to use registerPush on Safari",
334
334
  ),
335
335
  void ("function" == typeof e && e(!0))
336
336
  );
337
- const t = window.safari.pushNotification.permission(this.Dn);
338
- this.On(this.Dn, t, i, e);
337
+ const t = window.safari.pushNotification.permission(this.gn);
338
+ this.qn(this.gn, t, i, e);
339
339
  }
340
340
  }
341
341
  unsubscribe(i, t) {
342
- if (!yt.isPushSupported())
343
- return N.info(na.Yn), void ("function" == typeof t && t());
344
- this.Nn
345
- ? navigator.serviceWorker.getRegistration(this.kn).then((e) => {
342
+ if (!vt.isPushSupported())
343
+ return N.info(na.Rn), void ("function" == typeof t && t());
344
+ this.Pn
345
+ ? navigator.serviceWorker.getRegistration(this.bn).then((e) => {
346
346
  e
347
347
  ? e.pushManager
348
348
  .getSubscription()
349
349
  .then((s) => {
350
350
  s
351
- ? (this.Rn(),
351
+ ? (this.Tn(),
352
352
  s
353
353
  .unsubscribe()
354
354
  .then((s) => {
@@ -361,7 +361,7 @@ export default class na {
361
361
  "Failed to unsubscribe device from push.",
362
362
  ),
363
363
  "function" == typeof t && t()),
364
- this.Mn(e);
364
+ this.En(e);
365
365
  })
366
366
  .catch((i) => {
367
367
  N.error("Push unsubscription error: " + i),
@@ -377,10 +377,10 @@ export default class na {
377
377
  : (N.info("Device already unsubscribed from push."),
378
378
  "function" == typeof i && i());
379
379
  })
380
- : this.Wn &&
381
- (this.Rn(),
380
+ : this.Sn &&
381
+ (this.Tn(),
382
382
  N.info("Device unsubscribed from push."),
383
383
  "function" == typeof i && i());
384
384
  }
385
385
  }
386
- na.Yn = "Push notifications are not supported in this browser.";
386
+ na.Rn = "Push notifications are not supported in this browser.";
@@ -1,36 +1,36 @@
1
- const yt = {
2
- Un: () =>
1
+ const vt = {
2
+ Dn: () =>
3
3
  "serviceWorker" in navigator &&
4
4
  "undefined" != typeof ServiceWorkerRegistration &&
5
5
  "showNotification" in ServiceWorkerRegistration.prototype &&
6
6
  "PushManager" in window,
7
- _n: () =>
7
+ An: () =>
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: () => yt.Un() || yt._n(),
12
+ isPushSupported: () => vt.Dn() || vt.An(),
13
13
  isPushBlocked: () => {
14
14
  const i =
15
- yt.isPushSupported() &&
15
+ vt.isPushSupported() &&
16
16
  "Notification" in window &&
17
17
  null != window.Notification &&
18
18
  null != window.Notification.permission &&
19
19
  "denied" === window.Notification.permission,
20
20
  n =
21
- yt.isPushSupported() &&
21
+ vt.isPushSupported() &&
22
22
  (!("Notification" in window) || null == window.Notification);
23
23
  return i || n;
24
24
  },
25
25
  isPushPermissionGranted: () =>
26
- yt.isPushSupported() &&
26
+ vt.isPushSupported() &&
27
27
  "Notification" in window &&
28
28
  null != window.Notification &&
29
29
  null != window.Notification.permission &&
30
30
  "granted" === window.Notification.permission,
31
- Ur: () =>
32
- !yt.isPushBlocked() &&
33
- yt.isPushSupported() &&
34
- !yt.isPushPermissionGranted(),
31
+ Cr: () =>
32
+ !vt.isPushBlocked() &&
33
+ vt.isPushSupported() &&
34
+ !vt.isPushPermissionGranted(),
35
35
  };
36
- export default yt;
36
+ export default vt;
@@ -1,10 +1,10 @@
1
1
  import _t from "../models/identifier.js";
2
2
  import { getByteLength as er } from "../util/string-utils.js";
3
3
  import ti from "../models/push-token.js";
4
- import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
4
+ import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
5
5
  import { STORAGE_KEYS as t } from "../managers/storage-manager.js";
6
6
  import { User } from "../User/index.js";
7
- export default class kt {
7
+ export default class bt {
8
8
  constructor(t, s) {
9
9
  (this.B = t), (this.C = s), (this.B = t), (this.C = s);
10
10
  }
@@ -47,17 +47,17 @@ export default class kt {
47
47
  u
48
48
  );
49
49
  }
50
- En(s, i, e, u, o) {
50
+ _n(s, i, e, u, o) {
51
51
  this.nu("push_token", s, !1, !0),
52
52
  this.nu("custom_push_public_key", e, !1, !0),
53
53
  this.nu("custom_push_user_auth", u, !1, !0),
54
54
  this.nu("custom_push_vapid_public_key", o, !1, !0);
55
- const r = it.Gs._s,
56
- h = new it(r, N),
55
+ const r = tt._s.Xs,
56
+ h = new tt(r, N),
57
57
  n = new ti(s, i, e, u, o);
58
- this.C.js(t.bs.Kn, n.Bs()), h.setItem(r.Os.cu, r.oe, !0);
58
+ this.C.Bs(t.gs.Bn, n.bs()), h.setItem(r.Ks.cu, r.oe, !0);
59
59
  }
60
- Cn(s) {
60
+ In(s) {
61
61
  if (
62
62
  (this.nu("push_token", null, !1, !0),
63
63
  this.nu("custom_push_public_key", null, !1, !0),
@@ -65,9 +65,9 @@ export default class kt {
65
65
  this.nu("custom_push_vapid_public_key", null, !1, !0),
66
66
  s)
67
67
  ) {
68
- const s = it.Gs._s,
69
- i = new it(s, N);
70
- this.C.js(t.bs.Kn, !1), i.setItem(s.Os.cu, s.oe, !1);
68
+ const s = tt._s.Xs,
69
+ i = new tt(s, N);
70
+ this.C.Bs(t.gs.Bn, !1), i.setItem(s.Ks.cu, s.oe, !1);
71
71
  }
72
72
  }
73
73
  }
package/src/User/user.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  isArray as w,
3
3
  isDate as Nt,
4
- isObject as Ct,
4
+ isObject as yt,
5
5
  validateValueIsFromEnum as ta,
6
6
  } from "../util/code-utils.js";
7
7
  import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
8
8
  import {
9
- isValidEmail as St,
10
- validateCustomAttributeArrayType as At,
11
- validateCustomAttributeKey as Ut,
9
+ isValidEmail as Ct,
10
+ validateCustomAttributeArrayType as St,
11
+ validateCustomAttributeKey as At,
12
12
  validateCustomProperties as rt,
13
13
  validateCustomString as nt,
14
- validatePropertyType as Ft,
14
+ validatePropertyType as Ut,
15
15
  validateStandardString as ir,
16
16
  } from "../util/validation-utils.js";
17
- import { SET_CUSTOM_USER_ATTRIBUTE_STRING as $t } from "../common/constants.js";
18
- import { toValidBackendTimeString as Bt } from "../util/date-utils.js";
17
+ import { SET_CUSTOM_USER_ATTRIBUTE_STRING as Dt } from "../common/constants.js";
18
+ import { toValidBackendTimeString as Ft } from "../util/date-utils.js";
19
19
  export default class User {
20
20
  constructor(t, e) {
21
- (this.As = t), (this.Ue = e), (this.As = t), (this.Ue = e);
21
+ (this.As = t), (this.Bi = e), (this.As = t), (this.Bi = e);
22
22
  }
23
23
  getUserId(t) {
24
24
  const e = this.As.getUserId();
@@ -33,7 +33,7 @@ export default class User {
33
33
  ? (N.error("addAlias requires a non-empty alias"), !1)
34
34
  : !ir(e, "add alias", "the label", !1) || e.length <= 0
35
35
  ? (N.error("addAlias requires a non-empty label"), !1)
36
- : this.Ue.$n(t, e).ss;
36
+ : this.Bi.Ln(t, e).ss;
37
37
  }
38
38
  setFirstName(t) {
39
39
  return (
@@ -47,7 +47,7 @@ export default class User {
47
47
  );
48
48
  }
49
49
  setEmail(t) {
50
- return null === t || St(t)
50
+ return null === t || Ct(t)
51
51
  ? this.As.nu("email", t)
52
52
  : (N.error(
53
53
  `Cannot set email address - "${t}" did not pass RFC-5322 validation.`,
@@ -128,7 +128,7 @@ export default class User {
128
128
  setPhoneNumber(t) {
129
129
  return (
130
130
  !!ir(t, "set phone number", "the phoneNumber", !0) &&
131
- (null === t || t.match(User.Xn)
131
+ (null === t || t.match(User.$n)
132
132
  ? this.As.nu("phone", t)
133
133
  : (N.error(`Cannot set phone number - "${t}" did not pass validation.`),
134
134
  !1))
@@ -164,15 +164,15 @@ export default class User {
164
164
  "Cannot set last-known location - accuracy and altitudeAccuracy may not be negative.",
165
165
  ),
166
166
  !1)
167
- : this.Ue.setLastKnownLocation(this.As.getUserId(), t, e, s, r, n)
167
+ : this.Bi.setLastKnownLocation(this.As.getUserId(), t, e, s, r, n)
168
168
  .ss);
169
169
  }
170
170
  setCustomUserAttribute(t, e, r) {
171
- if (!Ut(t)) return !1;
171
+ if (!At(t)) return !1;
172
172
  const s = (e) => {
173
173
  const [r] = rt(
174
174
  e,
175
- $t,
175
+ Dt,
176
176
  "attribute value",
177
177
  `set custom user attribute "${t}"`,
178
178
  "custom user attribute",
@@ -180,17 +180,17 @@ export default class User {
180
180
  return r;
181
181
  };
182
182
  if (w(e)) {
183
- const [r, n] = At(t, e);
183
+ const [r, n] = St(t, e);
184
184
  if (!r && !n && 0 !== e.length) return !1;
185
- if (r || 0 === e.length) return this.Ue.Zn(d.au, t, e).ss;
185
+ if (r || 0 === e.length) return this.Bi.Gn(d.Hn, t, e).ss;
186
186
  for (const t of e) if (!s(t)) return !1;
187
- } else if (Ct(e)) {
187
+ } else if (yt(e)) {
188
188
  if (!s(e)) return !1;
189
- if (r) return this.Ue.Zn(d.du, t, e).ss;
189
+ if (r) return this.Bi.Gn(d.Kn, t, e).ss;
190
190
  } else {
191
- if (!(void 0 !== e && Ft(e))) return !1;
191
+ if (!(void 0 !== e && Ut(e))) return !1;
192
192
  if (
193
- (Nt(e) && (e = Bt(e)),
193
+ (Nt(e) && (e = Ft(e)),
194
194
  "string" == typeof e &&
195
195
  !nt(
196
196
  e,
@@ -209,7 +209,7 @@ export default class User {
209
209
  null != e &&
210
210
  !nt(e, "add to custom user attribute array", "the given value")
211
211
  ) &&
212
- this.Ue.Zn(d.pu, t, e).ss
212
+ this.Bi.Gn(d.Jn, t, e).ss
213
213
  );
214
214
  }
215
215
  removeFromCustomAttributeArray(t, e) {
@@ -219,7 +219,7 @@ export default class User {
219
219
  null != e &&
220
220
  !nt(e, "remove from custom user attribute array", "the given value")
221
221
  ) &&
222
- this.Ue.Zn(d.bu, t, e).ss
222
+ this.Bi.Gn(d.Qn, t, e).ss
223
223
  );
224
224
  }
225
225
  incrementCustomUserAttribute(t, e) {
@@ -231,7 +231,7 @@ export default class User {
231
231
  `Cannot increment custom user attribute because the given incrementValue "${e}" is not an integer.`,
232
232
  ),
233
233
  !1)
234
- : this.Ue.Zn(d.fu, t, r).ss;
234
+ : this.Bi.Gn(d.Xn, t, r).ss;
235
235
  }
236
236
  setCustomLocationAttribute(t, e, r) {
237
237
  return (
@@ -247,7 +247,7 @@ export default class User {
247
247
  "Received invalid values for latitude and/or longitude. Latitude and longitude are bounded by ±90 and ±180 respectively, or must both be null for removal.",
248
248
  ),
249
249
  !1)
250
- : this.Ue.gu(t, e, r).ss)
250
+ : this.Bi.Zn(t, e, r).ss)
251
251
  );
252
252
  }
253
253
  addToSubscriptionGroup(t) {
@@ -261,7 +261,7 @@ export default class User {
261
261
  "addToSubscriptionGroup requires a non-empty subscription group ID",
262
262
  ),
263
263
  !1)
264
- : this.Ue.yu(t, User.Nu.SUBSCRIBED).ss;
264
+ : this.Bi.au(t, User.du.SUBSCRIBED).ss;
265
265
  }
266
266
  removeFromSubscriptionGroup(t) {
267
267
  return !ir(
@@ -274,13 +274,24 @@ export default class User {
274
274
  "removeFromSubscriptionGroup requires a non-empty subscription group ID",
275
275
  ),
276
276
  !1)
277
- : this.Ue.yu(t, User.Nu.UNSUBSCRIBED).ss;
277
+ : this.Bi.au(t, User.du.UNSUBSCRIBED).ss;
278
278
  }
279
- En(t, e, r, s, n) {
280
- this.As.En(t, e, r, s, n), this.Ue.vu();
279
+ setLineId(t) {
280
+ return ir(t, "set LINE user ID", "the ID", !0) &&
281
+ 0 !== (null == t ? void 0 : t.length)
282
+ ? t && t.length > User.pu
283
+ ? (N.error(
284
+ `Rejected LINE user ID ${t} because it is longer than ${User.pu} characters.`,
285
+ ),
286
+ !1)
287
+ : this.As.nu("native_line_id", t)
288
+ : (N.error("setLineId requires a non-empty ID"), !1);
289
+ }
290
+ _n(t, e, r, s, n) {
291
+ this.As._n(t, e, r, s, n), this.Bi.bu();
281
292
  }
282
- Cn(t) {
283
- this.As.Cn(t);
293
+ In(t) {
294
+ this.As.In(t);
284
295
  }
285
296
  }
286
297
  (User.Genders = {
@@ -296,8 +307,9 @@ export default class User {
296
307
  SUBSCRIBED: "subscribed",
297
308
  UNSUBSCRIBED: "unsubscribed",
298
309
  }),
299
- (User.Xn = /^[0-9 .\\(\\)\\+\\-]+$/),
300
- (User.Nu = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
301
- (User.Cu = "user_id"),
310
+ (User.$n = /^[0-9 .\\(\\)\\+\\-]+$/),
311
+ (User.du = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
312
+ (User.fu = "user_id"),
302
313
  (User.lu = "custom"),
303
- (User.mr = 997);
314
+ (User.mr = 997),
315
+ (User.pu = 33);
@@ -10,6 +10,6 @@ export const BRAZE_MUST_BE_INITIALIZED_ERROR =
10
10
  export const GLOBAL_RATE_LIMIT_CAPACITY_DEFAULT = 30;
11
11
  export const GLOBAL_RATE_LIMIT_REFILL_RATE_DEFAULT = 30;
12
12
  export const LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT = 72e5;
13
- export const MAX_ERROR_RETRIES_CONTENT_CARDS = 3;
13
+ export const MAX_RETRY_COUNT_PER_REQUEST = 15;
14
14
  export const REQUEST_ATTEMPT_DEFAULT = 1;
15
15
  export const SUBSCRIPTION_ID_DATA_ATTRIBUTE = "data-update-subscription-id";