@braze/web-sdk 4.9.0 → 5.0.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 (111) hide show
  1. package/index.d.ts +2204 -2230
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -1
  4. package/shared-lib/event-types.js +9 -9
  5. package/shared-lib/indexed-db-adapter.js +13 -13
  6. package/shared-lib/logger.js +2 -2
  7. package/shared-lib/supported-options.js +8 -8
  8. package/src/Card/models/captioned-image.js +19 -19
  9. package/src/Card/models/card.js +95 -94
  10. package/src/Card/models/classic-card.js +19 -19
  11. package/src/Card/models/control-card.js +9 -9
  12. package/src/Card/models/image-only.js +21 -22
  13. package/src/Card/models/index.js +0 -1
  14. package/src/Card/util/card-factory.js +39 -39
  15. package/src/ContentCards/content-cards-provider.js +114 -114
  16. package/src/ContentCards/get-cached-content-cards.js +1 -1
  17. package/src/ContentCards/index.js +0 -1
  18. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  19. package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
  20. package/src/ContentCards/ui/hide-content-cards.js +2 -2
  21. package/src/ContentCards/ui/show-content-cards.js +14 -14
  22. package/src/Core/add-sdk-metadata.js +2 -2
  23. package/src/Core/change-user.js +2 -2
  24. package/src/Core/disable-sdk.js +4 -4
  25. package/src/Core/enable-sdk.js +4 -4
  26. package/src/Core/get-device-id.js +9 -7
  27. package/src/Core/handle-braze-action.js +14 -14
  28. package/src/Core/is-disabled.js +2 -2
  29. package/src/Core/open-session.js +5 -5
  30. package/src/Core/set-sdk-authentication-signature.js +2 -2
  31. package/src/Core/wipe-data.js +4 -4
  32. package/src/FeatureFlags/feature-flag-factory.js +10 -10
  33. package/src/FeatureFlags/feature-flag.js +7 -7
  34. package/src/FeatureFlags/feature-flags-provider.js +50 -50
  35. package/src/FeatureFlags/get-all-feature-flags.js +1 -1
  36. package/src/FeatureFlags/get-feature-flag.js +3 -5
  37. package/src/Feed/feed-provider-factory.js +8 -8
  38. package/src/Feed/feed-provider.js +15 -15
  39. package/src/Feed/get-cached-feed.js +2 -2
  40. package/src/Feed/request-feed-refresh.js +2 -2
  41. package/src/Feed/subscribe-to-feed-updates.js +2 -2
  42. package/src/Feed/ui/hide-feed.js +2 -2
  43. package/src/Feed/ui/show-feed.js +13 -13
  44. package/src/InAppMessage/display/html-message-to-html.js +11 -12
  45. package/src/InAppMessage/display/in-app-message-to-html.js +15 -15
  46. package/src/InAppMessage/display/modal-utils.js +8 -8
  47. package/src/InAppMessage/in-app-message-factory.js +4 -4
  48. package/src/InAppMessage/in-app-message-manager.js +38 -38
  49. package/src/InAppMessage/models/full-screen-message.js +31 -31
  50. package/src/InAppMessage/models/html-message.js +16 -16
  51. package/src/InAppMessage/models/in-app-message-button.js +5 -5
  52. package/src/InAppMessage/models/in-app-message.js +46 -46
  53. package/src/InAppMessage/models/modal-message.js +30 -30
  54. package/src/InAppMessage/models/slide-up-message.js +26 -26
  55. package/src/InAppMessage/ui/show-in-app-message.js +9 -9
  56. package/src/Push/is-push-blocked.js +2 -2
  57. package/src/Push/is-push-permission-granted.js +2 -2
  58. package/src/Push/is-push-supported.js +2 -2
  59. package/src/Push/push-manager.js +31 -31
  60. package/src/Push/utils/push-utils.js +9 -9
  61. package/src/User/user-manager.js +8 -8
  62. package/src/User/user.js +38 -37
  63. package/src/common/base-feed.js +15 -14
  64. package/src/common/base-provider.js +1 -1
  65. package/src/common/event-logger.js +2 -2
  66. package/src/common/feed-display.js +32 -32
  67. package/src/l10n/l10n-manager-factory.js +9 -9
  68. package/src/managers/auth-manager.js +6 -6
  69. package/src/managers/braze-instance.js +84 -92
  70. package/src/managers/device-manager.js +9 -9
  71. package/src/managers/network-manager.js +72 -69
  72. package/src/managers/server-config-manager.js +13 -13
  73. package/src/managers/session-manager.js +9 -9
  74. package/src/managers/storage-manager-factory.js +11 -11
  75. package/src/managers/storage-manager.js +110 -110
  76. package/src/managers/subscription-manager.js +3 -3
  77. package/src/models/backend-errors.js +5 -5
  78. package/src/models/braze-event.js +7 -7
  79. package/src/models/identifier.js +1 -1
  80. package/src/models/push-token.js +1 -1
  81. package/src/models/server-config.js +6 -6
  82. package/src/request-controller.js +129 -125
  83. package/src/triggers/models/custom-event-data.js +1 -1
  84. package/src/triggers/models/custom-event-property-data.js +6 -6
  85. package/src/triggers/models/filter-set.js +8 -8
  86. package/src/triggers/models/filter.js +31 -31
  87. package/src/triggers/models/in-app-message-click-data.js +1 -1
  88. package/src/triggers/models/purchase-data.js +1 -1
  89. package/src/triggers/models/purchase-property-data.js +4 -4
  90. package/src/triggers/models/push-click-data.js +3 -3
  91. package/src/triggers/models/trigger-condition.js +30 -30
  92. package/src/triggers/models/trigger-events.js +1 -1
  93. package/src/triggers/models/trigger.js +32 -32
  94. package/src/triggers/triggers-provider.js +55 -55
  95. package/src/ui/js/attach-css.js +1 -1
  96. package/src/ui/js/feed-css.js +5 -5
  97. package/src/ui/js/iam-css.js +4 -4
  98. package/src/ui/js/load-font-awesome.js +1 -1
  99. package/src/util/braze-actions.js +4 -4
  100. package/src/util/browser-detector.js +11 -11
  101. package/src/util/client-hints-parser.js +5 -5
  102. package/src/util/component-utils.js +2 -2
  103. package/src/util/date-utils.js +2 -2
  104. package/src/util/device-constants.js +4 -5
  105. package/src/util/dom-utils.js +5 -5
  106. package/src/util/net.js +1 -1
  107. package/src/util/request-header-utils.js +17 -17
  108. package/src/util/user-agent-parser.js +11 -16
  109. package/src/util/validation-utils.js +9 -9
  110. package/src/Card/models/banner.js +0 -31
  111. package/src/ContentCards/log-content-cards-displayed.js +0 -5
