@braze/web-sdk 5.7.0 → 5.8.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 (98) hide show
  1. package/index.d.ts +4 -4
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +1 -1
  4. package/shared-lib/event-types.js +8 -8
  5. package/shared-lib/indexed-db-adapter.js +7 -7
  6. package/shared-lib/logger.js +2 -2
  7. package/shared-lib/supported-options.js +17 -17
  8. package/src/Banner/get-all-banners.js +2 -3
  9. package/src/Banner/get-banner.js +11 -11
  10. package/src/Banner/request-banners-refresh.js +20 -12
  11. package/src/Banner/subscribe-to-banners-updates.js +14 -13
  12. package/src/Banner/ui/insert-banner.js +11 -9
  13. package/src/Card/log-card-impressions.js +2 -2
  14. package/src/ContentCards/content-cards-provider-factory.js +1 -1
  15. package/src/ContentCards/content-cards.js +3 -3
  16. package/src/ContentCards/ui/show-content-cards.js +5 -5
  17. package/src/Core/add-sdk-metadata.js +2 -2
  18. package/src/Core/change-user.js +3 -3
  19. package/src/Core/disable-sdk.js +5 -5
  20. package/src/Core/enable-sdk.js +3 -3
  21. package/src/Core/get-device-id.js +2 -2
  22. package/src/Core/get-user.js +1 -1
  23. package/src/Core/is-disabled.js +1 -1
  24. package/src/Core/open-session.js +6 -6
  25. package/src/Core/wipe-data.js +1 -1
  26. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  27. package/src/FeatureFlags/feature-flag.js +17 -17
  28. package/src/FeatureFlags/feature-flags-provider.js +37 -37
  29. package/src/FeatureFlags/get-all-feature-flags.js +6 -7
  30. package/src/FeatureFlags/get-feature-flag.js +5 -6
  31. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  32. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  33. package/src/Feed/feed.js +2 -2
  34. package/src/Feed/ui/show-feed.js +4 -4
  35. package/src/InAppMessage/defer-in-app-message.js +1 -1
  36. package/src/InAppMessage/display/html-message-to-html.js +6 -6
  37. package/src/InAppMessage/display/in-app-message-to-html.js +18 -18
  38. package/src/InAppMessage/display/modal-utils.js +4 -4
  39. package/src/InAppMessage/in-app-message-factory.js +4 -4
  40. package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
  41. package/src/InAppMessage/in-app-message-manager.js +49 -49
  42. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  43. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  44. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  45. package/src/InAppMessage/models/control-message.js +1 -1
  46. package/src/InAppMessage/models/full-screen-message.js +3 -3
  47. package/src/InAppMessage/models/html-message.js +5 -5
  48. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  49. package/src/InAppMessage/models/in-app-message.js +32 -32
  50. package/src/InAppMessage/models/modal-message.js +3 -3
  51. package/src/InAppMessage/models/slide-up-message.js +6 -6
  52. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  53. package/src/InAppMessage/ui/show-in-app-message.js +18 -18
  54. package/src/Push/push-manager-factory.js +8 -8
  55. package/src/Push/push-manager.js +83 -83
  56. package/src/Push/utils/push-utils.js +4 -4
  57. package/src/User/user-manager.js +6 -6
  58. package/src/User/user.js +18 -18
  59. package/src/common/base-feed.js +3 -3
  60. package/src/common/event-logger.js +1 -1
  61. package/src/common/feed-display.js +8 -8
  62. package/src/l10n/l10n-manager-factory.js +2 -2
  63. package/src/l10n/l10n-manager.js +1 -1
  64. package/src/managers/braze-instance.js +107 -107
  65. package/src/managers/device-manager.js +18 -18
  66. package/src/managers/network-manager.js +117 -117
  67. package/src/managers/server-config-manager.js +61 -61
  68. package/src/managers/session-manager.js +25 -25
  69. package/src/managers/storage-manager-factory.js +8 -8
  70. package/src/managers/storage-manager.js +57 -57
  71. package/src/models/backend-errors.js +5 -5
  72. package/src/models/braze-event.js +2 -2
  73. package/src/models/device.js +2 -2
  74. package/src/models/identifier.js +10 -10
  75. package/src/models/push-token.js +7 -7
  76. package/src/models/server-config.js +30 -30
  77. package/src/request-controller.js +93 -93
  78. package/src/triggers/models/filter-set.js +4 -4
  79. package/src/triggers/models/filter.js +1 -1
  80. package/src/triggers/models/trigger-condition.js +29 -29
  81. package/src/triggers/models/trigger-events.js +1 -1
  82. package/src/triggers/models/trigger.js +9 -9
  83. package/src/triggers/triggers-provider-factory.js +2 -2
  84. package/src/triggers/triggers-provider.js +15 -15
  85. package/src/ui/js/attach-css.js +3 -3
  86. package/src/ui/js/load-font-awesome.js +2 -2
  87. package/src/util/base-device-parser.js +3 -3
  88. package/src/util/braze-actions.js +4 -4
  89. package/src/util/browser-detector.js +5 -5
  90. package/src/util/client-hints-parser.js +1 -1
  91. package/src/util/component-utils.js +1 -1
  92. package/src/util/dom-utils.js +6 -6
  93. package/src/util/key-codes.js +1 -1
  94. package/src/util/net.js +1 -1
  95. package/src/util/request-header-utils.js +13 -13
  96. package/src/util/user-agent-parser.js +1 -1
  97. package/src/util/validation-utils.js +4 -4
  98. package/src/util/window-utils.js +1 -1
