@braze/web-sdk 6.5.0 → 6.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 (153) hide show
  1. package/index.d.ts +258 -5
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +21 -20
  4. package/shared-lib/guid.js +3 -3
  5. package/shared-lib/indexed-db-adapter.js +70 -70
  6. package/shared-lib/logger.js +7 -7
  7. package/shared-lib/supported-options.js +26 -25
  8. package/src/Banner/banner-factory.js +11 -1
  9. package/src/Banner/banner-provider.js +244 -120
  10. package/src/Banner/banner.js +14 -12
  11. package/src/Banner/display/banner-to-html.js +23 -16
  12. package/src/Banner/display/detect-banner-impressions.js +13 -13
  13. package/src/Banner/get-all-banners.js +5 -5
  14. package/src/Banner/get-banner.js +4 -4
  15. package/src/Banner/log-banner-click.js +4 -4
  16. package/src/Banner/log-banner-dismissal.js +23 -0
  17. package/src/Banner/log-banner-impressions.js +7 -7
  18. package/src/Banner/request-banners-refresh.js +12 -16
  19. package/src/Banner/subscribe-to-banners-updates.js +6 -6
  20. package/src/Banner/ui/insert-banner.js +12 -12
  21. package/src/Card/card-manager-factory.js +5 -5
  22. package/src/Card/card-manager.js +33 -33
  23. package/src/Card/constants.js +1 -1
  24. package/src/Card/display/card-display.js +11 -11
  25. package/src/Card/log-card-dismissal.js +3 -3
  26. package/src/Card/log-content-card-click.js +3 -3
  27. package/src/Card/log-content-card-impressions.js +6 -6
  28. package/src/Card/models/captioned-image.js +21 -21
  29. package/src/Card/models/card.js +73 -73
  30. package/src/Card/models/classic-card.js +21 -21
  31. package/src/Card/models/control-card.js +11 -11
  32. package/src/Card/models/image-only.js +18 -18
  33. package/src/Card/util/card-factory.js +41 -41
  34. package/src/ContentCards/content-cards-provider-factory.js +12 -12
  35. package/src/ContentCards/content-cards-provider.js +151 -151
  36. package/src/ContentCards/content-cards.js +5 -5
  37. package/src/ContentCards/get-cached-content-cards.js +2 -2
  38. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  39. package/src/ContentCards/subscribe-to-content-cards-updates.js +6 -6
  40. package/src/ContentCards/ui/show-content-cards.js +10 -10
  41. package/src/Core/add-sdk-metadata.js +2 -2
  42. package/src/Core/change-user.js +6 -6
  43. package/src/Core/disable-sdk.js +9 -8
  44. package/src/Core/enable-sdk.js +5 -5
  45. package/src/Core/get-user.js +1 -1
  46. package/src/Core/handle-braze-action.js +3 -3
  47. package/src/Core/is-disabled.js +2 -2
  48. package/src/Core/log-custom-event.js +8 -8
  49. package/src/Core/log-purchase.js +5 -5
  50. package/src/Core/open-session.js +7 -7
  51. package/src/Core/set-sdk-authentication-signature.js +3 -3
  52. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  53. package/src/Core/wipe-data.js +6 -6
  54. package/src/DUST/dust-provider-factory.js +11 -11
  55. package/src/DUST/dust-provider.js +255 -255
  56. package/src/DUST/dust-shared-worker-impl.js +100 -100
  57. package/src/DUST/dust-worker-bridge.js +27 -27
  58. package/src/DUST/subscribe-to-dust.js +9 -9
  59. package/src/FeatureFlags/feature-flag-factory.js +8 -8
  60. package/src/FeatureFlags/feature-flag.js +9 -9
  61. package/src/FeatureFlags/feature-flags-provider.js +86 -86
  62. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  63. package/src/FeatureFlags/get-feature-flag.js +2 -2
  64. package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
  65. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  66. package/src/InAppMessage/constants.js +83 -2
  67. package/src/InAppMessage/defer-in-app-message.js +1 -1
  68. package/src/InAppMessage/display/html-message-display-utils.js +15 -15
  69. package/src/InAppMessage/display/html-message-to-html.js +36 -37
  70. package/src/InAppMessage/display/in-app-message-to-html.js +44 -44
  71. package/src/InAppMessage/display/modal-utils.js +10 -14
  72. package/src/InAppMessage/in-app-message-factory.js +16 -20
  73. package/src/InAppMessage/in-app-message-manager.js +116 -117
  74. package/src/InAppMessage/log-in-app-message-button-click.js +8 -8
  75. package/src/InAppMessage/log-in-app-message-click.js +7 -7
  76. package/src/InAppMessage/log-in-app-message-html-click.js +8 -8
  77. package/src/InAppMessage/log-in-app-message-impression.js +5 -5
  78. package/src/InAppMessage/models/control-message.js +4 -4
  79. package/src/InAppMessage/models/full-screen-message.js +56 -49
  80. package/src/InAppMessage/models/html-message.js +31 -27
  81. package/src/InAppMessage/models/in-app-message-button.js +12 -12
  82. package/src/InAppMessage/models/in-app-message.js +202 -256
  83. package/src/InAppMessage/models/modal-message.js +55 -49
  84. package/src/InAppMessage/models/slide-up-message.js +57 -51
  85. package/src/InAppMessage/models/templated-in-app-message.js +10 -10
  86. package/src/InAppMessage/shared-types.js +1 -0
  87. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  88. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +5 -5
  89. package/src/InAppMessage/ui/remove-all-visible-in-app-messages.js +3 -3
  90. package/src/InAppMessage/ui/show-in-app-message.js +43 -41
  91. package/src/Push/is-push-blocked.js +2 -2
  92. package/src/Push/is-push-permission-granted.js +2 -2
  93. package/src/Push/is-push-supported.js +2 -2
  94. package/src/Push/push-manager-factory.js +9 -9
  95. package/src/Push/push-manager.js +15 -15
  96. package/src/Push/utils/push-utils.js +15 -15
  97. package/src/User/user-manager.js +14 -14
  98. package/src/User/user.js +60 -59
  99. package/src/common/base-provider.js +1 -1
  100. package/src/common/constants.js +2 -1
  101. package/src/common/content-cards-display.js +38 -38
  102. package/src/common/event-logger.js +8 -8
  103. package/src/l10n/l10n-manager-factory.js +9 -9
  104. package/src/l10n/l10n-manager.js +2 -2
  105. package/src/managers/auth-manager.js +31 -31
  106. package/src/managers/braze-instance.js +197 -182
  107. package/src/managers/constants.js +1 -0
  108. package/src/managers/device-manager.js +25 -25
  109. package/src/managers/network-manager.js +155 -155
  110. package/src/managers/server-config-manager.js +106 -93
  111. package/src/managers/session-manager.js +37 -33
  112. package/src/managers/storage-manager-factory.js +33 -28
  113. package/src/managers/storage-manager.js +194 -175
  114. package/src/managers/subscription-manager.js +13 -13
  115. package/src/managers/utils.js +1 -1
  116. package/src/models/backend-errors.js +5 -5
  117. package/src/models/braze-event.js +13 -13
  118. package/src/models/device.js +3 -3
  119. package/src/models/identifier.js +12 -12
  120. package/src/models/push-token.js +9 -9
  121. package/src/models/request-result.js +4 -4
  122. package/src/models/server-config.js +29 -38
  123. package/src/request-controller.js +159 -163
  124. package/src/triggers/models/custom-event-data.js +7 -7
  125. package/src/triggers/models/custom-event-property-data.js +10 -10
  126. package/src/triggers/models/filter-set.js +12 -12
  127. package/src/triggers/models/filter.js +66 -66
  128. package/src/triggers/models/in-app-message-click-data.js +13 -13
  129. package/src/triggers/models/purchase-data.js +4 -4
  130. package/src/triggers/models/purchase-property-data.js +10 -10
  131. package/src/triggers/models/push-click-data.js +8 -8
  132. package/src/triggers/models/trigger-condition.js +58 -58
  133. package/src/triggers/models/trigger-events.js +3 -3
  134. package/src/triggers/models/trigger.js +44 -44
  135. package/src/triggers/triggers-provider-factory.js +5 -5
  136. package/src/triggers/triggers-provider.js +70 -70
  137. package/src/ui/js/attach-css.js +3 -3
  138. package/src/ui/js/feed-css.js +2 -2
  139. package/src/ui/js/iam-css.js +2 -2
  140. package/src/ui/js/load-font-awesome.js +2 -2
  141. package/src/util/base-device-parser.js +9 -9
  142. package/src/util/braze-actions.js +3 -3
  143. package/src/util/browser-detector.js +37 -37
  144. package/src/util/client-hints-parser.js +9 -9
  145. package/src/util/component-utils.js +3 -3
  146. package/src/util/dom-utils.js +2 -2
  147. package/src/util/html-display-utils.js +11 -11
  148. package/src/util/key-codes.js +1 -1
  149. package/src/util/net.js +8 -8
  150. package/src/util/request-header-utils.js +25 -25
  151. package/src/util/user-agent-parser.js +20 -20
  152. package/src/util/validation-utils.js +21 -21
  153. package/src/util/window-utils.js +3 -3
