@braze/web-sdk 6.10.2 → 6.12.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 (109) hide show
  1. package/index.d.ts +61 -6
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +3 -3
  4. package/shared-lib/event-types.js +12 -12
  5. package/shared-lib/indexed-db-adapter.js +52 -52
  6. package/shared-lib/logger.js +7 -7
  7. package/shared-lib/supported-options.js +10 -10
  8. package/src/Core/logout.js +2 -2
  9. package/src/DUST/dust-config-store.js +89 -0
  10. package/src/DUST/dust-connection-core.js +7 -21
  11. package/src/DUST/dust-message-dedup.js +33 -0
  12. package/src/DUST/dust-provider.js +367 -397
  13. package/src/DUST/dust-tab-identity.js +30 -0
  14. package/src/DUST/index.js +7 -9
  15. package/src/DUST/subscribe-to-dust.js +5 -5
  16. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  17. package/src/FeatureFlags/feature-flag.js +5 -5
  18. package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
  19. package/src/FeatureFlags/feature-flags-provider.js +74 -74
  20. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  21. package/src/FeatureFlags/get-feature-flag.js +2 -2
  22. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  23. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  24. package/src/InAppMessage/constants.js +39 -47
  25. package/src/InAppMessage/defer-in-app-message.js +2 -2
  26. package/src/InAppMessage/display/get-animation-effect.js +1 -1
  27. package/src/InAppMessage/display/html-message-display-utils.js +4 -4
  28. package/src/InAppMessage/display/html-message-to-html.js +10 -10
  29. package/src/InAppMessage/display/in-app-message-to-html.js +68 -66
  30. package/src/InAppMessage/display/modal-utils.js +14 -14
  31. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  32. package/src/InAppMessage/in-app-message-factory.js +6 -6
  33. package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
  34. package/src/InAppMessage/in-app-message-manager.js +101 -80
  35. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  36. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  37. package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
  38. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  39. package/src/InAppMessage/models/full-screen-message.js +25 -25
  40. package/src/InAppMessage/models/html-message.js +14 -14
  41. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  42. package/src/InAppMessage/models/in-app-message.js +100 -98
  43. package/src/InAppMessage/models/modal-message.js +23 -23
  44. package/src/InAppMessage/models/slide-up-message.js +29 -29
  45. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  46. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  47. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +2 -2
  48. package/src/InAppMessage/ui/show-in-app-message.js +42 -40
  49. package/src/Push/index.js +1 -0
  50. package/src/Push/is-push-blocked.js +2 -2
  51. package/src/Push/is-push-permission-granted.js +2 -2
  52. package/src/Push/is-push-supported.js +2 -2
  53. package/src/Push/push-manager-factory.js +6 -6
  54. package/src/Push/push-manager.js +228 -185
  55. package/src/Push/register-push.js +9 -0
  56. package/src/Push/unregister-push-token-on-server.js +4 -4
  57. package/src/Push/utils/push-utils.js +16 -16
  58. package/src/User/user-manager.js +19 -19
  59. package/src/User/user.js +36 -36
  60. package/src/common/constants.js +1 -1
  61. package/src/common/content-cards-display.js +21 -21
  62. package/src/common/event-logger.js +2 -2
  63. package/src/l10n/l10n-manager-factory.js +7 -7
  64. package/src/l10n/l10n-manager.js +5 -5
  65. package/src/managers/auth-manager.js +1 -1
  66. package/src/managers/braze-instance.js +70 -66
  67. package/src/managers/device-manager.js +12 -12
  68. package/src/managers/network-manager.js +118 -118
  69. package/src/managers/server-config-manager.js +84 -84
  70. package/src/managers/session-manager.js +10 -10
  71. package/src/managers/storage-manager-factory.js +4 -4
  72. package/src/managers/storage-manager.js +138 -136
  73. package/src/managers/subscription-manager.js +1 -1
  74. package/src/managers/utils.js +1 -1
  75. package/src/models/backend-errors.js +5 -5
  76. package/src/models/braze-event.js +7 -7
  77. package/src/models/device.js +2 -2
  78. package/src/models/identifier.js +6 -6
  79. package/src/models/push-token.js +6 -6
  80. package/src/models/server-config.js +31 -31
  81. package/src/request-controller.js +91 -91
  82. package/src/triggers/models/filter.js +58 -58
  83. package/src/triggers/models/in-app-message-click-data.js +4 -4
  84. package/src/triggers/models/push-click-data.js +2 -2
  85. package/src/triggers/models/trigger-condition.js +35 -35
  86. package/src/triggers/models/trigger.js +37 -37
  87. package/src/triggers/triggers-provider-factory.js +3 -3
  88. package/src/triggers/triggers-provider.js +61 -53
  89. package/src/types.js +1 -1
  90. package/src/ui/js/attach-css.js +1 -1
  91. package/src/ui/js/feed-css.js +2 -2
  92. package/src/ui/js/iam-css.js +2 -2
  93. package/src/util/base-device-parser.js +1 -1
  94. package/src/util/braze-actions.js +4 -4
  95. package/src/util/browser-detector.js +13 -13
  96. package/src/util/client-hints-parser.js +4 -4
  97. package/src/util/component-utils.js +4 -4
  98. package/src/util/dom-utils.js +5 -5
  99. package/src/util/ecommerce-event-validation.js +77 -48
  100. package/src/util/key-codes.js +1 -1
  101. package/src/util/net.js +4 -4
  102. package/src/util/request-header-utils.js +20 -20
  103. package/src/util/string-utils.js +5 -0
  104. package/src/util/user-agent-parser.js +15 -15
  105. package/src/util/validation-utils.js +9 -9
  106. package/src/util/window-utils.js +2 -2
  107. package/src/DUST/dust-shared-worker-code.js +0 -2
  108. package/src/DUST/dust-shared-worker-impl.js +0 -234
  109. package/src/DUST/dust-worker-bridge.js +0 -151