@@ -2,7 +2,7 @@ import s from "../common/base-provider.js";
2
2
  import { newInAppMessageFromJson as ut } from "../InAppMessage/in-app-message-factory.js";
3
3
  import ve from "../models/braze-event.js";
4
4
  import {
5
- isArray as w,
5
+ isArray as z,
6
6
  isEqual as ii,
7
7
  validateValueIsFromEnum as ta,
8
8
  } from "../util/code-utils.js";
@@ -50,7 +50,7 @@ export default class gr extends s {
50
50
  this.lg = this.C.vs(t.gs.oE) || 0;
51
51
  const i = this.C.vs(t.gs.rE) || [],
52
52
  s = [];
53
- for (let t = 0; t < i.length; t++) s.push(pt.Yn(i[t]));
53
+ for (let t = 0; t < i.length; t++) s.push(pt.Bn(i[t]));
54
54
  (this.triggers = s), this.fg();
55
55
  }
56
56
  gg() {
@@ -70,19 +70,19 @@ export default class gr extends s {
70
70
  h = [];
71
71
  for (let r = 0; r < t.length; r++) {
72
72
  const n = t[r],
73
- o = i.ud(n.Zr || 0);
73
+ o = i.ud(n.Wr || 0);
74
74
  if (o > 0) {
75
75
  let t, r;
76
76
  h.push(n),
77
77
  null != n.ug && (t = n.ug),
78
- null != n.dg && ve.RE(n.dg) && (r = ve.Yn(n.dg));
78
+ null != n.dg && ve.RE(n.dg) && (r = ve.Bn(n.dg));
79
79
  const l = [];
80
- if (n.pg && w(n.pg))
80
+ if (n.pg && z(n.pg))
81
81
  for (let t = 0; t < n.pg.length; t++) {
82
82
  const i = e[n.pg[t]];
83
83
  null != i && l.push(i);
84
84
  }
85
- this.eg.push(window.setTimeout(s(i, n.Zr || 0, t, r, l), o));
85
+ this.eg.push(window.setTimeout(s(i, n.Wr || 0, t, r, l), o));
86
86
  }
87
87
  }
88
88
  this.ng[i.id].length > h.length &&
@@ -109,7 +109,7 @@ export default class gr extends s {
109
109
  U(i) {
110
110
  let s = !1;
111
111
  if (null != i && i.triggers) {
112
- this.ig.hn(), this.fg();
112
+ this.ig.pn(), this.fg();
113
113
  const e = {},
114
114
  r = {};
115
115
  this.triggers = [];
@@ -148,7 +148,7 @@ export default class gr extends s {
148
148
  this.fg();
149
149
  const r = new Date().valueOf();
150
150
  t.dd(i) ||
151
- (!1 === navigator.onLine && t.type === pt.Wr.Vr && e.imageUrl
151
+ (!1 === navigator.onLine && t.type === pt.Ur.Qr && e.imageUrl
152
152
  ? N.info(
153
153
  `Not showing ${t.type} trigger action ${t.id} due to offline state.`,
154
154
  )
@@ -185,27 +185,27 @@ export default class gr extends s {
185
185
  };
186
186
  let o, l, a;
187
187
  switch (t.type) {
188
- case pt.Wr.Vr:
188
+ case pt.Ur.Qr:
189
189
  if (((o = ut(t.data)), null == o)) {
190
190
  N.error(
191
191
  `Could not parse trigger data for trigger ${t.id}, ignoring.`,
192
192
  );
193
193
  break;
194
194
  }
195
- if (((l = this.ig.Gr(o)), l)) {
195
+ if (((l = this.ig.Er(o)), l)) {
196
196
  N.error(l), n();
197
197
  break;
198
198
  }
199
199
  h(o);
200
200
  break;
201
- case pt.Wr.md:
202
- if (((a = wt.fromJson(t.data, h, n, i, t.sn || 0)), null == a)) {
201
+ case pt.Ur.md:
202
+ if (((a = wt.fromJson(t.data, h, n, i, t.Yr || 0)), null == a)) {
203
203
  N.error(
204
204
  `Could not parse trigger data for trigger ${t.id}, ignoring.`,
205
205
  );
206
206
  break;
207
207
  }
208
- this.ig.Jr(a, s, e);
208
+ this.ig.Xr(a, s, e);
209
209
  break;
210
210
  default:
211
211
  N.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`);
@@ -213,7 +213,7 @@ export default class gr extends s {
213
213
  }
214
214
  ue(t, i = null, s) {
215
215
  if (!ta(et, t, "Cannot fire trigger action.", "TriggerEvents")) return;
216
- if (this.Bi && this.Bi.cc())
216
+ if (this.Bi && this.Bi.uc())
217
217
  return (
218
218
  N.info(
219
219
  "Trigger sync is currently in progress, awaiting sync completion before firing trigger event.",
@@ -297,7 +297,7 @@ export default class gr extends s {
297
297
  this.fg(), i.id && (this.ng[i.id] = this.ng[i.id] || []);
298
298
  const n = {};
299
299
  let o;
300
- (n.Zr = s), (n.ug = e), null != r && (o = r.bs()), (n.dg = o);
300
+ (n.Wr = s), (n.ug = e), null != r && (o = r.bs()), (n.dg = o);
301
301
  const l = [];
302
302
  for (const t of h) t.id && l.push(t.id);
303
303
  (n.pg = l),
@@ -1,13 +1,13 @@
1
- import r, { OPTIONS as z } from "../../managers/braze-instance.js";
1
+ import r, { OPTIONS as w } from "../../managers/braze-instance.js";
2
2
  export function attachCSS(n, t, o) {
3
3
  const c = n || document.querySelector("head"),
4
- e = `ab-${t}-css-definitions-${"5.7.0".replace(/\./g, "-")}`;
4
+ e = `ab-${t}-css-definitions-${"5.8.0".replace(/\./g, "-")}`;
5
5
  if (!c) return;
6
6
  const s = c.ownerDocument || document;
7
7
  if (null == s.getElementById(e)) {
8
8
  const n = s.createElement("style");
9
9
  (n.innerHTML = o || ""), (n.id = e);
10
- const t = r.sr(z.ir);
10
+ const t = r.ee(w.er);
11
11
  null != t && n.setAttribute("nonce", t), c.appendChild(n);
12
12
  }
13
13
  }
@@ -1,6 +1,6 @@
1
- import r, { OPTIONS as z } from "../../managers/braze-instance.js";
1
+ import r, { OPTIONS as w } from "../../managers/braze-instance.js";
2
2
  export function loadFontAwesome() {
3
- if (r.sr(z.Vh)) return;
3
+ if (r.ee(w.Yh)) return;
4
4
  const e = "https://use.fontawesome.com/7f85a56ba4.css";
5
5
  if (
6
6
  !(null !== document.querySelector('link[rel=stylesheet][href="' + e + '"]'))
@@ -1,12 +1,12 @@
1
- import { isArray as w } from "./code-utils.js";
1
+ import { isArray as z } from "./code-utils.js";
2
2
  export default class Oe {
3
3
  constructor() {}
4
4
  ef() {}
5
5
  ff() {}
6
- Qa(t) {}
6
+ Xa(t) {}
7
7
  static nf(t, e) {
8
8
  if (t && e)
9
- if (((t = t.toLowerCase()), w(e.cf))) {
9
+ if (((t = t.toLowerCase()), z(e.cf))) {
10
10
  for (let r = 0; r < e.cf.length; r++)
11
11
  if (-1 !== t.indexOf(e.cf[r].toLowerCase())) return e.identity;
12
12
  } else if (-1 !== t.indexOf(e.cf.toLowerCase())) return e.identity;
@@ -25,14 +25,14 @@ export const BRAZE_ACTIONS = {
25
25
  properties: { type: "type", eo: "steps", so: "args" },
26
26
  };
27
27
  export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
28
- Nr: "unknownBrazeAction",
29
- Or: "noPushPrompt",
28
+ Gr: "unknownBrazeAction",
29
+ $r: "noPushPrompt",
30
30
  };
31
31
  export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
32
32
  switch (t) {
33
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Nr:
33
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Gr:
34
34
  return `${o} contains an unknown braze action type and will not be displayed.`;
35
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Or:
35
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.$r:
36
36
  return `${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;
37
37
  default:
38
38
  return "";
@@ -9,7 +9,7 @@ class ui {
9
9
  (this.browser = this.Sg.ef()),
10
10
  (this.version = this.Sg.ff()),
11
11
  (this.OS = null),
12
- this.Qa().then((t) => (this.OS = t));
12
+ this.Xa().then((t) => (this.OS = t));
13
13
  const i = navigator;
14
14
  (this.language = (
15
15
  i.userLanguage ||
@@ -18,18 +18,18 @@ class ui {
18
18
  i.systemLanguage ||
19
19
  ""
20
20
  ).toLowerCase()),
21
- (this.Wa = ui.vg(this.userAgent));
21
+ (this.Fa = ui.vg(this.userAgent));
22
22
  }
23
23
  fE() {
24
24
  return this.browser === oi.Bg;
25
25
  }
26
- Za() {
26
+ tc() {
27
27
  return this.OS || null;
28
28
  }
29
- Qa() {
29
+ Xa() {
30
30
  return this.OS
31
31
  ? Promise.resolve(this.OS)
32
- : this.Sg.Qa(ui.kg).then((t) => ((this.OS = t), t));
32
+ : this.Sg.Xa(ui.kg).then((t) => ((this.OS = t), t));
33
33
  }
34
34
  static vg(t) {
35
35
  t = t.toLowerCase();
@@ -21,7 +21,7 @@ export default class ai extends Oe {
21
21
  ff() {
22
22
  return this.version;
23
23
  }
24
- Qa(t) {
24
+ Xa(t) {
25
25
  if (this.OS) return Promise.resolve(this.OS);
26
26
  const s = (s) => {
27
27
  for (let r = 0; r < t.length; r++) {
@@ -16,7 +16,7 @@ export function createCloseButton(t, o, e, n = "ltr") {
16
16
  return (
17
17
  r.appendChild(l),
18
18
  r.addEventListener("keydown", (t) => {
19
- (t.keyCode !== mt.Ro && t.keyCode !== mt.Lo) ||
19
+ (t.keyCode !== mt.Ro && t.keyCode !== mt.Oo) ||
20
20
  (e(), t.stopPropagation());
21
21
  }),
22
22
  (r.onclick = (t) => {
@@ -18,8 +18,8 @@ export function _isInView(t, n = !1, e = !1, s = !1) {
18
18
  !s)
19
19
  );
20
20
  }
21
- export const DOMUtils = { Ic: null, Mo: _isInView };
22
- export const DIRECTIONS = { Co: "up", $o: "down", kt: "left", Ht: "right" };
21
+ export const DOMUtils = { Ic: null, Ho: _isInView };
22
+ export const DIRECTIONS = { ko: "up", Mo: "down", kt: "left", Ht: "right" };
23
23
  export function supportsPassive() {
24
24
  if (null == DOMUtils.Ic) {
25
25
  DOMUtils.Ic = !1;
@@ -41,10 +41,10 @@ export function addPassiveEventListener(t, n, e = () => {}) {
41
41
  t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
42
42
  }
43
43
  export function topIsInView(t) {
44
- return DOMUtils.Mo(t, !0, !1, !1);
44
+ return DOMUtils.Ho(t, !0, !1, !1);
45
45
  }
46
46
  export function bottomIsInView(t) {
47
- return DOMUtils.Mo(t, !1, !0, !1);
47
+ return DOMUtils.Ho(t, !1, !0, !1);
48
48
  }
49
49
  export function clickElement(t) {
50
50
  if (t.onclick) {
@@ -69,9 +69,9 @@ export function detectSwipe(t, n, e) {
69
69
  (i = null))
70
70
  : Math.abs(u) >= 25 &&
71
71
  (((u > 0 &&
72
- n === DIRECTIONS.Co &&
72
+ n === DIRECTIONS.ko &&
73
73
  t.scrollTop === t.scrollHeight - t.offsetHeight) ||
74
- (u < 0 && n === DIRECTIONS.$o && 0 === t.scrollTop)) &&
74
+ (u < 0 && n === DIRECTIONS.Mo && 0 === t.scrollTop)) &&
75
75
  e(o),
76
76
  (s = null),
77
77
  (i = null));
@@ -1 +1 @@
1
- export const KeyCodes = { Ro: 32, yo: 9, Lo: 13, _h: 27 };
1
+ export const KeyCodes = { Ro: 32, yo: 9, Oo: 13, _h: 27 };
package/src/util/net.js CHANGED
@@ -27,7 +27,7 @@ const l = {
27
27
  o = JSON.parse(e.responseText);
28
28
  } catch (o) {
29
29
  const n = {
30
- error: "" === e.responseText ? qt.ku : qt.yu,
30
+ error: "" === e.responseText ? qt.Au : qt.ku,
31
31
  response: e.responseText,
32
32
  };
33
33
  (0, t.ss)(n, r);
@@ -2,13 +2,13 @@ import { REQUEST_ATTEMPT_DEFAULT as Ae } from "../common/constants.js";
2
2
  import { STORAGE_KEYS as t } from "../managers/storage-manager.js";
3
3
  const h = {
4
4
  O: {
5
- zu: "data",
5
+ Su: "data",
6
6
  Ai: "content_cards/sync",
7
- Ue: "feature_flags/sync",
8
- Kr: "template",
7
+ _e: "feature_flags/sync",
8
+ Hr: "template",
9
9
  K: "banners/sync",
10
10
  },
11
- il: (e) => (null == e ? void 0 : e.vs(t.gs.lE)),
11
+ tl: (e) => (null == e ? void 0 : e.vs(t.gs.lE)),
12
12
  sm: (e) => (null == e ? void 0 : e.vs(t.gs.SE)),
13
13
  nm: (e, s) => {
14
14
  null == e || e.Bs(t.gs.lE, s);
@@ -16,14 +16,14 @@ const h = {
16
16
  rm: (e, s) => {
17
17
  null == e || e.Bs(t.gs.SE, s);
18
18
  },
19
- $u: (t, e) => {
19
+ Mu: (t, e) => {
20
20
  if (!t || !e) return -1;
21
- const s = h.il(t);
21
+ const s = h.tl(t);
22
22
  if (null == s) return -1;
23
23
  const n = s[e];
24
24
  return null == n || isNaN(n) ? -1 : n;
25
25
  },
26
- Fu: (t, e) => {
26
+ Xu: (t, e) => {
27
27
  let s = Ae;
28
28
  if (!t || !e) return s;
29
29
  const n = h.sm(t);
@@ -31,21 +31,21 @@ const h = {
31
31
  },
32
32
  W: (t, e, s) => {
33
33
  if (!t || !e) return;
34
- let n = h.il(t);
34
+ let n = h.tl(t);
35
35
  null == n && (n = {}), (n[e] = s), h.nm(t, n);
36
36
  },
37
- Lu: (t, e, s) => {
37
+ $u: (t, e, s) => {
38
38
  if (!t || !e) return;
39
39
  let n = h.sm(t);
40
40
  null == n && (n = {}), (n[e] = s), h.rm(t, n);
41
41
  },
42
42
  zi: (t, e) => {
43
- t && e && h.Lu(t, e, Ae);
43
+ t && e && h.$u(t, e, Ae);
44
44
  },
45
- Gu: (t, e) => {
45
+ Hu: (t, e) => {
46
46
  if (!t || !e) return;
47
- const s = h.Fu(t, e);
48
- h.Lu(t, e, s + 1);
47
+ const s = h.Xu(t, e);
48
+ h.$u(t, e, s + 1);
49
49
  },
50
50
  };
51
51
  export default h;
@@ -10,7 +10,7 @@ export default class gi extends Oe {
10
10
  ff() {
11
11
  return this.fd[1] || "Unknown Version";
12
12
  }
13
- Qa(r) {
13
+ Xa(r) {
14
14
  for (let n = 0; n < r.length; n++) {
15
15
  const e = r[n].string;
16
16
  let i = gi.nf(e, r[n]);
@@ -1,5 +1,5 @@
1
1
  import {
2
- isArray as w,
2
+ isArray as z,
3
3
  isDate as Nt,
4
4
  isObject as yt,
5
5
  keys as y,
@@ -57,7 +57,7 @@ export function _validateNestedProperties(t, e, r) {
57
57
  if (n && r > 50)
58
58
  return N.error("Nested attributes cannot be more than 50 levels deep."), !1;
59
59
  const o = n ? r + 1 : -1;
60
- if (w(t) && w(e)) {
60
+ if (z(t) && z(e)) {
61
61
  for (let r = 0; r < t.length && r < e.length; r++)
62
62
  if (
63
63
  (Nt(t[r]) && (e[r] = Ft(t[r])),
@@ -81,7 +81,7 @@ export function _validateEventPropertyValue(t, e, r, n, o) {
81
81
  let i;
82
82
  return (
83
83
  (i =
84
- yt(t) || w(t)
84
+ yt(t) || z(t)
85
85
  ? _validateNestedProperties(t, e, o ? 1 : -1)
86
86
  : validatePropertyType(t)),
87
87
  i || N.error(`Cannot ${r} because ${n} "${t}" is invalid.`),
@@ -93,7 +93,7 @@ export function validateStandardString(t, e, r, n = !1) {
93
93
  return o || N.error(`Cannot ${e} because ${r} "${t}" is invalid.`), o;
94
94
  }
95
95
  export function validateCustomProperties(t, e, r, n, o) {
96
- if ((null == t && (t = {}), "object" != typeof t || w(t)))
96
+ if ((null == t && (t = {}), "object" != typeof t || z(t)))
97
97
  return (
98
98
  N.error(`${e} requires that ${r} be an object. Ignoring ${o}.`),
99
99
  [!1, null]
@@ -30,5 +30,5 @@ export const WindowUtils = {
30
30
  openUri: _openUri,
31
31
  Uo: _isPhone,
32
32
  Jo: _getOrientation,
33
- Ua: _getCurrentUrl,
33
+ Va: _getCurrentUrl,
34
34
  };