@@ -1,27 +1,27 @@
1
1
  import {
2
- getCardId as xt,
3
- markCardAsRead as Rt,
2
+ getCardId as Rt,
3
+ markCardAsRead as Ht,
4
4
  } from "../Card/display/card-display.js";
5
- import { bottomIsInView as I, topIsInView as B } from "../util/dom-utils.js";
5
+ import { bottomIsInView as q, topIsInView as k } from "../util/dom-utils.js";
6
6
  import { Card, ControlCard } from "../Card/index.js";
7
- import { cardToHtml as Lt } from "../Card/display/card-display.js";
8
- import { isArray as R } from "../util/code-utils.js";
7
+ import { cardToHtml as qt } from "../Card/display/card-display.js";
8
+ import { isArray as g } from "../util/code-utils.js";
9
9
  import { KeyCodes as Ce } from "../util/key-codes.js";
10
- import Me from "../l10n/l10n-manager-factory.js";
10
+ import Je from "../l10n/l10n-manager-factory.js";
11
11
  import { removeSubscription } from "../Core/remove-subscription.js";
12
- import { logger as E, Guid as P } from "../../shared-lib/index.js";
12
+ import { logger as E, Guid as V } from "../../shared-lib/index.js";
13
13
  import { BRAZE_ACTION_URI_REGEX as to } from "../util/validation-utils.js";