@@ -1,68 +1,67 @@
1
1
  import kt from "./auth-manager.js";
2
2
  import y from "../common/base-provider.js";
3
- import V from "../util/browser-detector.js";
3
+ import Q from "../util/browser-detector.js";
4
4
  import Ot from "./device-manager.js";
5
5
  import DeviceProperties from "../Core/device-properties.js";
6
6
  import {
7
7
  isArray as p,
8
8
  keys as oo,
9
- validateValueIsFromEnum as H,
10
- values as Lt,
9
+ validateValueIsFromEnum as G,
10
+ values as Pt,
11
11
  } from "../util/code-utils.js";
12
- import { logDeprecationWarning as z } from "../util/deprecation-utils.js";
13
- import Pt from "./network-manager.js";
14
- import Rt from "../request-controller.js";
15
- import Mt from "./server-config-manager.js";
12
+ import Rt from "./network-manager.js";
13
+ import Lt from "../request-controller.js";
14
+ import jt from "./server-config-manager.js";
16
15
  import Dt from "./session-manager.js";
17
16
  import r from "../../shared-lib/braze-shared-lib.js";
18
- import O, { STORAGE_KEYS as i } from "./storage-manager.js";
19
- import Bt from "./storage-manager-factory.js";
17
+ import J, { STORAGE_KEYS as i } from "./storage-manager.js";
18
+ import Mt from "./storage-manager-factory.js";
20
19
  import E from "./subscription-manager.js";
21
20
  import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
22
21
  import bt from "../User/user-manager.js";
