@braze/web-sdk 5.4.0 → 5.5.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 (77) hide show
  1. package/index.d.ts +3 -3
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +12 -12
  4. package/shared-lib/indexed-db-adapter.js +14 -14
  5. package/shared-lib/logger.js +2 -2
  6. package/shared-lib/supported-options.js +5 -5
  7. package/src/Card/card-manager.js +46 -42
  8. package/src/Card/models/card.js +61 -55
  9. package/src/Card/models/classic-card.js +1 -1
  10. package/src/Card/models/control-card.js +1 -1
  11. package/src/Card/models/image-only.js +1 -1
  12. package/src/Card/util/card-factory.js +20 -20
  13. package/src/ContentCards/content-cards-provider.js +140 -140
  14. package/src/ContentCards/get-cached-content-cards.js +1 -1
  15. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  16. package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
  17. package/src/ContentCards/ui/show-content-cards.js +3 -3
  18. package/src/Core/disable-sdk.js +2 -2
  19. package/src/Core/enable-sdk.js +2 -2
  20. package/src/Core/log-custom-event.js +14 -14
  21. package/src/Core/log-purchase.js +8 -8
  22. package/src/Core/open-session.js +4 -4
  23. package/src/Core/wipe-data.js +2 -2
  24. package/src/FeatureFlags/feature-flag-factory.js +5 -5
  25. package/src/FeatureFlags/feature-flag.js +1 -1
  26. package/src/FeatureFlags/feature-flags-provider.js +74 -74
  27. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  28. package/src/FeatureFlags/get-feature-flag.js +2 -2
  29. package/src/FeatureFlags/log-feature-flag-impression.js +12 -12
  30. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  31. package/src/Feed/feed-provider.js +29 -29
  32. package/src/Feed/get-cached-feed.js +1 -1
  33. package/src/Feed/request-feed-refresh.js +1 -1
  34. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  35. package/src/Feed/ui/show-feed.js +1 -1
  36. package/src/InAppMessage/in-app-message-manager.js +63 -63
  37. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  38. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  39. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  40. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  41. package/src/InAppMessage/models/full-screen-message.js +10 -10
  42. package/src/InAppMessage/models/html-message.js +13 -13
  43. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  44. package/src/InAppMessage/models/in-app-message.js +59 -59
  45. package/src/InAppMessage/models/modal-message.js +9 -9
  46. package/src/InAppMessage/models/slide-up-message.js +11 -11
  47. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  48. package/src/Push/push-manager-factory.js +4 -4
  49. package/src/Push/push-manager.js +6 -6
  50. package/src/Push/utils/push-utils.js +1 -1
  51. package/src/User/user-manager.js +6 -6
  52. package/src/User/user.js +27 -27
  53. package/src/common/base-provider.js +1 -1
  54. package/src/common/event-logger.js +7 -7
  55. package/src/common/feed-display.js +1 -1
  56. package/src/managers/auth-manager.js +9 -9
  57. package/src/managers/braze-instance.js +44 -44
  58. package/src/managers/network-manager.js +100 -100
  59. package/src/managers/server-config-manager.js +24 -24
  60. package/src/managers/session-manager.js +10 -10
  61. package/src/managers/storage-manager.js +20 -20
  62. package/src/managers/subscription-manager.js +2 -2
  63. package/src/models/backend-errors.js +4 -4
  64. package/src/models/braze-event.js +1 -1
  65. package/src/models/device.js +1 -1
  66. package/src/models/request-result.js +1 -1
  67. package/src/models/server-config.js +5 -5
  68. package/src/request-controller.js +121 -121
  69. package/src/triggers/models/filter.js +9 -9
  70. package/src/triggers/models/trigger-condition.js +26 -26
  71. package/src/triggers/models/trigger-events.js +1 -1
  72. package/src/triggers/models/trigger.js +7 -7
  73. package/src/triggers/triggers-provider.js +27 -27
  74. package/src/ui/js/attach-css.js +1 -1
  75. package/src/util/braze-actions.js +4 -4
  76. package/src/util/net.js +4 -4
  77. package/src/util/request-header-utils.js +17 -17