14
14
  import {
15
- INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as jt,
16
- ineligibleBrazeActionURLErrorMessage as dt,
15
+ INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as bt,
16
+ ineligibleBrazeActionURLErrorMessage as yt,
17
17
  getDecodedBrazeAction as eo,
18
- containsUnknownBrazeAction as gt,
18
+ containsUnknownBrazeAction as vt,
19
19
  } from "../util/braze-actions.js";
20
20
  import {
21
- bottomHadImpression as Ft,
21
+ bottomHadImpression as Ot,
22
22
  impressOnBottom as $,
23
- impressOnTop as g,
24
- topHadImpression as Ht,
23
+ impressOnTop as B,
24
+ topHadImpression as Bt,
25
25
  } from "./detect-impression.js";
26
26
  import { BannerStrings as j } from "../Banner/constants.js";
27
27
  import ContentCards from "../ContentCards/content-cards.js";
@@ -34,7 +34,7 @@ export function destroyContentCardsHtml(t) {
34
34
  ((t.className = t.className.replace("ab-show", "ab-hide")),
35
35
  setTimeout(() => {
36
36
  t && t.parentNode && t.parentNode.removeChild(t);
37
- }, ContentCards.hr));
37
+ }, ContentCards.gr));
38
38
  const e = t.getAttribute(j.ea);
39
39
  null != e && removeSubscription(e);
40
40
  const n = t.getAttribute("data-listener-id");
@@ -43,7 +43,7 @@ export function destroyContentCardsHtml(t) {
43
43
  delete scrollListeners[n]);
44
44
  }
