@braze/web-sdk 6.5.0 → 6.6.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 (59) hide show
  1. package/index.d.ts +8 -3
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +11 -11
  4. package/shared-lib/indexed-db-adapter.js +4 -4
  5. package/shared-lib/logger.js +2 -2
  6. package/shared-lib/supported-options.js +14 -13
  7. package/src/Core/disable-sdk.js +8 -7
  8. package/src/Core/enable-sdk.js +3 -3
  9. package/src/Core/is-disabled.js +1 -1
  10. package/src/DUST/dust-provider.js +100 -100
  11. package/src/DUST/dust-shared-worker-impl.js +12 -12
  12. package/src/DUST/dust-worker-bridge.js +11 -11
  13. package/src/DUST/subscribe-to-dust.js +5 -5
  14. package/src/InAppMessage/defer-in-app-message.js +1 -1
  15. package/src/InAppMessage/in-app-message-manager.js +68 -68
  16. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  17. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  18. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  19. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  20. package/src/InAppMessage/models/full-screen-message.js +7 -7
  21. package/src/InAppMessage/models/html-message.js +8 -8
  22. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  23. package/src/InAppMessage/models/in-app-message.js +42 -42
  24. package/src/InAppMessage/models/modal-message.js +8 -8
  25. package/src/InAppMessage/models/slide-up-message.js +6 -6
  26. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  27. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  28. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  29. package/src/Push/push-manager-factory.js +2 -2
  30. package/src/Push/utils/push-utils.js +6 -6
  31. package/src/User/user-manager.js +2 -2
  32. package/src/User/user.js +9 -9
  33. package/src/common/content-cards-display.js +1 -1
  34. package/src/l10n/l10n-manager-factory.js +1 -1
  35. package/src/managers/braze-instance.js +99 -95
  36. package/src/managers/device-manager.js +2 -2
  37. package/src/managers/network-manager.js +116 -116
  38. package/src/managers/server-config-manager.js +33 -33
  39. package/src/managers/session-manager.js +1 -1
  40. package/src/managers/storage-manager-factory.js +8 -8
  41. package/src/managers/storage-manager.js +45 -48
  42. package/src/managers/subscription-manager.js +8 -8
  43. package/src/models/backend-errors.js +5 -5
  44. package/src/models/braze-event.js +1 -1
  45. package/src/models/device.js +1 -1
  46. package/src/models/push-token.js +6 -6
  47. package/src/models/server-config.js +29 -29
  48. package/src/request-controller.js +91 -91
  49. package/src/triggers/models/trigger-condition.js +25 -25
  50. package/src/triggers/models/trigger.js +7 -7
  51. package/src/triggers/triggers-provider-factory.js +1 -1
  52. package/src/triggers/triggers-provider.js +12 -12
  53. package/src/ui/js/attach-css.js +1 -1
  54. package/src/ui/js/load-font-awesome.js +1 -1
  55. package/src/util/braze-actions.js +2 -2
  56. package/src/util/browser-detector.js +1 -1
  57. package/src/util/net.js +2 -2
  58. package/src/util/request-header-utils.js +12 -12
  59. package/src/util/window-utils.js +1 -1
