@braze/web-sdk 6.8.0 → 6.9.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 (137) hide show
  1. package/index.d.ts +99 -19
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +20 -20
  4. package/shared-lib/indexed-db-adapter.js +64 -64
  5. package/shared-lib/logger.js +18 -18
  6. package/shared-lib/supported-options.js +8 -8
  7. package/src/Banner/banner-provider.js +67 -59
  8. package/src/Banner/banner.js +40 -19
  9. package/src/Banner/dismiss-banner.js +4 -0
  10. package/src/Banner/display/banner-to-html.js +10 -10
  11. package/src/Banner/display/destroy-banner-html.js +2 -2
  12. package/src/Banner/get-all-banners.js +6 -6
  13. package/src/Banner/get-banner.js +6 -6
  14. package/src/Banner/index.js +1 -0
  15. package/src/Banner/log-banner-click.js +7 -7
  16. package/src/Banner/log-banner-dismissal.js +7 -7
  17. package/src/Banner/log-banner-impressions.js +10 -10
  18. package/src/Banner/request-banners-refresh.js +8 -8
  19. package/src/Banner/subscribe-to-banners-updates.js +5 -5
  20. package/src/Banner/ui/insert-banner.js +8 -8
  21. package/src/Card/card-manager.js +31 -31
  22. package/src/Card/log-card-dismissal.js +2 -2
  23. package/src/Card/log-content-card-click.js +2 -2
  24. package/src/Card/log-content-card-impressions.js +4 -4
  25. package/src/Card/models/captioned-image.js +15 -15
  26. package/src/Card/models/card.js +89 -89
  27. package/src/Card/models/classic-card.js +16 -16
  28. package/src/Card/models/control-card.js +7 -7
  29. package/src/Card/models/image-only.js +13 -13
  30. package/src/Card/util/card-factory.js +32 -32
  31. package/src/ContentCards/content-cards-provider.js +102 -102
  32. package/src/ContentCards/get-cached-content-cards.js +1 -1
  33. package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
  34. package/src/ContentCards/ui/show-content-cards.js +5 -5
  35. package/src/Core/add-sdk-metadata.js +2 -2
  36. package/src/Core/change-user.js +3 -3
  37. package/src/Core/destroy.js +2 -2
  38. package/src/Core/disable-sdk.js +4 -4
  39. package/src/Core/enable-sdk.js +4 -4
  40. package/src/Core/get-device-id.js +2 -2
  41. package/src/Core/handle-braze-action.js +5 -5
  42. package/src/Core/log-custom-event.js +5 -5
  43. package/src/Core/log-ecommerce-event.js +5 -5
  44. package/src/Core/log-purchase.js +9 -9
  45. package/src/Core/open-session.js +7 -7
  46. package/src/Core/set-logger.js +2 -2
  47. package/src/Core/toggle-logging.js +2 -2
  48. package/src/Core/wipe-data.js +6 -6
  49. package/src/DUST/dust-provider.js +249 -240
  50. package/src/DUST/dust-shared-worker-code.js +1 -1
  51. package/src/DUST/dust-shared-worker-impl.js +15 -14
  52. package/src/DUST/dust-worker-bridge.js +50 -35
  53. package/src/DUST/subscribe-to-dust.js +7 -7
  54. package/src/FeatureFlags/feature-flag-factory.js +8 -8
  55. package/src/FeatureFlags/feature-flag.js +3 -3
  56. package/src/FeatureFlags/feature-flags-provider.js +21 -21
  57. package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
  58. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  59. package/src/InAppMessage/constants.js +3 -3
  60. package/src/InAppMessage/defer-in-app-message.js +4 -4
  61. package/src/InAppMessage/display/html-message-to-html.js +4 -4
  62. package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
  63. package/src/InAppMessage/in-app-message-factory.js +36 -36
  64. package/src/InAppMessage/in-app-message-manager.js +78 -78
  65. package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
  66. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  67. package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
  68. package/src/InAppMessage/log-in-app-message-impression.js +4 -4
  69. package/src/InAppMessage/models/control-message.js +4 -4
  70. package/src/InAppMessage/models/full-screen-message.js +4 -4
  71. package/src/InAppMessage/models/html-message.js +3 -3
  72. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  73. package/src/InAppMessage/models/in-app-message.js +12 -12
  74. package/src/InAppMessage/models/modal-message.js +4 -4
  75. package/src/InAppMessage/models/slide-up-message.js +4 -4
  76. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  77. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  78. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  79. package/src/InAppMessage/ui/show-in-app-message.js +14 -14
  80. package/src/Push/push-manager-factory.js +2 -2
  81. package/src/Push/push-manager.js +38 -38
  82. package/src/Push/utils/push-utils.js +6 -6
  83. package/src/User/user-manager.js +14 -14
  84. package/src/User/user.js +25 -25
  85. package/src/common/base-provider.js +1 -1
  86. package/src/common/content-cards-display.js +7 -7
  87. package/src/common/event-logger.js +3 -3
  88. package/src/common/properties-base.js +3 -3
  89. package/src/l10n/l10n-manager-factory.js +1 -1
  90. package/src/l10n/l10n-manager.js +3 -3
  91. package/src/managers/auth-manager.js +11 -11
  92. package/src/managers/braze-instance.js +56 -56
  93. package/src/managers/device-manager.js +10 -10
  94. package/src/managers/network-manager.js +102 -101
  95. package/src/managers/server-config-manager.js +115 -98
  96. package/src/managers/session-manager.js +20 -20
  97. package/src/managers/storage-manager-factory.js +9 -9
  98. package/src/managers/storage-manager.js +74 -74
  99. package/src/managers/subscription-manager.js +2 -2
  100. package/src/managers/utils.js +1 -1
  101. package/src/models/backend-errors.js +5 -5
  102. package/src/models/braze-event.js +1 -1
  103. package/src/models/device.js +1 -1
  104. package/src/models/identifier.js +2 -2
  105. package/src/models/push-token.js +6 -6
  106. package/src/models/request-result.js +1 -1
  107. package/src/models/server-config.js +42 -24
  108. package/src/request-controller.js +126 -126
  109. package/src/triggers/models/custom-event-data.js +4 -4
  110. package/src/triggers/models/custom-event-property-data.js +5 -5
  111. package/src/triggers/models/filter-set.js +2 -2
  112. package/src/triggers/models/filter.js +1 -1
  113. package/src/triggers/models/in-app-message-click-data.js +1 -1
  114. package/src/triggers/models/purchase-data.js +1 -1
  115. package/src/triggers/models/purchase-property-data.js +2 -2
  116. package/src/triggers/models/push-click-data.js +1 -1
  117. package/src/triggers/models/trigger-condition.js +33 -33
  118. package/src/triggers/models/trigger-events.js +1 -1
  119. package/src/triggers/models/trigger.js +33 -33
  120. package/src/triggers/triggers-provider-factory.js +1 -1
  121. package/src/triggers/triggers-provider.js +68 -68
  122. package/src/types.js +2 -2
  123. package/src/ui/js/attach-css.js +1 -1
  124. package/src/util/braze-actions.js +7 -7
  125. package/src/util/browser-detector.js +2 -2
  126. package/src/util/client-hints-parser.js +4 -4
  127. package/src/util/code-utils.js +2 -2
  128. package/src/util/deprecation-utils.js +2 -2
  129. package/src/util/dom-utils.js +7 -7
  130. package/src/util/ecommerce-event-validation.js +52 -35
  131. package/src/util/html-display-utils.js +11 -11
  132. package/src/util/net.js +4 -4
  133. package/src/util/request-header-utils.js +17 -17
  134. package/src/util/string-utils.js +2 -2
  135. package/src/util/user-agent-parser.js +2 -2
  136. package/src/util/validation-utils.js +12 -12
  137. package/src/util/window-utils.js +2 -2