45
45
  export function generateContentCardsUI(t, e) {
46
- const n = Me.ra(),
46
+ const n = Je.ra(),
47
47
  o = document.createElement("div");
48
48
  if (
49
49
  ((o.className = "ab-feed-body"),
@@ -59,11 +59,11 @@ export function generateContentCardsUI(t, e) {
59
59
  o.appendChild(t);
60
60
  } else {
61
61
  let s = !1;
62
- const r = (e) => t.dr(e);
62
+ const r = (e) => t.cr(e);
63
63
  for (const a of t.cards) {
64
64
  const i = a instanceof ControlCard;
65
- !i || t.cr()
66
- ? (o.appendChild(Lt(a, r, e, n.Ta())), (s = s || !i))
65
+ !i || t.hr()
66
+ ? (o.appendChild(qt(a, r, e, n.wa())), (s = s || !i))
67
67
  : E.error(
68
68
  "Received a control card for a legacy news feed. Control cards are only supported with content cards.",
69
69
  );
@@ -82,31 +82,31 @@ export function detectContentCardsImpressions(t, e) {
82
82
  if (null != t && null != e) {
83
83
  const n = [],
84
84
  o = e.querySelectorAll(".ab-card");
85
- t.Qa || (t.Qa = {});
85
+ t.Ta || (t.Ta = {});
86
86
  for (let e = 0; e < o.length; e++) {
87
- const s = xt(o[e]),
88
- r = B(o[e]),
89
- a = I(o[e]);
90
- if (t.Qa[s]) {
91
- r || a || Rt(o[e]);
87
+ const s = Rt(o[e]),
88
+ r = k(o[e]),
89
+ a = q(o[e]);
90
+ if (t.Ta[s]) {
91
+ r || a || Ht(o[e]);
92
92
  continue;
93
93
  }
94
- let i = Ht(o[e]),
95
- l = Ft(o[e]);
94
+ let i = Bt(o[e]),
95
+ l = Ot(o[e]);
96
96
  const d = i,
97
97
  c = l;
98
98
  if (
99
- (!i && r && ((i = !0), g(o[e])), !l && a && ((l = !0), $(o[e])), i && l)
99
+ (!i && r && ((i = !0), B(o[e])), !l && a && ((l = !0), $(o[e])), i && l)
100
100
  ) {
101
101
  if (d && c) continue;
102
102
  for (const e of t.cards)
103
103
  if (e.id === s) {
104
- (t.Qa[e.id] = !0), n.push(e);
104
+ (t.Ta[e.id] = !0), n.push(e);
105
105
  break;
106
106
  }
107
107
  }
108
108
  }
109
- n.length > 0 && t.sr(n);
109
+ n.length > 0 && t.ur(n);
110
110
  }
111
111
  }
112
112
  export function refreshContentCardsUI(t, e) {
@@ -124,15 +124,15 @@ export function refreshContentCardsUI(t, e) {
124
124
  const n = e.querySelectorAll(".ab-initial-spinner")[0];
125
125
  if (null != n) {
126
126
  const t = document.createElement("span");
127
- (t.innerHTML = Me.ra().get("FEED_TIMEOUT_MESSAGE") || ""),
127
+ (t.innerHTML = Je.ra().get("FEED_TIMEOUT_MESSAGE") || ""),
128
128
  null != n.parentNode &&
129
129
  (n.parentNode.appendChild(t), n.parentNode.removeChild(n));
130
130
  }
131
131
  "true" === e.getAttribute("aria-busy") &&
132
132
  e.setAttribute("aria-busy", "false");
133
133
  }
134
- }, ContentCards.lr),
135
- t.ur();
134
+ }, ContentCards.jr),
135
+ t.Cr();
136
136
  }
137
137
  export function contentCardsToHtml(t, e, n) {
138
138
  const o = document.createElement("div");
@@ -153,7 +153,7 @@ export function contentCardsToHtml(t, e, n) {
153
153
  destroyContentCardsHtml(o), t.stopPropagation();
154
154
  };
155
155
  r.addEventListener("keydown", (t) => {
156
- (t.keyCode !== Ce.Ho && t.keyCode !== Ce.Go) || a(t);
156
+ (t.keyCode !== Ce.Ao && t.keyCode !== Ce.Lo) || a(t);
157
157
  }),
158
158
  (r.onclick = a);
159
159
  const i = document.createElement("i");
@@ -166,7 +166,7 @@ export function contentCardsToHtml(t, e, n) {
166
166
  refreshContentCardsUI(t, o), e.stopPropagation();
167
167
  };
168
168
  i.addEventListener("keydown", (t) => {
169
- (t.keyCode !== Ce.Ho && t.keyCode !== Ce.Go) || l(t);
169
+ (t.keyCode !== Ce.Ao && t.keyCode !== Ce.Lo) || l(t);
170
170
  }),
171
171
  (i.onclick = l),
172
172
  s.appendChild(i),
@@ -175,20 +175,20 @@ export function contentCardsToHtml(t, e, n) {
175
175
  const d = () => detectContentCardsImpressions(t, o);
176
176
  if ((o.addEventListener("scroll", d), !n)) {
177
177
  window.addEventListener("scroll", d);
178
- const t = P.se();
178
+ const t = V.de();
179
179
  (scrollListeners[t] = d), o.setAttribute("data-listener-id", t);
180
180
  }
181
181
  return o;
182
182
  }
183
183
  export function updateContentCards(t, e, n, o, s) {
184
- if (!R(e)) return;
184
+ if (!g(e)) return;
185
185
  const r = [];
186
186
  for (const t of e)
187
187
  if (t instanceof Card) {
188
188
  if (t.url && to.test(t.url)) {
189
189
  const e = eo(t.url);
190
- if (gt(e)) {
191
- E.error(dt(jt.Pn, "Content Card"));
190
+ if (vt(e)) {
191
+ E.error(yt(bt.Un, "Content Card"));
192
192
  continue;
193
193
  }
194
194
  }
@@ -1,11 +1,11 @@
1
1
  import { logger as E } from "../../shared-lib/index.js";
2
2
  import r from "../managers/braze-instance.js";
3
- import De from "../models/braze-event.js";
4
- import H from "../models/request-result.js";
3
+ import Ie from "../models/braze-event.js";
4
+ import L from "../models/request-result.js";
5
5
  const v = {
6
- lt: (e, o, t) => {
6
+ wt: (e, o, t) => {
7
7
  var n, s;
8
- const i = new H(),
8
+ const i = new L(),
9
9
  l = r.u();
10
10
  if (!l)
11
11
  return (
@@ -16,8 +16,8 @@ const v = {
16
16
  );
17
17
  const d = l.el();
18
18
  return (
19
- i.Ee.push(
20
- new De(
19
+ i.Ce.push(
20
+ new Ie(
21
21
  t || (null === (n = r.ir()) || void 0 === n ? void 0 : n.getUserId()),
22
22
  e,
23
23
  new Date().valueOf(),
@@ -25,8 +25,8 @@ const v = {
25
25
  o,
26
26
  ),
27
27
  ),
28
- (i.W =
29
- (null === (s = r.p()) || void 0 === s ? void 0 : s.ol(i.Ee)) || !1),
28
+ (i.lt =
29
+ (null === (s = r.p()) || void 0 === s ? void 0 : s.ol(i.Ce)) || !1),
30
30
  i
31
31
  );
32
32
  },
@@ -1,22 +1,22 @@
1
- import r, { OPTIONS as D } from "../managers/braze-instance.js";
1
+ import r, { OPTIONS as U } from "../managers/braze-instance.js";
2
2
  import ro from "../util/browser-detector.js";
3
- import mr from "./l10n-manager.js";
4
- const Me = {
3
+ import gr from "./l10n-manager.js";
4
+ const Je = {
5
5
  i: !1,
6
6
  na: null,
7
7
  ra: () => {
8
- if ((Me.t(), !Me.na)) {
8
+ if ((Je.t(), !Je.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.er(U.qa) && ((e = r.er(U.qa)), (t = !0)), (Je.na = new gr(e, t));
12
12
  }
13
- return Me.na;
13
+ return Je.na;
14
14
  },
15
15
  t: () => {
16
- Me.i || (r.g(Me), (Me.i = !0));
16
+ Je.i || (r.g(Je), (Je.i = !0));
17
17
  },
18
18
  destroy: () => {
19
- (Me.na = null), (Me.i = !1);
19
+ (Je.na = null), (Je.i = !1);
20
20
  },
21
21
  };
22
- export default Me;
22
+ export default Je;
@@ -1,6 +1,6 @@
1
1
  import { logger as E } from "../../shared-lib/index.js";
2
2
  import zt from "../common/translations.js";
3
- export default class mr {
3
+ export default class gr {
4
4
  constructor(t, e = !1) {
5
5
  if (
6
6
  ((this.language = t),
@@ -22,7 +22,7 @@ export default class mr {
22
22
  get(t) {
23
23
  return zt[this.language][t];
24
24
  }
25
- Ta() {
25
+ wa() {
26
26
  switch (this.language) {
27
27
  case "ar":
28
28
  case "he":
@@ -1,51 +1,51 @@
1
1
  import { STORAGE_KEYS as s } from "./storage-manager.js";
2
- import m from "./subscription-manager.js";
2
+ import f from "./subscription-manager.js";
3
3
  import { logger as E, IndexedDBAdapter as et } from "../../shared-lib/index.js";
4
- export default class kt {
4
+ export default class Gt {
5
5
  constructor(t, i, s) {
6
- (this.B = t),
6
+ (this.C = t),
7
7
  (this.gh = i),
8
- (this.ph = s),
9
- (this.B = t),
8
+ (this.bh = s),
9
+ (this.C = t),
10
10
  (this.gh = i || !1),
11
- (this.ph = s),
12
- (this.Fh = new m()),
13
- (this.kh = 0),
14
- (this.fh = 1);
11
+ (this.bh = s),
12
+ (this.Sh = new f()),
13
+ (this.Ah = 0),
14
+ (this.ph = 1);
15
15
  }
16
- wh() {
16
+ Fh() {
17
17
  return this.gh;
18
18
  }
19
- jh() {
20
- return this.B.dt(s.ft.xh);
19
+ kh() {
20
+ return this.C.Rt(s.Tt.fh);
21
21
  }
22
22
  setSdkAuthenticationSignature(t) {
23
- const i = this.jh();
24
- this.B.bt(s.ft.xh, t);
25
- const e = et.Us.Rs;
26
- new et(e, E).setItem(e.Fs.qh, this.fh, t), i !== t && this.Z();
23
+ const i = this.kh();
24
+ this.C.It(s.Tt.fh, t);
25
+ const e = et.Ps.$s;
26
+ new et(e, E).setItem(e.Os.wh, this.ph, t), i !== t && this.ct();
27
27
  }
28
- yh() {
29
- this.B.zt(s.ft.xh);
30
- const t = et.Us.Rs;
31
- new et(t, E).je(t.Fs.qh, this.fh);
28
+ jh() {
29
+ this.C.Qt(s.Tt.fh);
30
+ const t = et.Ps.$s;
31
+ new et(t, E).ge(t.Os.wh, this.ph);
32
32
  }
33
33
  subscribeToSdkAuthenticationFailures(t) {
34
- return this.ph.Rt(t);
34
+ return this.bh.Kt(t);
35
35
  }
36
- Bh(t) {
37
- this.ph.L(t);
36
+ Ch(t) {
37
+ this.bh.A(t);
38
38
  }
39
- Gh() {
40
- this.Fh.removeAllSubscriptions();
39
+ xh() {
40
+ this.Sh.removeAllSubscriptions();
41
41
  }
42
- Hh() {
43
- this.kh += 1;
42
+ Eh() {
43
+ this.Ah += 1;
44
44
  }
45
- Jh() {
46
- return this.kh;
45
+ Ih() {
46
+ return this.Ah;
47
47
  }
48
- Z() {
49
- this.kh = 0;
48
+ ct() {
49
+ this.Ah = 0;
50
50
  }
51
51
  }