@@ -28,15 +28,15 @@ const vt = {
28
28
  null != window.Notification &&
29
29
  null != window.Notification.permission &&
30
30
  "granted" === window.Notification.permission,
31
- En: () =>
31
+ Gn: () =>
32
32
  vt.isPushBlocked()
33
- ? { Gn: !1, reason: "blocked" }
33
+ ? { Nn: !1, reason: "blocked" }
34
34
  : vt.isPushSupported()
35
35
  ? vt.isPushPermissionGranted()
36
- ? { Gn: !1, reason: "permissionGranted" }
37
- : { Gn: !0 }
38
- : { Gn: !1, reason: "unsupported" },
39
- Nn: (o, i) =>
36
+ ? { Nn: !1, reason: "permissionGranted" }
37
+ : { Nn: !0 }
38
+ : { Nn: !1, reason: "unsupported" },
39
+ $n: (o, i) =>
40
40
  "blocked" === o
41
41
  ? `${i} containing a push prompt is not being shown because the user has already declined push permission prompt.`
42
42
  : "unsupported" === o
@@ -55,7 +55,7 @@ export default class bt {
55
55
  const r = et.Us.Rs,
56
56
  h = new et(r, E),
57
57
  n = new oi(t, i, e, u, o);
58
- this.B.bt(s.ft.Uu, n.gt()), h.setItem(r.Fs.Fu, r.fe, !0);
58
+ this.B.bt(s.ft.Uu, n.gt()), h.setItem(r.Fs.Fu, r.ge, !0);
59
59
  }
60
60
  wu(t) {
61
61
  if (
@@ -67,7 +67,7 @@ export default class bt {
67
67
  ) {
68
68
  const t = et.Us.Rs,
69
69
  i = new et(t, E);
70
- this.B.bt(s.ft.Uu, !1), i.setItem(t.Fs.Fu, t.fe, !1);
70
+ this.B.bt(s.ft.Uu, !1), i.setItem(t.Fs.Fu, t.ge, !1);
71
71
  }
72
72
  }
73
73
  }
package/src/User/user.js CHANGED
@@ -246,7 +246,7 @@ export default class User {
246
246
  "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.",
247
247
  ),
248
248
  !1)
249
- : this.Ru.Na(t, e, r).W)
249
+ : this.Ru.Ra(t, e, r).W)
250
250
  );
251
251
  }
252
252
  addToSubscriptionGroup(t) {
@@ -260,7 +260,7 @@ export default class User {
260
260
  "addToSubscriptionGroup requires a non-empty subscription group ID",
261
261
  ),
262
262
  !1)
263
- : this.Ru.Ra(t, User.Pa.SUBSCRIBED).W;
263
+ : this.Ru.Pa(t, User.Oa.SUBSCRIBED).W;
264
264
  }
265
265
  removeFromSubscriptionGroup(t) {
266
266
  return !ir(
@@ -273,21 +273,21 @@ export default class User {
273
273
  "removeFromSubscriptionGroup requires a non-empty subscription group ID",
274
274
  ),
275
275
  !1)
276
- : this.Ru.Ra(t, User.Pa.UNSUBSCRIBED).W;
276
+ : this.Ru.Pa(t, User.Oa.UNSUBSCRIBED).W;
277
277
  }
278
278
  setLineId(t) {
279
279
  return ir(t, "set LINE user ID", "the ID", !0) &&
280
280
  0 !== (null == t ? void 0 : t.length)
281
- ? t && t.length > User.Oa
281
+ ? t && t.length > User.Ya
282
282
  ? (E.error(
283
- `Rejected LINE user ID ${t} because it is longer than ${User.Oa} characters.`,
283
+ `Rejected LINE user ID ${t} because it is longer than ${User.Ya} characters.`,
284
284
  ),
285
285
  !1)
286
286
  : this.vs.zu("native_line_id", t)
287
287
  : (E.error("setLineId requires a non-empty ID"), !1);
288
288
  }
289
289
  gu(t, e, r, s, n) {
290
- this.vs.gu(t, e, r, s, n), this.Ru.Ya();
290
+ this.vs.gu(t, e, r, s, n), this.Ru.Va();
291
291
  }
292
292
  wu(t) {
293
293
  this.vs.wu(t);
@@ -307,8 +307,8 @@ export default class User {
307
307
  UNSUBSCRIBED: "unsubscribed",
308
308
  }),
309
309
  (User.Hu = /^[0-9 .\\(\\)\\+\\-]+$/),