@@ -5,7 +5,7 @@ import Pt from "./device-manager.js";
5
5
  import DeviceProperties from "../Core/device-properties.js";
6
6
  import {
7
7
  isArray as g,
8
- keys as D,
8
+ keys as C,
9
9
  validateValueIsFromEnum as ta,
10
10
  values as Wt,
11
11
  } from "../util/code-utils.js";
@@ -24,7 +24,7 @@ import { User } from "../User/index.js";
24
24
  import { parseQueryStringKeyValues as lt } 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 E } from "../../shared-lib/index.js";
27
+ import { SupportedOptions as li, 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,27 +32,27 @@ const U = {
32
32
  se: "cookieExpiryInDays",
33
33
  Oh: "noCookies",
34
34
  Th: "devicePropertyAllowlist",
35
- qa: "disablePushTokenMaintenance",
35
+ ka: "disablePushTokenMaintenance",
36
36
  Rh: "enableLogging",
37
37
  Ph: "enableSdkAuthentication",
38
- ka: "manageServiceWorkerExternally",
38
+ _a: "manageServiceWorkerExternally",
39
39
  Dh: "minimumIntervalBetweenTriggerActionsInSeconds",
40
40
  Lh: "sessionTimeoutInSeconds",
41
41
  yh: "appVersion",
42
42
  Mh: "appVersionNumber",
43
43
  xa: "serviceWorkerLocation",
44
- _a: "safariWebsitePushId",
45
- Ba: "localization",
44
+ Ma: "safariWebsitePushId",
45
+ qa: "localization",
46
46
  sr: "contentSecurityNonce",
47
47
  nr: "allowUserSuppliedJavascript",
48
- wa: "inAppMessageZIndex",
49
- va: "openInAppMessagesInNewTab",
48
+ ja: "inAppMessageZIndex",
49
+ ba: "openInAppMessagesInNewTab",
50
50
  tn: "openCardsInNewTab",
51
51
  oh: "requireExplicitInAppMessageDismissal",
52
52
  Uh: "doNotLoadFontAwesome",
53
53
  Wh: "deviceId",
54
- Ma: "serviceWorkerScope",
55
- Xe: "dustHost",
54
+ ya: "serviceWorkerScope",
55
+ Ye: "dustHost",
56
56
  Bh: "sdkFlavor",
57
57
  };
58
58
  class ci {
@@ -65,8 +65,8 @@ class ci {
65
65
  (this.B = null),
66
66
  (this.Ru = null),
67
67
  (this.h = null),
68
- (this.j = null),
69
68
  (this.C = null),
69
+ (this.j = null),
70
70
  (this.Ss = null),
71
71
  (this.Yh = ""),
72
72
  (this.isInitialized = !1),
@@ -77,34 +77,34 @@ class ci {
77
77
  (this.Jh = []),
78
78
  (this.Xh = []),
79
79
  (this.In = []),
80
- (this.Vh = "6.8.0");
80
+ (this.Vh = "6.9.0");
81
81
  }
82
82
  Zh(t) {
83
- this.qh.Kt(t);
83
+ this.qh.Ut(t);
84
84
  }
85
85
  uh(t) {
86
- this.Hh.Kt(t);
86
+ this.Hh.Ut(t);
87
87
  }
88
88
  initialize(t, i) {
89
89
  var e, r, o;
90
90
  if (this.ao())
91
- return E.info("Braze has already been initialized with an API key."), !0;
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
94
  const h = lt(no.Qh());
95
95
  if (
96
96
  (h && "true" === h.brazeLogging && (n = !0),
97
- E.init(n),
98
- E.info(
97
+ b.init(n),
98
+ b.info(
99
99
  `Initialization Options: ${JSON.stringify(this.options, null, 2)}`,
100
100
  ),
101
101
  null == t || "" === t || "string" != typeof t)
102
102
  )
103
- return E.error("Braze requires a valid API key to be initialized."), !1;
103
+ return b.error("Braze requires a valid API key to be initialized."), !1;
104
104
  this.tu = t;
105
105
  let l = this.er(U.Nh);
106
106
  if (null == l || "" === l || "string" != typeof l)
107
- return E.error("Braze requires a valid baseUrl to be initialized."), !1;
107
+ return b.error("Braze requires a valid baseUrl to be initialized."), !1;
108
108
  !1 === /^https?:/.test(l) && (l = `https://${l}`);
109
109
  const a = l;
110
110
  if (
@@ -115,7 +115,7 @@ class ci {
115
115
  ro.il && !this.er(U._h))
116
116
  )
117
117
  return (
118
- E.info("Ignoring activity from crawler bot " + navigator.userAgent),
118
+ b.info("Ignoring activity from crawler bot " + navigator.userAgent),
119
119
  (this.$h = !0),
120
120
  !1
121
121
  );
@@ -123,24 +123,24 @@ class ci {
123
123
  c = this.er(U.se),
124
124
  m = Zt.sl();
125
125
  if (
126
- ((this.C = Zt.rl(t, u, c)),
127
- u && this.C.hl(t),
126
+ ((this.j = Zt.rl(t, u, c)),
127
+ u && this.j.hl(t),
128
128
  new ne.le(null, !0).wr(s.ce))
129
129
  )
130
130
  return (
131
- E.info("Ignoring all activity due to previous opt out"),
131
+ b.info("Ignoring all activity due to previous opt out"),
132
132
  (this.$h = !0),
133
133
  !1
134
134
  );
135
- for (const t of D(this.options))
135
+ for (const t of C(this.options))
136
136
  -1 === Wt(li).indexOf(t) &&
137
- E.warn(`Ignoring unknown initialization option '${t}'.`);
137
+ b.warn(`Ignoring unknown initialization option '${t}'.`);
138
138
  const p = ["mparticle", "wordpress", "tealium"];
139
139
  if (null != this.er(U.Bh)) {
140
140
  const t = this.er(U.Bh);
141
141
  -1 !== p.indexOf(t)
142
142
  ? (this.Kh = t)
143
- : E.error("Invalid sdk flavor passed: " + t);
143
+ : b.error("Invalid sdk flavor passed: " + t);
144
144
  }
145
145
  let d = this.er(li.Th);
146
146
  if (null != d)
@@ -155,28 +155,28 @@ class ci {
155
155
  ) && t.push(d[i]);
156
156
  d = t;
157
157
  } else
158
- E.error(
158
+ b.error(
159
159
  "devicePropertyAllowlist must be an array. Defaulting to all properties.",
160
160
  ),
161
161
  (d = null);
162
- const I = this.er(U.Wh);
163
- if (I) {
164
- const t = new _t(I);
165
- this.C.Iu(s.Ou.Wh, t);
162
+ const E = this.er(U.Wh);
163
+ if (E) {
164
+ const t = new _t(E);
165
+ this.j.Iu(s.Ou.Wh, t);
166
166
  }
167
- (this.eu = new Pt(this.C, d)),
168
- (this.h = new Yt(this.C)),
169
- (this.Ss = new Ut(this.h, this.C)),
170
- (this.j = new Xt(this.C, this.Ss, this.h, this.er(U.Lh)));
171
- const _ = new f();
172
- (this.Gh = new Gt(this.C, this.er(U.Ph), _)),
173
- this.S(_),
167
+ (this.eu = new Pt(this.j, d)),
168
+ (this.h = new Yt(this.j)),
169
+ (this.Ss = new Ut(this.h, this.j)),
170
+ (this.C = new Xt(this.j, this.Ss, this.h, this.er(U.Lh)));
171
+ const I = new f();
172
+ (this.Gh = new Gt(this.j, this.er(U.Ph), I)),
173
+ this.S(I),
174
174
  (this.B = new Vt(
175
175
  this.eu,
176
- this.C,
176
+ this.j,
177
177
  this.Gh,
178
178
  this.Ss,
179
- this.j,
179
+ this.C,
180
180
  this.h,
181
181
  this.tu,
182
182
  this.Yh,
@@ -188,20 +188,20 @@ class ci {
188
188
  (this.Ru = new Kt(
189
189
  this.tu,
190
190
  this.Yh,
191
- this.j,
191
+ this.C,
192
192
  this.eu,
193
193
  this.Ss,
194
194
  this.h,
195
- this.C,
195
+ this.j,
196
196
  (t) => {
197
- if (this.ao()) for (const i of this.vr()) i.I(t);
197
+ if (this.ao()) for (const i of this.vr()) i.q(t);
198
198
  },
199
199
  this.Gh,
200
200
  this.B,
201
201
  )),
202
202
  this.Ru.initialize(),
203
- u || this.C.ll(),
204
- E.info(
203
+ u || this.j.ll(),
204
+ b.info(
205
205
  `Initialized for the Braze backend at "${this.er(
206
206
  U.Nh,
207
207
  )}" with API key "${this.tu}".`,
@@ -229,13 +229,13 @@ class ci {
229
229
  this.qh.A(this.options),
230
230
  (this.isInitialized = !0),
231
231
  window.dispatchEvent(new CustomEvent("braze.initialized"));
232
- const S = null === (e = this.j) || void 0 === e ? void 0 : e.al();
232
+ const _ = null === (e = this.C) || void 0 === e ? void 0 : e.al();
233
233
  return (
234
234
  m ||
235
- null == S ||
236
- (null === (r = this.j) || void 0 === r
235
+ null == _ ||
236
+ (null === (r = this.C) || void 0 === r
237
237
  ? void 0
238
- : r.ul(new Date().valueOf(), S)) ||
238
+ : r.ul(new Date().valueOf(), _)) ||
239
239
  null === (o = this.Ru) ||
240
240
  void 0 === o ||
241
241
  o.Ar(),
@@ -243,7 +243,7 @@ class ci {
243
243
  );
244
244
  }
245
245
  destroy(t) {
246
- if ((E.destroy(), this.ao())) {
246
+ if ((b.destroy(), this.ao())) {
247
247
  this.Hh.A(), this.Hh.removeAllSubscriptions();
248
248
  for (const t of this.Jh) t.destroy();
249
249
  this.Jh = [];
@@ -258,13 +258,13 @@ class ci {
258
258
  (this.eu = null),
259
259
  (this.B = null),
260
260
  (this.h = null),
261
- (this.j = null),
261
+ (this.C = null),
262
262
  (this.Ss = null),
263
263
  (this.options = {}),
264
264
  (this.Kh = void 0),
265
265
  (this.isInitialized = !1),
266
266
  (this.$h = !1),
267
- t && (this.C = null);
267
+ t && (this.j = null);
268
268
  }
269
269
  }
270
270
  rr() {
@@ -298,10 +298,10 @@ class ci {
298
298
  return this.h;
299
299
  }
300
300
  u() {
301
- return this.j;
301
+ return this.C;
302
302
  }
303
303
  p() {
304
- return this.C;
304
+ return this.j;
305
305
  }
306
306
  zr() {
307
307
  if (this.Ss && this.Ru) return new User(this.Ss, this.Ru);
@@ -342,9 +342,9 @@ class ci {
342
342
  }
343
343
  ar(t, i) {
344
344
  if (!this.rr()) return null;
345
- return dr.o().en(t, i);
345
+ return dr.o().on(t, i);
346
346
  }
347
- zi() {
347
+ qi() {
348
348
  return this.Vh;
349
349
  }
350
350
  }
@@ -2,21 +2,21 @@ import ro from "../util/browser-detector.js";
2
2
  import Se from "../models/device.js";
3
3
  import DeviceProperties from "../Core/device-properties.js";
4
4
  import _t from "../models/identifier.js";
5
- import { logger as E, Guid as V } from "../../shared-lib/index.js";
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
7
  import { values as Wt } from "../util/code-utils.js";
8
8
  import { getErrorMessage as hi } from "../util/error-utils.js";
9
9
  export default class Pt {
10
10
  constructor(t, e) {
11
- (this.C = t),
11
+ (this.j = t),
12
12
  (this.Da = e),
13
- (this.C = t),
13
+ (this.j = t),
14
14
  null == e && (e = Wt(DeviceProperties)),
15
15
  (this.Da = e);
16
16
  }
17
17
  ve(t = !0) {
18
- let e = this.C.$u(s.Ou.Wh);
19
- null == e && ((e = new _t(V.de())), t && this.C.Iu(s.Ou.Wh, e));
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
20
  const r = new Se(e.Tu);
21
21
  for (let t = 0; t < this.Da.length; t++) {
22
22
  switch (this.Da[t]) {
@@ -45,8 +45,8 @@ export default class Pt {
45
45
  return r;
46
46
  }
47
47
  Fa() {
48
- if (ro.Ha()) return ro.Ha();
49
- const t = this.C.Rt(s.Tt.Ka);
48
+ if (ro.Aa()) return ro.Aa();
49
+ const t = this.j.St(s.It.Ba);
50
50
  return t && t.os_version ? t.os_version : ro.Fa();
51
51
  }
52
52
  Ja(t) {
@@ -58,7 +58,7 @@ export default class Pt {
58
58
  if (null != t && "" !== t) return t;
59
59
  }
60
60
  } catch (t) {
61
- E.info(
61
+ b.info(
62
62
  "Intl.DateTimeFormat threw an error, cannot detect user's time zone:" +
63
63
  hi(t),
64
64
  ),
@@ -66,9 +66,9 @@ export default class Pt {
66
66
  }
67
67
  if (e) return "";
68
68
  const r = t.getTimezoneOffset();
69
- return this.La(r);
69
+ return this.Ha(r);
70
70
  }
71
- La(t) {
71
+ Ha(t) {
72
72
  const e = Math.trunc(t / 60),
73
73
  r = Math.trunc(t % 60);
74
74
  let s = "GMT";