23
22
  import { User } from "../User/index.js";
24
- import { parseQueryStringKeyValues as ct } from "../util/url-utils.js";
25
- import { WindowUtils as Z } from "../util/window-utils.js";
23
+ import { parseQueryStringKeyValues as ut } from "../util/url-utils.js";
24
+ import { WindowUtils as Y } from "../util/window-utils.js";
26
25
  import { BRAZE_MUST_BE_INITIALIZED_ERROR as P } from "../common/constants.js";
27
26
  const L = {
28
27
  ho: "allowCrawlerActivity",
29
- Eo: "baseUrl",
30
- _o: "noCookies",
28
+ _o: "baseUrl",
29
+ Eo: "noCookies",
31
30
  Io: "devicePropertyAllowlist",
32
31
  Aa: "disablePushTokenMaintenance",
33
32
  Ao: "enableLogging",
34
33
  So: "enableSdkAuthentication",
35
34
  qa: "manageServiceWorkerExternally",
36
35
  No: "minimumIntervalBetweenTriggerActionsInSeconds",
37
- wo: "sessionTimeoutInSeconds",
38
- Oo: "appVersion",
36
+ Oo: "sessionTimeoutInSeconds",
37
+ wo: "appVersion",
38
+ Po: "appVersionNumber",
39
39
  _a: "serviceWorkerLocation",
40
40
  ka: "safariWebsitePushId",
41
41
  Ba: "localization",
42
42
  po: "contentSecurityNonce",
43
- Co: "enableHtmlInAppMessages",
44
- Lo: "allowUserSuppliedJavascript",
43
+ Ro: "allowUserSuppliedJavascript",
45
44
  lo: "inAppMessageZIndex",
46
45
  fo: "openInAppMessagesInNewTab",
47
46
  tn: "openCardsInNewTab",
48
47
  en: "openNewsFeedCardsInNewTab",
49
48
  mh: "requireExplicitInAppMessageDismissal",
50
- Po: "doNotLoadFontAwesome",
51
- Ro: "sdkFlavor",
49
+ Co: "doNotLoadFontAwesome",
50
+ Lo: "sdkFlavor",
52
51
  };