@@ -1,30 +1,30 @@
1
- import Gt from "./auth-manager.js";
1
+ import Vt from "./auth-manager.js";
2
2
  import t from "../common/base-provider.js";
3
3
  import ro from "../util/browser-detector.js";
4
- import Pt from "./device-manager.js";
4
+ import Wt from "./device-manager.js";
5
5
  import DeviceProperties from "../Core/device-properties.js";
6
6
  import {
7
7
  isArray as g,
8
8
  keys as C,
9
9
  validateValueIsFromEnum as ta,
10
- values as Wt,
10
+ values as Yt,
11
11
  } from "../util/code-utils.js";
12
- import Vt from "./network-manager.js";
13
- import Kt from "../request-controller.js";
14
- import Yt from "./server-config-manager.js";
15
- import Xt from "./session-manager.js";
12
+ import Xt from "./network-manager.js";
13
+ import Zt from "../request-controller.js";
14
+ import li from "./server-config-manager.js";
15
+ import fi from "./session-manager.js";
16
16
  import ne, { STORAGE_KEYS as s } from "./storage-manager.js";
17
- import Zt from "./storage-manager-factory.js";
17
+ import di from "./storage-manager-factory.js";
18
18
  import f from "./subscription-manager.js";
19
19
  import { TriggersProviderFactory as rt } from "../triggers/triggers-provider-factory.js";
20
20
  import dr from "../DUST/dust-provider-factory.js";
21
- import { subscribeToDust as Qt } from "../DUST/subscribe-to-dust.js";
21
+ import { subscribeToDust as mi } from "../DUST/subscribe-to-dust.js";
22
22
  import Ut from "../User/user-manager.js";
23
23
  import { User } from "../User/index.js";
24
- import { parseQueryStringKeyValues as lt } from "../util/url-utils.js";
24
+ import { parseQueryStringKeyValues as pt } from "../util/url-utils.js";
25
25
  import { WindowUtils as no } from "../util/window-utils.js";
26
26
  import { CoreStrings as R } from "../common/constants.js";
27
- import { SupportedOptions as li, logger as b } from "../../shared-lib/index.js";
27
+ import { SupportedOptions as pi, logger as b } from "../../shared-lib/index.js";
28
28
  import _t from "../models/identifier.js";