310
- (User.Pa = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
311
- (User.Va = "user_id"),
310
+ (User.Oa = { SUBSCRIBED: "subscribed", UNSUBSCRIBED: "unsubscribed" }),
311
+ (User.Wa = "user_id"),
312
312
  (User.Bu = "custom"),
313
313
  (User.mr = 997),
314
- (User.Oa = 33);
314
+ (User.Ya = 33);
@@ -188,7 +188,7 @@ export function updateContentCards(t, e, n, o, s) {
188
188
  if (t.url && to.test(t.url)) {
189
189
  const e = eo(t.url);
190
190
  if (gt(e)) {
191
- E.error(dt(jt.Pn, "Content Card"));
191
+ E.error(dt(jt.En, "Content Card"));
192
192
  continue;
193
193
  }
194
194
  }
@@ -8,7 +8,7 @@ const Me = {
8
8
  if ((Me.t(), !Me.na)) {
9
9
  let e = ro.language,
10
10
  t = !1;
11
- r.re(D.Wa) && ((e = r.re(D.Wa)), (t = !0)), (Me.na = new mr(e, t));
11
+ r.re(D.Xa) && ((e = r.re(D.Xa)), (t = !0)), (Me.na = new mr(e, t));
12
12
  }
13
13
  return Me.na;
14
14
  },
@@ -24,42 +24,43 @@ import { User } from "../User/index.js";
24
24
  import { parseQueryStringKeyValues as ll } from "../util/url-utils.js";
25
25
  import { WindowUtils as no } from "../util/window-utils.js";
26
26
  import { CoreStrings as z } from "../common/constants.js";
27
- import { SupportedOptions as $t, logger as E } from "../../shared-lib/index.js";
27
+ import { SupportedOptions as Yt, logger as E } from "../../shared-lib/index.js";
28
28
  import _t from "../models/identifier.js";
29
29
  const D = {
30
30
  Ph: "allowCrawlerActivity",
31
31
  Wh: "baseUrl",
32
+ le: "cookieExpiryInDays",
32
33
  Vh: "noCookies",
33
34
  Kh: "devicePropertyAllowlist",
34
- La: "disablePushTokenMaintenance",
35
- $h: "enableLogging",
36
- Yh: "enableSdkAuthentication",
37
- Ka: "manageServiceWorkerExternally",
35
+ Na: "disablePushTokenMaintenance",
36
+ Yh: "enableLogging",
37
+ $h: "enableSdkAuthentication",
38
+ La: "manageServiceWorkerExternally",
38
39
  Xh: "minimumIntervalBetweenTriggerActionsInSeconds",
39
40
  Zh: "sessionTimeoutInSeconds",
40
41
  Qh: "appVersion",
41
- Xa: "appVersionNumber",
42
- Ga: "serviceWorkerLocation",
43
- Ia: "safariWebsitePushId",
44
- Wa: "localization",
42
+ Za: "appVersionNumber",
43
+ Ha: "serviceWorkerLocation",
44
+ Ka: "safariWebsitePushId",
45
+ Xa: "localization",
45
46
  er: "contentSecurityNonce",
46
47
  te: "allowUserSuppliedJavascript",
47
48
  $a: "inAppMessageZIndex",
48
49
  Ja: "openInAppMessagesInNewTab",
49
50
  tn: "openCardsInNewTab",
50
51
  Oh: "requireExplicitInAppMessageDismissal",
51
- Za: "doNotLoadFontAwesome",
52
- tl: "deviceId",
53
- Ha: "serviceWorkerScope",
54
- Ne: "dustHost",
55
- il: "sdkFlavor",
52
+ tl: "doNotLoadFontAwesome",
53
+ il: "deviceId",
54
+ Ia: "serviceWorkerScope",
55
+ Te: "dustHost",
56
+ sl: "sdkFlavor",
56
57
  };
57
- class qt {
58
+ class $t {
58
59
  constructor() {
59
60
  (this.tu = ""),
60
- (this.sl = ""),
61
- (this.rl = void 0),
62
- (this.hl = null),
61
+ (this.rl = ""),
62
+ (this.hl = void 0),
63
+ (this.al = null),
63
64
  (this.eu = null),
64
65
  (this.j = null),
65
66
  (this.Ru = null),
@@ -67,29 +68,29 @@ class qt {
67
68
  (this.C = null),
68
69
  (this.B = null),
69
70
  (this.vs = null),
70
- (this.al = ""),
71
+ (this.ul = ""),
71
72
  (this.isInitialized = !1),
72
- (this.ul = !1),
73
- (this.cl = new m()),
73
+ (this.cl = !1),
74
74
  (this.fl = new m()),
75
+ (this.ml = new m()),
75
76
  (this.options = {}),
76
- (this.ml = []),
77
- (this.dl = []),
78
- (this.jn = []),
79
- (this.sl = "6.5.0");
77
+ (this.El = []),
78
+ (this.Il = []),
79
+ (this.vn = []),
80
+ (this.rl = "6.6.0");
80
81
  }
81
- El(t) {
82
- this.cl.Rt(t);
82
+ dl(t) {
83
+ this.fl.Rt(t);
83
84
  }
84
85
  mh(t) {
85
- this.fl.Rt(t);
86
+ this.ml.Rt(t);
86
87
  }
87
88
  initialize(t, i) {
88
89
  if (this.ao())
89
90
  return E.info("Braze has already been initialized with an API key."), !0;
90
91
  this.options = i || {};
91
- let e = this.re(D.$h);
92
- const r = ll(no.gl());
92
+ let e = this.re(D.Yh);
93
+ const r = ll(no._l());
93
94
  if (
94
95
  (r && "true" === r.brazeLogging && (e = !0),
95
96
  E.init(e),
@@ -109,80 +110,83 @@ class qt {
109
110
  ((o = document.createElement("a")),
110
111
  (o.href = n),
111
112
  "/" === o.pathname && (o = `${o}api/v3`),
112
- (this.al = o.toString()),
113
- ro.Il && !this.re(D.Ph))
113
+ (this.ul = o.toString()),
114
+ ro.gl && !this.re(D.Ph))
114
115
  )
115
116
  return (
116
117
  E.info("Ignoring activity from crawler bot " + navigator.userAgent),
117
- (this.ul = !0),
118
+ (this.cl = !0),
118
119
  !1
119
120
  );
120
- const h = this.re(D.Vh) || !1;
121
+ const h = this.re(D.Vh) || !1,
122
+ a = this.re(D.le);
121
123
  if (
122
- ((this.B = Kt._l(t, h)), h && this.B.Sl(t), new ee.le(null, !0).jr(s.pe))
124
+ ((this.B = Kt.Sl(t, h, a)),
125
+ h && this.B.Al(t),
126
+ new ee.me(null, !0).jr(s.be))
123
127
  )
124
128
  return (
125
129
  E.info("Ignoring all activity due to previous opt out"),
126
- (this.ul = !0),
130
+ (this.cl = !0),
127
131
  !1
128
132
  );
129
133
  for (const t of C(this.options))
130
- -1 === Pt($t).indexOf(t) &&
134
+ -1 === Pt(Yt).indexOf(t) &&
131
135
  E.warn(`Ignoring unknown initialization option '${t}'.`);
132
- const a = ["mparticle", "wordpress", "tealium"];
133
- if (null != this.re(D.il)) {
134
- const t = this.re(D.il);
135
- -1 !== a.indexOf(t)
136
- ? (this.rl = t)
136
+ const l = ["mparticle", "wordpress", "tealium"];
137
+ if (null != this.re(D.sl)) {
138
+ const t = this.re(D.sl);
139
+ -1 !== l.indexOf(t)
140
+ ? (this.hl = t)
137
141
  : E.error("Invalid sdk flavor passed: " + t);
138
142
  }
139
- let l = this.re($t.Kh);
140
- if (null != l)
141
- if (R(l)) {
143
+ let u = this.re(Yt.Kh);
144
+ if (null != u)
145
+ if (R(u)) {
142
146
  const t = [];
143
- for (let i = 0; i < l.length; i++)
147
+ for (let i = 0; i < u.length; i++)
144
148
  ta(
145
149
  DeviceProperties,
146
- l[i],
150
+ u[i],
147
151
  "devicePropertyAllowlist contained an invalid value.",
148
152
  "DeviceProperties",
149
- ) && t.push(l[i]);
150
- l = t;
153
+ ) && t.push(u[i]);
154
+ u = t;
151
155
  } else
152
156
  E.error(
153
157
  "devicePropertyAllowlist must be an array. Defaulting to all properties.",
154
158
  ),
155
- (l = null);
156
- const u = this.re(D.tl);
157
- if (u) {
158
- const t = new _t(u);
159
- this.B.Iu(s.Ou.tl, t);
159
+ (u = null);
160
+ const c = this.re(D.il);
161
+ if (c) {
162
+ const t = new _t(c);
163
+ this.B.Iu(s.Ou.il, t);
160
164
  }
161
- (this.eu = new Ot(this.B, l)),
165
+ (this.eu = new Ot(this.B, u)),
162
166
  (this.h = new Bt(this.B)),
163
167
  (this.vs = new bt(this.h, this.B)),
164
168
  (this.C = new Vt(this.B, this.vs, this.h, this.re(D.Zh)));
165
- const c = new m();
169
+ const f = new m();
166
170
  return (
167
- (this.hl = new kt(this.B, this.re(D.Yh), c)),
168
- this.q(c),
171
+ (this.al = new kt(this.B, this.re(D.$h), f)),
172
+ this.q(f),
169
173
  (this.j = new Mt(
170
174
  this.eu,
171
175
  this.B,
172
- this.hl,
176
+ this.al,
173
177
  this.vs,
174
178
  this.C,
175
179
  this.h,
176
180
  this.tu,
177
- this.al,
178
- this.sl,
179
- this.rl || "",
181
+ this.ul,
182
+ this.rl,
183
+ this.hl || "",
180
184
  this.re(D.Qh),
181
- this.re(D.Xa),
185
+ this.re(D.Za),
182
186
  )),
183
187
  (this.Ru = new Wt(
184
188
  this.tu,
185
- this.al,
189
+ this.ul,
186
190
  this.C,
187
191
  this.eu,
188
192
  this.vs,
@@ -191,11 +195,11 @@ class qt {
191
195
  (t) => {
192
196
  if (this.ao()) for (const i of this.gr()) i.N(t);
193
197
  },
194
- this.hl,
198
+ this.al,
195
199
  this.j,
196
200
  )),
197
201
  this.Ru.initialize(),
198
- h || this.B.Al(),
202
+ h || this.B.Nl(),
199
203
  E.info(
200
204
  `Initialized for the Braze backend at "${this.re(
201
205
  D.Wh,
@@ -221,7 +225,7 @@ class qt {
221
225
  (0, t.default)(void 0, void 0, !0);
222
226
  });
223
227
  }),
224
- this.cl.L(this.options),
228
+ this.fl.L(this.options),
225
229
  (this.isInitialized = !0),
226
230
  window.dispatchEvent(new CustomEvent("braze.initialized")),
227
231
  !0
@@ -229,40 +233,40 @@ class qt {
229
233
  }
230
234
  destroy(t) {
231
235
  if ((E.destroy(), this.ao())) {
232
- this.fl.L(), this.fl.removeAllSubscriptions();
233
- for (const t of this.ml) t.destroy();
234
- this.ml = [];
235
- for (const t of this.dl) t.clearData(!1);
236
+ this.ml.L(), this.ml.removeAllSubscriptions();
237
+ for (const t of this.El) t.destroy();
238
+ this.El = [];
239
+ for (const t of this.Il) t.clearData(!1);
236
240
  this.j && this.j.fo(),
237
- (this.dl = []),
241
+ (this.Il = []),
238
242
  this.removeAllSubscriptions(),
239
- (this.jn = []),
243
+ (this.vn = []),
240
244
  null != this.Ru && this.Ru.destroy(),
241
245
  (this.Ru = null),
242
- (this.hl = null),
246
+ (this.al = null),
243
247
  (this.eu = null),
244
248
  (this.j = null),
245
249
  (this.h = null),
246
250
  (this.C = null),
247
251
  (this.vs = null),
248
252
  (this.options = {}),
249
- (this.rl = void 0),
253
+ (this.hl = void 0),
250
254
  (this.isInitialized = !1),
251
- (this.ul = !1),
255
+ (this.cl = !1),
252
256
  t && (this.B = null);
253
257
  }
254
258
  }
255
259
  rr() {
256
- return !this.Nl() && (!!this.ao() || (console.warn(z.ee), !1));
260
+ return !this.vl() && (!!this.ao() || (console.warn(z.ee), !1));
257
261
  }
258
262
  _a() {
259
263
  return this.tu;
260
264
  }
261
265
  Sr() {
262
- return this.hl;
266
+ return this.al;
263
267
  }
264
268
  V() {
265
- return this.al;
269
+ return this.ul;
266
270
  }
267
271
  ue() {
268
272
  return this.eu;
@@ -274,7 +278,7 @@ class qt {
274
278
  return this.options[t];
275
279
  }
276
280
  gr() {
277
- return this.dl;
281
+ return this.Il;
278
282
  }
279
283
  nn() {
280
284
  return this.Ru;
@@ -299,39 +303,39 @@ class qt {
299
303
  }
300
304
  g(t) {
301
305
  let i = !1;
302
- for (const s of this.ml) s === t && (i = !0);
303
- i || this.ml.push(t);
306
+ for (const s of this.El) s === t && (i = !0);
307
+ i || this.El.push(t);
304
308
  }
305
309
  v(i) {
306
310
  let s = !1;
307
- for (const t of this.dl) t.constructor === i.constructor && (s = !0);
308
- i instanceof t && !s && this.dl.push(i);
311
+ for (const t of this.Il) t.constructor === i.constructor && (s = !0);
312
+ i instanceof t && !s && this.Il.push(i);
309
313
  }
310
314
  q(t) {
311
- t instanceof m && this.jn.push(t);
315
+ t instanceof m && this.vn.push(t);
312
316
  }
313
317
  removeAllSubscriptions() {
314
- if (this.rr()) for (const t of this.jn) t.removeAllSubscriptions();
318
+ if (this.rr()) for (const t of this.vn) t.removeAllSubscriptions();
315
319
  }
316
320
  removeSubscription(t) {
317
- if (this.rr()) for (const i of this.jn) i.removeSubscription(t);
321
+ if (this.rr()) for (const i of this.vn) i.removeSubscription(t);
318
322
  }
319
- ge(t) {
320
- this.ul = t;
323
+ we(t) {
324
+ this.cl = t;
321
325
  }
322
326
  ao() {
323
327
  return this.isInitialized;
324
328
  }
325
- Nl() {
326
- return this.ul;
329
+ vl() {
330
+ return this.cl;
327
331
  }
328
332
  tr(t, i) {
329
333
  if (!this.rr()) return null;
330
- return nr.o().Be(t, i);
334
+ return nr.o().Ge(t, i);
331
335
  }
332
336
  Vs() {
333
- return this.sl;
337
+ return this.rl;
334
338
  }
335
339
  }
336
- const r = new qt();
337
- export { r as default, qt as BrazeSdkInstance, D as OPTIONS };
340
+ const r = new $t();
341
+ export { r as default, $t as BrazeSdkInstance, D as OPTIONS };
@@ -15,8 +15,8 @@ export default class Ot {
15
15
  (this.tc = e);
16
16
  }
17
17
  ve(t = !0) {
18
- let e = this.B.$u(s.Ou.tl);
19
- null == e && ((e = new _t(P.se())), t && this.B.Iu(s.Ou.tl, e));
18
+ let e = this.B.$u(s.Ou.il);
19
+ null == e && ((e = new _t(P.se())), t && this.B.Iu(s.Ou.il, e));
20
20
  const r = new Jt(e.Tu);
21
21
  for (let t = 0; t < this.tc.length; t++) {
22
22
  switch (this.tc[t]) {