@@ -15,14 +15,14 @@ export default class gr extends y {
15
15
  constructor(t, i, s, e, r) {
16
16
  super(),
17
17
  (this.tg = t),
18
- (this.Jt = i),
18
+ (this.Bt = i),
19
19
  (this.u = s),
20
- (this.zi = e),
20
+ (this.Ui = e),
21
21
  (this.ig = r),
22
22
  (this.tg = t),
23
- (this.Jt = i),
23
+ (this.Bt = i),
24
24
  (this.u = s),
25
- (this.zi = e),
25
+ (this.Ui = e),
26
26
  (this.ig = r),
27
27
  (this.sg = []),
28
28
  (this.eg = []),
@@ -70,7 +70,7 @@ export default class gr extends y {
70
70
  h = [];
71
71
  for (let e = 0; e < t.length; e++) {
72
72
  const n = t[e],
73
- o = r.ud(n.Er || 0);
73
+ o = r.ud(n.Nr || 0);
74
74
  if (o > 0) {
75
75
  let t, e;
76
76
  h.push(n),
@@ -82,7 +82,7 @@ export default class gr extends y {
82
82
  const i = s[n.pg[t]];
83
83
  null != i && l.push(i);
84
84
  }
85
- this.eg.push(window.setTimeout(i(r, n.Er || 0, t, e, l), o));
85
+ this.eg.push(window.setTimeout(i(r, n.Nr || 0, t, e, l), o));
86
86
  }
87
87
  }
88
88
  this.ng[r.id].length > h.length &&
@@ -91,24 +91,24 @@ export default class gr extends y {
91
91
  0 === this.ng[r.id].length && delete this.ng[r.id]);
92
92
  }
93
93
  }
94
- e && this.u && this.u.k(o.C.EE, this.ng);
94
+ e && this.u && this.u.I(o.C.EE, this.ng);
95
95
  }
96
96
  mg() {
97
97
  if (!this.u) return;
98
98
  const t = [];
99
99
  for (let i = 0; i < this.triggers.length; i++) t.push(this.triggers[i].Y());
100
100
  (this.lg = new Date().valueOf()),
101
- this.u.k(o.C.rE, t),
102
- this.u.k(o.C.oE, this.lg);
101
+ this.u.I(o.C.rE, t),
102
+ this.u.I(o.C.oE, this.lg);
103
103
  }
104
104
  bg() {
105
105
  if (!this.u) return;
106
106
  (this.u.j(o.C.oE) || 0) > this.lg ? this.ag() : this.fg();
107
107
  }