29
29
  const U = {
30
30
  _h: "allowCrawlerActivity",
@@ -32,36 +32,36 @@ const U = {
32
32
  se: "cookieExpiryInDays",
33
33
  Oh: "noCookies",
34
34
  Th: "devicePropertyAllowlist",
35
- ka: "disablePushTokenMaintenance",
35
+ xa: "disablePushTokenMaintenance",
36
36
  Rh: "enableLogging",
37
37
  Ph: "enableSdkAuthentication",
38
- _a: "manageServiceWorkerExternally",
38
+ wa: "manageServiceWorkerExternally",
39
39
  Dh: "minimumIntervalBetweenTriggerActionsInSeconds",
40
40
  Lh: "sessionTimeoutInSeconds",
41
41
  yh: "appVersion",
42
42
  Mh: "appVersionNumber",
43
- xa: "serviceWorkerLocation",
44
- Ma: "safariWebsitePushId",
45
- Aa: "localization",
43
+ za: "serviceWorkerLocation",
44
+ ha: "safariWebsitePushId",
45
+ Ma: "localization",
46
46
  sr: "contentSecurityNonce",
47
47
  nr: "allowUserSuppliedJavascript",
48
- ja: "inAppMessageZIndex",
49
- ba: "openInAppMessagesInNewTab",
48
+ ca: "inAppMessageZIndex",
49
+ da: "openInAppMessagesInNewTab",
50
50
  tn: "openCardsInNewTab",
51
- oh: "requireExplicitInAppMessageDismissal",
51
+ lh: "requireExplicitInAppMessageDismissal",
52
52
  Uh: "doNotLoadFontAwesome",
53
53
  Wh: "deviceId",
54
- ya: "serviceWorkerScope",
55
- Ye: "dustHost",
54
+ ba: "serviceWorkerScope",
55
+ Oi: "dustHost",
56
56
  Bh: "sdkFlavor",
57
57
  };
58
- class ci {
58
+ class Ei {
59
59
  constructor() {
60
- (this.tu = ""),
60
+ (this.eu = ""),
61
61
  (this.Vh = ""),
62
62
  (this.Kh = void 0),
63
63
  (this.Gh = null),
64
- (this.eu = null),
64
+ (this.tu = null),
65
65
  (this.B = null),
66
66
  (this.Ru = null),
67
67
  (this.h = null),
@@ -77,12 +77,12 @@ class ci {
77
77
  (this.Jh = []),
78
78
  (this.Xh = []),
79
79
  (this.In = []),
80
- (this.Vh = "6.10.2");
80
+ (this.Vh = "6.12.0");
81
81
  }
82
82
  Zh(t) {
83
83
  this.qh.Ut(t);
84
84
  }
85
- uh(t) {
85
+ ah(t) {
86
86
  this.Hh.Ut(t);
87
87
  }
88
88
  initialize(t, i) {
@@ -91,7 +91,7 @@ class ci {
91
91
  return b.info("Braze has already been initialized with an API key."), !0;
92
92
  this.options = i || {};
93
93
  let n = this.er(U.Rh);
94
- const h = lt(no.Qh());
94
+ const h = pt(no.Qh());
95
95
  if (
96
96
  (h && "true" === h.brazeLogging && (n = !0),
97
97
  b.init(n),
@@ -101,7 +101,7 @@ class ci {
101
101
  null == t || "" === t || "string" != typeof t)
102
102
  )
103
103
  return b.error("Braze requires a valid API key to be initialized."), !1;
104
- this.tu = t;
104
+ this.eu = t;
105
105
  let l = this.er(U.Nh);
106
106
  if (null == l || "" === l || "string" != typeof l)
107
107
  return b.error("Braze requires a valid baseUrl to be initialized."), !1;
@@ -121,9 +121,9 @@ class ci {
121
121
  );
122
122
  const u = this.er(U.Oh) || !1,
123
123
  c = this.er(U.se),
124
- m = Zt.sl();
124
+ d = di.sl();
125
125
  if (
126
- ((this.j = Zt.rl(t, u, c)),
126
+ ((this.j = di.rl(t, u, c)),
127
127
  u && this.j.hl(t),
128
128
  new ne.le(null, !0).wr(s.ce))
129
129
  )
@@ -133,63 +133,63 @@ class ci {
133
133
  !1
134
134
  );
135
135
  for (const t of C(this.options))
136
- -1 === Wt(li).indexOf(t) &&
136
+ -1 === Yt(pi).indexOf(t) &&
137
137
  b.warn(`Ignoring unknown initialization option '${t}'.`);
138
- const p = ["mparticle", "wordpress", "tealium"];
138
+ const m = ["mparticle", "wordpress", "tealium"];
139
139
  if (null != this.er(U.Bh)) {
140
140
  const t = this.er(U.Bh);
141
- -1 !== p.indexOf(t)
141
+ -1 !== m.indexOf(t)
142
142
  ? (this.Kh = t)
143
143
  : b.error("Invalid sdk flavor passed: " + t);
144
144
  }
145
- let d = this.er(li.Th);
146
- if (null != d)
147
- if (g(d)) {
145
+ let p = this.er(pi.Th);
146
+ if (null != p)
147
+ if (g(p)) {
148
148
  const t = [];
149
- for (let i = 0; i < d.length; i++)
149
+ for (let i = 0; i < p.length; i++)
150
150
  ta(
151
151
  DeviceProperties,
152
- d[i],
152
+ p[i],
153
153
  "devicePropertyAllowlist contained an invalid value.",
154
154
  "DeviceProperties",
155
- ) && t.push(d[i]);
156
- d = t;
155
+ ) && t.push(p[i]);
156
+ p = t;
157
157
  } else
158
158
  b.error(
159
159
  "devicePropertyAllowlist must be an array. Defaulting to all properties.",
160
160
  ),
161
- (d = null);
161
+ (p = null);
162
162
  const E = this.er(U.Wh);
163
163
  if (E) {
164
164
  const t = new _t(E);
165
- this.j.Iu(s.Ou.Wh, t);
165
+ this.j.Ju(s.Ou.Wh, t);
166
166
  }
167
- (this.eu = new Pt(this.j, d)),
168
- (this.h = new Yt(this.j)),
167
+ (this.tu = new Wt(this.j, p)),
168
+ (this.h = new li(this.j)),
169
169
  (this.Ss = new Ut(this.h, this.j)),
170
- (this.C = new Xt(this.j, this.Ss, this.h, this.er(U.Lh)));
170
+ (this.C = new fi(this.j, this.Ss, this.h, this.er(U.Lh)));
171
171
  const I = new f();
172
- (this.Gh = new Gt(this.j, this.er(U.Ph), I)),
172
+ (this.Gh = new Vt(this.j, this.er(U.Ph), I)),
173
173
  this.S(I),
174
- (this.B = new Vt(
175
- this.eu,
174
+ (this.B = new Xt(
175
+ this.tu,
176
176
  this.j,
177
177
  this.Gh,
178
178
  this.Ss,
179
179
  this.C,
180
180
  this.h,
181
- this.tu,
181
+ this.eu,
182
182
  this.Yh,
183
183
  this.Vh,
184
184
  this.Kh || "",
185
185
  this.er(U.yh),
186
186
  this.er(U.Mh),
187
187
  )),
188
- (this.Ru = new Kt(
189
- this.tu,
188
+ (this.Ru = new Zt(
189
+ this.eu,
190
190
  this.Yh,
191
191
  this.C,
192
- this.eu,
192
+ this.tu,
193
193
  this.Ss,
194
194
  this.h,
195
195
  this.j,
@@ -204,14 +204,14 @@ class ci {
204
204
  b.info(
205
205
  `Initialized for the Braze backend at "${this.er(
206
206
  U.Nh,
207
- )}" with API key "${this.tu}".`,
207
+ )}" with API key "${this.eu}".`,
208
208
  ),
209
209
  rt.t(),
210
- Qt(),
211
- this.h.bo(() => {
210
+ mi(),
211
+ this.h.do(() => {
212
212
  var t;
213
213
  this.isInitialized &&
214
- (null === (t = this.h) || void 0 === t ? void 0 : t.lo()) &&
214
+ (null === (t = this.h) || void 0 === t ? void 0 : t.Kr()) &&
215
215
  import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
216
216
  if (!this.isInitialized) return;
217
217
  (0, t.default)();
@@ -220,7 +220,7 @@ class ci {
220
220
  this.Ru.rn(() => {
221
221
  var t;
222
222
  this.isInitialized &&
223
- (null === (t = this.h) || void 0 === t ? void 0 : t.lo()) &&
223
+ (null === (t = this.h) || void 0 === t ? void 0 : t.Kr()) &&
224
224
  import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
225
225
  if (!this.isInitialized) return;
226
226
  (0, t.default)(void 0, void 0, !0);
@@ -228,10 +228,14 @@ class ci {
228
228
  }),
229
229
  this.qh.A(this.options),
230
230
  (this.isInitialized = !0),
231
- window.dispatchEvent(new CustomEvent("braze.initialized"));
231
+ window.dispatchEvent(new CustomEvent("braze.initialized")),
232
+ this.ar("tgr", () => {
233
+ var t;
234
+ null === (t = this.Ru) || void 0 === t || t.Ar(void 0, void 0, "dust");
235
+ });
232
236
  const _ = null === (e = this.C) || void 0 === e ? void 0 : e.al();
233
237
  return (
234
- m ||
238
+ d ||
235
239
  null == _ ||
236
240
  (null === (r = this.C) || void 0 === r
237
241
  ? void 0
@@ -255,7 +259,7 @@ class ci {
255
259
  null != this.Ru && this.Ru.destroy(),
256
260
  (this.Ru = null),
257
261
  (this.Gh = null),
258
- (this.eu = null),
262
+ (this.tu = null),
259
263
  (this.B = null),
260
264
  (this.h = null),
261
265
  (this.C = null),
@@ -270,8 +274,8 @@ class ci {
270
274
  rr() {
271
275
  return !this.cl() && (!!this.ao() || (console.warn(R.ee), !1));
272
276
  }
273
- za() {
274
- return this.tu;
277
+ ja() {
278
+ return this.eu;
275
279
  }
276
280
  Er() {
277
281
  return this.Gh;
@@ -280,7 +284,7 @@ class ci {
280
284
  return this.Yh;
281
285
  }
282
286
  ue() {
283
- return this.eu;
287
+ return this.tu;
284
288
  }
285
289
  m() {
286
290
  return this.B;
@@ -342,11 +346,11 @@ class ci {
342
346
  }
343
347
  ar(t, i) {
344
348
  if (!this.rr()) return null;
345
- return dr.o().on(t, i);
349
+ return dr.o().mn(t, i);
346
350
  }
347
351
  qi() {
348
352
  return this.Vh;
349
353
  }
350
354
  }
351
- const r = new ci();
352
- export { r as default, ci as BrazeSdkInstance, U as OPTIONS };
355
+ const r = new Ei();
356
+ export { r as default, Ei as BrazeSdkInstance, U as OPTIONS };
@@ -1,23 +1,23 @@
1
1
  import ro from "../util/browser-detector.js";
2
- import Se from "../models/device.js";
2
+ import ke from "../models/device.js";
3
3
  import DeviceProperties from "../Core/device-properties.js";
4
4
  import _t from "../models/identifier.js";
5
5
  import { logger as b, Guid as V } from "../../shared-lib/index.js";
6
6
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
7
- import { values as Wt } from "../util/code-utils.js";
8
- import { getErrorMessage as hi } from "../util/error-utils.js";
9
- export default class Pt {
7
+ import { values as Yt } from "../util/code-utils.js";
8
+ import { getErrorMessage as ci } from "../util/error-utils.js";
9
+ export default class Wt {
10
10
  constructor(t, e) {
11
11
  (this.j = t),
12
12
  (this.Da = e),
13
13
  (this.j = t),
14
- null == e && (e = Wt(DeviceProperties)),
14
+ null == e && (e = Yt(DeviceProperties)),
15
15
  (this.Da = e);
16
16
  }
17
17
  ve(t = !0) {
18
18
  let e = this.j.$u(s.Ou.Wh);
19
- null == e && ((e = new _t(V.de())), t && this.j.Iu(s.Ou.Wh, e));
20
- const r = new Se(e.Tu);
19
+ null == e && ((e = new _t(V.de())), t && this.j.Ju(s.Ou.Wh, e));
20
+ const r = new ke(e.Iu);
21
21
  for (let t = 0; t < this.Da.length; t++) {
22
22
  switch (this.Da[t]) {
23
23
  case DeviceProperties.BROWSER:
@@ -45,8 +45,8 @@ export default class Pt {
45
45
  return r;
46
46
  }
47
47
  Fa() {
48
- if (ro.Ba()) return ro.Ba();
49
- const t = this.j.St(s.It.Ha);
48
+ if (ro.qa()) return ro.qa();
49
+ const t = this.j.St(s.It.Aa);
50
50
  return t && t.os_version ? t.os_version : ro.Fa();
51
51
  }
52
52
  Ja(t) {
@@ -60,15 +60,15 @@ export default class Pt {
60
60
  } catch (t) {
61
61
  b.info(
62
62
  "Intl.DateTimeFormat threw an error, cannot detect user's time zone:" +
63
- hi(t),
63
+ ci(t),
64
64
  ),
65
65
  (e = !0);
66
66
  }
67
67
  if (e) return "";
68
68
  const r = t.getTimezoneOffset();
69
- return this.Ka(r);
69
+ return this.Ba(r);
70
70
  }
71
- Ka(t) {
71
+ Ba(t) {
72
72
  const e = Math.trunc(t / 60),
73
73
  r = Math.trunc(t % 60);
74
74
  let s = "GMT";