53
- class Wt {
52
+ class Bt {
54
53
  constructor() {
55
54
  (this.cn = ""),
56
- (this.Mo = ""),
57
- (this.jo = void 0),
58
- (this.Do = null),
55
+ (this.jo = ""),
56
+ (this.Do = void 0),
57
+ (this.Mo = null),
59
58
  (this.fn = null),
60
- (this.gt = null),
59
+ (this.$t = null),
61
60
  (this.ki = null),
62
- (this.wt = null),
61
+ (this.yt = null),
63
62
  (this._e = null),
64
63
  (this.u = null),
65
- (this.ft = null),
64
+ (this.wt = null),
66
65
  (this.Uo = ""),
67
66
  (this.Bo = !1),
68
67
  (this.Wo = !1),
@@ -72,13 +71,13 @@ class Wt {
72
71
  (this.Go = []),
73
72
  (this.Ko = []),
74
73
  (this.Ve = []),
75
- (this.Mo = "4.9.0");
74
+ (this.jo = "5.0.0");
76
75
  }
77
- Ho(t) {
78
- this.zo.lt(t);
76
+ $o(t) {
77
+ this.zo.It(t);
79
78
  }
80
79
  Rh(t) {
81
- this.Vo.lt(t);
80
+ this.Vo.It(t);
82
81
  }
83
82
  initialize(t, s) {
84
83
  if (this.fe())
@@ -87,7 +86,7 @@ class Wt {
87
86
  );
88
87
  this.options = s || {};
89
88
  let e = this.nn(L.Ao);
90
- const n = ct(Z.Cn());
89
+ const n = ut(Y.Cn());
91
90
  if (
92
91
  (n && "true" === n.brazeLogging && (e = !0),
93
92
  r.j.init(e),
@@ -98,7 +97,7 @@ class Wt {
98
97
  )
99
98
  return r.j.error("Braze requires a valid API key to be initialized."), !1;
100
99
  this.cn = t;
101
- let o = this.nn(L.Eo);
100
+ let o = this.nn(L._o);
102
101
  if (null == o || "" === o || "string" != typeof o)
103
102
  return r.j.error("Braze requires a valid baseUrl to be initialized."), !1;
104
103
  !1 === /^https?:/.test(o) && (o = `https://${o}`);
@@ -108,16 +107,16 @@ class Wt {
108
107
  (o.href = h),
109
108
  "/" === o.pathname && (o = `${o}api/v3`),
110
109
  (this.Uo = o.toString()),
111
- V.$o && !this.nn(L.ho))
110
+ Q.qo && !this.nn(L.ho))
112
111
  )
113
112
  return (
114
113
  r.j.info("Ignoring activity from crawler bot " + navigator.userAgent),
115
114
  (this.Wo = !0),
116
115
  !1
117
116
  );
118
- const a = this.nn(L._o) || !1;
117
+ const a = this.nn(L.Eo) || !1;
119
118
  if (
120
- ((this.u = Bt.qo(t, a)), a && this.u.xo(t), new O.ee(null, !0).jr(i.re))
119
+ ((this.u = Mt.xo(t, a)), a && this.u.Jo(t), new J.ee(null, !0).jr(i.re))
121
120
  )
122
121
  return (
123
122
  r.j.info("Ignoring all activity due to previous opt out"),
@@ -125,21 +124,21 @@ class Wt {
125
124
  !1
126
125
  );
127
126
  for (const t of oo(this.options))
128
- -1 === Lt(r.Jo).indexOf(t) &&
127
+ -1 === Pt(r.Yo).indexOf(t) &&
129
128
  r.j.warn(`Ignoring unknown initialization option '${t}'.`);
130
129
  const l = ["mparticle", "wordpress", "tealium"];
131
- if (null != this.nn(L.Ro)) {
132
- const t = this.nn(L.Ro);
130
+ if (null != this.nn(L.Lo)) {
131
+ const t = this.nn(L.Lo);
133
132
  -1 !== l.indexOf(t)
134
- ? (this.jo = t)
133
+ ? (this.Do = t)
135
134
  : r.j.error("Invalid sdk flavor passed: " + t);
136
135
  }
137
- let u = this.nn(r.Jo.Io);
136
+ let u = this.nn(r.Yo.Io);
138
137
  if (null != u)
139
138
  if (p(u)) {
140
139
  const t = [];
141
140
  for (let i = 0; i < u.length; i++)
142
- H(
141
+ G(
143
142
  DeviceProperties,
144
143
  u[i],
145
144
  "devicePropertyAllowlist contained an invalid value.",
@@ -152,57 +151,52 @@ class Wt {
152
151
  ),
153
152
  (u = null);
154
153
  (this.fn = new Ot(this.u, u)),
155
- (this.wt = new Mt(this.u)),
156
- (this.ft = new bt(this.wt, this.u)),
157
- (this._e = new Dt(this.u, this.ft, this.wt, this.nn(L.wo)));
154
+ (this.yt = new jt(this.u)),
155
+ (this.wt = new bt(this.yt, this.u)),
156
+ (this._e = new Dt(this.u, this.wt, this.yt, this.nn(L.Oo)));
158
157
  const f = new E();
159
158
  return (
160
- (this.Do = new kt(this.u, this.nn(L.So), f)),
161
- this.jt(f),
162
- (this.gt = new Pt(
159
+ (this.Mo = new kt(this.u, this.nn(L.So), f)),
160
+ this.Ht(f),
161
+ (this.$t = new Rt(
163
162
  this.fn,
164
163
  this.u,
165
- this.Do,
166
- this.ft,
167
- this._e,
164
+ this.Mo,
168
165
  this.wt,
166
+ this._e,
167
+ this.yt,
169
168
  this.cn,
170
169
  this.Uo,
171
- this.Mo,
172
- this.jo || "",
173
- this.nn(L.Oo),
170
+ this.jo,
171
+ this.Do || "",
172
+ this.nn(L.wo),
173
+ this.nn(L.Po),
174
174
  )),
175
- (this.ki = new Rt(
175
+ (this.ki = new Lt(
176
176
  this.cn,
177
177
  this.Uo,
178
178
  this._e,
179
179
  this.fn,
180
- this.ft,
181
180
  this.wt,
181
+ this.yt,
182
182
  this.u,
183
183
  (t) => {
184
- if (this.fe()) for (const i of this.gr()) i.Ts(t);
184
+ if (this.fe()) for (const i of this.gr()) i.Ss(t);
185
185
  },
186
- this.Do,
187
- this.gt,
186
+ this.Mo,
187
+ this.$t,
188
188
  )),
189
189
  this.ki.initialize(),
190
190
  r.j.info(
191
191
  `Initialized for the Braze backend at "${this.nn(
192
- L.Eo,
192
+ L._o,
193
193
  )}" with API key "${this.cn}".`,
194
194
  ),
195
- null != this.nn(L.Co) &&
196
- z(
197
- "enableHtmlInAppMessages",
198
- "initialization option",
199
- "allowUserSuppliedJavascript",
200
- ),
201
195
  et.o(),
202
- this.wt.Ci(() => {
196
+ this.yt.Ci(() => {
203
197
  this.Bo &&
204
- this.wt &&
205
- this.wt.vi() &&
198
+ this.yt &&
199
+ this.yt.yi() &&
206
200
  import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
207
201
  if (!this.Bo) return;
208
202
  (0, t.default)();
@@ -210,21 +204,21 @@ class Wt {
210
204
  }),
211
205
  this.ki.pr(() => {
212
206
  this.Bo &&
213
- this.wt &&
214
- this.wt.vi() &&
207
+ this.yt &&
208
+ this.yt.yi() &&
215
209
  import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
216
210
  if (!this.Bo) return;
217
211
  (0, t.default)(void 0, void 0, !0);
218
212
  });
219
213
  }),
220
- this.zo.Et(this.options),
214
+ this.zo.Dt(this.options),
221
215
  (this.Bo = !0),
222
216
  !0
223
217
  );
224
218
  }
225
219
  destroy(t) {
226
220
  if ((r.j.destroy(), this.fe())) {
227
- this.Vo.Et(), this.Vo.removeAllSubscriptions();
221
+ this.Vo.Dt(), this.Vo.removeAllSubscriptions();
228
222
  for (const t of this.Go) t.destroy();
229
223
  this.Go = [];
230
224
  for (const t of this.Ko) t.clearData(!1);
@@ -233,29 +227,27 @@ class Wt {
233
227
  (this.Ve = []),
234
228
  null != this.ki && this.ki.destroy(),
235
229
  (this.ki = null),
236
- (this.Do = null),
230
+ (this.Mo = null),
237
231
  (this.fn = null),
238
- (this.gt = null),
239
- (this.wt = null),
232
+ (this.$t = null),
233
+ (this.yt = null),
240
234
  (this._e = null),
241
- (this.ft = null),
235
+ (this.wt = null),
242
236
  (this.options = {}),
243
- (this.jo = void 0),
237
+ (this.Do = void 0),
244
238
  (this.Bo = !1),
245
239
  (this.Wo = !1),
246
240
  t && (this.u = null);
247
241
  }
248
242
  }
249
243
  rr() {
250
- if (this.Yo()) return !1;
251
- if (!this.fe()) throw new Error(P);
252
- return !0;
244
+ return !this.Ho() && (!!this.fe() || (console.warn(P), !1));
253
245
  }
254
246
  Ma() {
255
247
  return this.cn;
256
248
  }
257
249
  Sr() {
258
- return this.Do;
250
+ return this.Mo;
259
251
  }
260
252
  Ys() {
261
253
  return this.Uo;
@@ -264,7 +256,7 @@ class Wt {
264
256
  return this.fn;
265
257
  }
266
258
  ar() {
267
- return this.gt;
259
+ return this.$t;
268
260
  }
269
261
  nn(t) {
270
262
  return this.options[t];
@@ -276,7 +268,7 @@ class Wt {
276
268
  return this.ki;
277
269
  }
278
270
  tr() {
279
- return this.wt;
271
+ return this.yt;
280
272
  }
281
273
  aa() {
282
274
  return this._e;
@@ -285,13 +277,13 @@ class Wt {
285
277
  return this.u;
286
278
  }
287
279
  br() {
288
- if (this.ft && this.ki) return new User(this.ft, this.ki);
280
+ if (this.wt && this.ki) return new User(this.wt, this.ki);
289
281
  }
290
282
  ir() {
291
- return this.ft;
283
+ return this.wt;
292
284
  }
293
285
  nr() {
294
- return !0 === this.nn(L.Lo) || !0 === this.nn(L.Co);
286
+ return !0 === this.nn(L.Ro);
295
287
  }
296
288
  g(t) {
297
289
  let i = !1;
@@ -303,7 +295,7 @@ class Wt {
303
295
  for (const s of this.Ko) s.constructor === t.constructor && (i = !0);
304
296
  t instanceof y && !i && this.Ko.push(t);
305
297
  }
306
- jt(t) {
298
+ Ht(t) {
307
299
  t instanceof E && this.Ve.push(t);
308
300
  }
309
301
  removeAllSubscriptions() {
@@ -318,12 +310,12 @@ class Wt {
318
310
  fe() {
319
311
  return this.Bo;
320
312
  }
321
- Yo() {
313
+ Ho() {
322
314
  return this.Wo;
323
315
  }
324
- ks() {
325
- return this.Mo;
316
+ As() {
317
+ return this.jo;
326
318
  }
327
319
  }
328
- const e = new Wt();
329
- export { e as default, Wt as BrazeSdkInstance, L as OPTIONS };
320
+ const e = new Bt();
321
+ export { e as default, Bt as BrazeSdkInstance, L as OPTIONS };
@@ -1,17 +1,17 @@
1
- import V from "../util/browser-detector.js";
1
+ import Q from "../util/browser-detector.js";
2
2
  import xt from "../models/device.js";
3
3
  import DeviceProperties from "../Core/device-properties.js";
4
4
  import _t from "../models/identifier.js";
5
5
  import r from "../../shared-lib/braze-shared-lib.js";
6
6
  import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
7
- import { values as Lt } from "../util/code-utils.js";
7
+ import { values as Pt } from "../util/code-utils.js";
8
8
  import { getErrorMessage as ei } from "../util/error-utils.js";
9
9
  export default class Ot {
10
10
  constructor(t, e) {
11
11
  (this.u = t),
12
12
  (this.Qo = e),
13
13
  (this.u = t),
14
- null == e && (e = Lt(DeviceProperties)),
14
+ null == e && (e = Pt(DeviceProperties)),
15
15
  (this.Qo = e);
16
16
  }
17
17
  ce(t = !0) {
@@ -21,10 +21,10 @@ export default class Ot {
21
21
  for (let t = 0; t < this.Qo.length; t++) {
22
22
  switch (this.Qo[t]) {
23
23
  case DeviceProperties.BROWSER:
24
- s.browser = V.browser;
24
+ s.browser = Q.browser;
25
25
  break;
26
26
  case DeviceProperties.BROWSER_VERSION:
27
- s.Zo = V.version;
27
+ s.Zo = Q.version;
28
28
  break;
29
29
  case DeviceProperties.OS:
30
30
  s.os = this.Ia();
@@ -33,21 +33,21 @@ export default class Ot {
33
33
  s.Ta = screen.width + "x" + screen.height;
34
34
  break;
35
35
  case DeviceProperties.LANGUAGE:
36
- s.language = V.language;
36
+ s.language = Q.language;
37
37
  break;
38
38
  case DeviceProperties.TIME_ZONE:
39
39
  s.timeZone = this.Da(new Date());
40
40
  break;
41
41
  case DeviceProperties.USER_AGENT:
42
- s.userAgent = V.userAgent;
42
+ s.userAgent = Q.userAgent;
43
43
  }
44
44
  }
45
45
  return s;
46
46
  }
47
47
  Ia() {
48
- if (V.Oa()) return V.Oa();
48
+ if (Q.Oa()) return Q.Oa();
49
49
  const t = this.u.v(i.k.Ca);
50
- return t && t.os_version ? t.os_version : V.Ia();
50
+ return t && t.os_version ? t.os_version : Q.Ia();
51
51
  }
52
52
  Da(t) {
53
53
  let e = !1;