108
- Ns(t) {
108
+ Ss(t) {
109
109
  let i = !1;
110
110
  if (null != t && t.triggers) {
111
- this.ig.Lr(), this.fg();
111
+ this.ig.Ur(), this.fg();
112
112
  const s = {},
113
113
  e = {};
114
114
  this.triggers = [];
@@ -127,8 +127,8 @@ export default class gr extends y {
127
127
  this.triggers.push(h);
128
128
  }
129
129
  }
130
- ii(this.og, s) || ((this.og = s), this.u && this.u.k(o.C.aE, this.og)),
131
- ii(this.ng, e) || ((this.ng = e), this.u && this.u.k(o.C.EE, this.ng)),
130
+ ii(this.og, s) || ((this.og = s), this.u && this.u.I(o.C.aE, this.og)),
131
+ ii(this.ng, e) || ((this.ng = e), this.u && this.u.I(o.C.EE, this.ng)),
132
132
  this.mg(),
133
133
  i &&
134
134
  (r.info("Trigger with test condition found, firing test."),
@@ -146,16 +146,16 @@ export default class gr extends y {
146
146
  this.fg();
147
147
  const h = new Date().valueOf();
148
148
  t.dd(i) ||
149
- (!1 === navigator.onLine && t.type === gt.Br.Tr && e.imageUrl
149
+ (!1 === navigator.onLine && t.type === gt.Er._r && e.imageUrl
150
150
  ? r.info(
151
151
  `Not showing ${t.type} trigger action ${t.id} due to offline state.`,
152
152
  )
153
153
  : t.nd(h) && this.wg(t, h, s)
154
- ? 0 === this.Jt.ic()
154
+ ? 0 === this.Bt.ic()
155
155
  ? r.info(
156
156
  `Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`,
157
157
  )
158
- : (this.Jt.Dt([e]), this.yg(t, h))
158
+ : (this.Bt.Rt([e]), this.yg(t, h))
159
159
  : r.info(
160
160
  `Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`,
161
161
  ));
@@ -183,27 +183,27 @@ export default class gr extends y {
183
183
  };
184
184
  let l, a, g;
185
185
  switch (t.type) {
186
- case gt.Br.Tr:
186
+ case gt.Er._r:
187
187
  if (((l = pt(t.data)), null == l)) {
188
188
  r.error(
189
189
  `Could not parse trigger data for trigger ${t.id}, ignoring.`,
190
190
  );
191
191
  break;
192
192
  }
193
- if (((a = this.ig.Ki(l)), a)) {
193
+ if (((a = this.ig.Qi(l)), a)) {
194
194
  r.error(a), o();
195
195
  break;
196
196
  }
197
197
  n(l);
198
198
  break;
199
- case gt.Br.md:
200
- if (((g = wt.fromJson(t.data, n, o, i, t.Gr || 0)), null == g)) {
199
+ case gt.Er.md:
200
+ if (((g = wt.fromJson(t.data, n, o, i, t.Or || 0)), null == g)) {
201
201
  r.error(
202
202
  `Could not parse trigger data for trigger ${t.id}, ignoring.`,
203
203
  );
204
204
  break;
205
205
  }
206
- this.ig.Wi(g, s, e);
206
+ this.ig.Zi(g, s, e);
207
207
  break;
208
208
  default:
209
209
  r.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`);
@@ -211,7 +211,7 @@ export default class gr extends y {
211
211
  }
212
212
  fe(t, i = null, s) {
213
213
  if (!J(tt, t, "Cannot fire trigger action.", "TriggerEvents")) return;
214
- if (this.zi && this.zi.zu())
214
+ if (this.Ui && this.Ui.Uu())
215
215
  return (
216
216
  r.info(
217
217
  "Trigger sync is currently in progress, awaiting sync completion before firing trigger event.",
@@ -267,11 +267,11 @@ export default class gr extends y {
267
267
  ));
268
268
  }
269
269
  changeUser(t = !1) {
270
- if (((this.triggers = []), this.u && this.u.ti(o.C.rE), !t)) {
270
+ if (((this.triggers = []), this.u && this.u.ii(o.C.rE), !t)) {
271
271
  (this.sg = []), (this.hg = null), (this.og = {}), (this.ng = {});
272
272
  for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
273
273
  (this.eg = []),
274
- this.u && (this.u.ti(o.C.iE), this.u.ti(o.C.aE), this.u.ti(o.C.EE));
274
+ this.u && (this.u.ii(o.C.iE), this.u.ii(o.C.aE), this.u.ii(o.C.EE));
275
275
  }
276
276
  }
277
277
  clearData() {
@@ -295,18 +295,18 @@ export default class gr extends y {
295
295
  this.fg(), t.id && (this.ng[t.id] = this.ng[t.id] || []);
296
296
  const h = {};
297
297
  let n;
298
- (h.Er = i), (h.ug = s), null != e && (n = e.Y()), (h.dg = n);
298
+ (h.Nr = i), (h.ug = s), null != e && (n = e.Y()), (h.dg = n);
299
299
  const l = [];
300
300
  for (const t of r) t.id && l.push(t.id);
301
301
  (h.pg = l),
302
302
  t.id && this.ng[t.id].push(h),
303
- this.u && this.u.k(o.C.EE, this.ng);
303
+ this.u && this.u.I(o.C.EE, this.ng);
304
304
  }
305
305
  yg(t, i) {
306
306
  this.fg(),
307
307
  t.ad(i),
308
308
  (this.hg = i),
309
309
  t.id && (this.og[t.id] = i),
310
- this.u && (this.u.k(o.C.iE, i), this.u.k(o.C.aE, this.og));
310
+ this.u && (this.u.I(o.C.iE, i), this.u.I(o.C.aE, this.og));
311
311
  }
312
312
  }
@@ -1,7 +1,7 @@
1
1
  import e, { OPTIONS as L } from "../../managers/braze-instance.js";
2
2
  export function attachCSS(n, t, o) {
3
3
  const c = n || document.querySelector("head"),
4
- s = `ab-${t}-css-definitions-${"5.4.0".replace(/\./g, "-")}`;
4
+ s = `ab-${t}-css-definitions-${"5.5.0".replace(/\./g, "-")}`;
5
5
  if (!c) return;
6
6
  const a = c.ownerDocument || document;
7
7
  if (null == a.getElementById(s)) {
@@ -25,14 +25,14 @@ export const BRAZE_ACTIONS = {
25
25
  properties: { type: "type", oo: "steps", eo: "args" },
26
26
  };
27
27
  export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
28
- Li: "unknownBrazeAction",
29
- Vi: "noPushPrompt",
28
+ Vi: "unknownBrazeAction",
29
+ Yi: "noPushPrompt",
30
30
  };
31
31
  export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
32
32
  switch (t) {
33
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Li:
34
- return `${o} contains an unknown braze action type and will not be displayed.`;
35
33
  case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Vi:
34
+ return `${o} contains an unknown braze action type and will not be displayed.`;
35
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Yi:
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 "";
package/src/util/net.js CHANGED
@@ -2,7 +2,7 @@ import { logger as r } from "../../shared-lib/index.js";
2
2
  import Xt from "../models/backend-errors.js";
3
3
  import { getErrorMessage as si } from "./error-utils.js";
4
4
  const C = {
5
- Gs: (t) => {
5
+ Ks: (t) => {
6
6
  let e, o;
7
7
  try {
8
8
  const n = () => {
@@ -13,7 +13,7 @@ const C = {
13
13
  e = new XMLHttpRequest();
14
14
  const i = () => {
15
15
  "function" == typeof t.error && t.error(e.status),
16
- "function" == typeof t.Ws && t.Ws(!1);
16
+ "function" == typeof t.Zs && t.Zs(!1);
17
17
  };
18
18
  (e.onload = () => {
19
19
  let o = !1;
@@ -28,14 +28,14 @@ const C = {
28
28
  (r = e.getAllResponseHeaders());
29
29
  } catch (o) {
30
30
  const n = {
31
- error: "" === e.responseText ? Xt.Ra : Xt.qa,
31
+ error: "" === e.responseText ? Xt.Ra : Xt.Ba,
32
32
  response: e.responseText,
33
33
  };
34
34
  (0, t.L)(n, r);
35
35
  }
36
36
  o && t.L(o, r);
37
37
  }
38
- "function" == typeof t.Ws && t.Ws(!0);
38
+ "function" == typeof t.Zs && t.Zs(!0);
39
39
  } else i();
40
40
  }),
41
41
  (e.onerror = () => {
@@ -1,47 +1,47 @@
1
1
  import { REQUEST_ATTEMPT_DEFAULT as Ae } from "../common/constants.js";
2
2
  import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
3
3
  const D = {
4
- Ps: {
5
- La: "data",
6
- Bs: "content_cards/sync",
7
- bi: "feature_flags/sync",
8
- Ir: "template",
4
+ _s: {
5
+ Ka: "data",
6
+ Xs: "content_cards/sync",
7
+ Ri: "feature_flags/sync",
8
+ Tr: "template",
9
9
  },
10
- Du: (t) => (null == t ? void 0 : t.j(o.C.lE)),
10
+ ku: (t) => (null == t ? void 0 : t.j(o.C.lE)),
11
11
  sm: (t) => (null == t ? void 0 : t.j(o.C.SE)),
12
12
  nm: (t, e) => {
13
- null == t || t.k(o.C.lE, e);
13
+ null == t || t.I(o.C.lE, e);
14
14
  },
15
15
  um: (t, e) => {
16
- null == t || t.k(o.C.SE, e);
16
+ null == t || t.I(o.C.SE, e);
17
17
  },
18
- Ua: (t, e) => {
18
+ Wa: (t, e) => {
19
19
  if (!t || !e) return -1;
20
- const s = D.Du(t);
20
+ const s = D.ku(t);
21
21
  if (null == s) return -1;
22
22
  const n = s[e];
23
23
  return null == n || isNaN(n) ? -1 : n;
24
24
  },
25
- Ha: (t, e) => {
25
+ Ya: (t, e) => {
26
26
  let s = Ae;
27
27
  if (!t || !e) return s;
28
28
  const n = D.sm(t);
29
29
  return null == n ? s : ((s = n[e]), null == s || isNaN(s) ? Ae : s);
30
30
  },
31
- _s: (t, e, s) => {
31
+ Hs: (t, e, s) => {
32
32
  if (!t || !e) return;
33
- let n = D.Du(t);
33
+ let n = D.ku(t);
34
34
  null == n && (n = {}), (n[e] = s), D.nm(t, n);
35
35
  },
36
- Qs: (t, e, s) => {
36
+ Ws: (t, e, s) => {
37
37
  if (!t || !e) return;
38
38
  let n = D.sm(t);
39
39
  null == n && (n = {}), (n[e] = s), D.um(t, n);
40
40
  },
41
- Ys: (t, e) => {
41
+ ti: (t, e) => {
42
42
  if (!t || !e) return;
43
- const s = D.Ha(t, e);
44
- D.Qs(t, e, s + 1);
43
+ const s = D.Ya(t, e);
44
+ D.Ws(t, e, s + 1);
45
45
  },
46
46
  };
47
47
  export default D;