@braze/web-sdk 4.5.1 → 4.6.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 (84) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +49 -8
  3. package/package.json +1 -1
  4. package/shared-lib/braze-shared-lib.js +7 -7
  5. package/shared-lib/encoding-utils.js +3 -3
  6. package/shared-lib/event-types.js +14 -14
  7. package/shared-lib/guid.js +2 -2
  8. package/shared-lib/indexed-db-adapter.js +3 -3
  9. package/shared-lib/logger.js +18 -18
  10. package/shared-lib/supported-options.js +15 -15
  11. package/src/Card/index.js +1 -0
  12. package/src/Card/log-content-card-click.js +4 -0
  13. package/src/FeatureFlags/feature-flag-factory.js +13 -5
  14. package/src/FeatureFlags/feature-flag.js +36 -8
  15. package/src/FeatureFlags/feature-flags-provider.js +58 -33
  16. package/src/FeatureFlags/get-all-feature-flags.js +3 -3
  17. package/src/FeatureFlags/get-feature-flag.js +5 -5
  18. package/src/FeatureFlags/index.js +1 -0
  19. package/src/Feed/feed-provider-factory.js +8 -8
  20. package/src/Feed/feed-provider.js +3 -3
  21. package/src/Feed/get-cached-feed.js +2 -2
  22. package/src/Feed/log-feed-displayed.js +1 -1
  23. package/src/Feed/request-feed-refresh.js +2 -2
  24. package/src/Feed/subscribe-to-feed-updates.js +2 -2
  25. package/src/Feed/ui/show-feed.js +2 -2
  26. package/src/InAppMessage/display/html-message-to-html.js +3 -3
  27. package/src/InAppMessage/display/in-app-message-to-html.js +101 -86
  28. package/src/InAppMessage/display/modal-utils.js +9 -9
  29. package/src/InAppMessage/in-app-message-factory.js +1 -1
  30. package/src/InAppMessage/in-app-message-manager-factory.js +3 -3
  31. package/src/InAppMessage/in-app-message-manager.js +52 -52
  32. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  33. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  34. package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
  35. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  36. package/src/InAppMessage/models/full-screen-message.js +1 -1
  37. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  38. package/src/InAppMessage/models/in-app-message.js +68 -68
  39. package/src/InAppMessage/models/modal-message.js +2 -2
  40. package/src/InAppMessage/models/slide-up-message.js +8 -8
  41. package/src/InAppMessage/models/templated-in-app-message.js +4 -4
  42. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  43. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  44. package/src/InAppMessage/ui/show-in-app-message.js +24 -21
  45. package/src/Push/push-manager.js +54 -54
  46. package/src/Push/utils/push-utils.js +4 -4
  47. package/src/User/user-manager.js +4 -4
  48. package/src/User/user.js +13 -13
  49. package/src/common/base-feed.js +1 -1
  50. package/src/common/feed-display.js +22 -22
  51. package/src/l10n/l10n-manager-factory.js +7 -7
  52. package/src/managers/auth-manager.js +23 -23
  53. package/src/managers/braze-instance.js +93 -93
  54. package/src/managers/device-manager.js +2 -2
  55. package/src/managers/network-manager.js +42 -42
  56. package/src/managers/server-config-manager.js +9 -9
  57. package/src/managers/session-manager.js +27 -27
  58. package/src/managers/storage-manager-factory.js +1 -1
  59. package/src/managers/storage-manager.js +61 -61
  60. package/src/managers/subscription-manager.js +6 -6
  61. package/src/models/backend-errors.js +5 -5
  62. package/src/models/braze-event.js +2 -2
  63. package/src/models/device.js +1 -1
  64. package/src/models/identifier.js +6 -6
  65. package/src/models/push-token.js +3 -3
  66. package/src/models/server-config.js +3 -3
  67. package/src/request-controller.js +52 -52
  68. package/src/triggers/models/filter-set.js +2 -2
  69. package/src/triggers/models/filter.js +34 -34
  70. package/src/triggers/models/in-app-message-click-data.js +6 -6
  71. package/src/triggers/models/push-click-data.js +1 -1
  72. package/src/triggers/models/trigger-condition.js +8 -8
  73. package/src/triggers/models/trigger-events.js +1 -1
  74. package/src/triggers/models/trigger.js +30 -30
  75. package/src/triggers/triggers-provider-factory.js +2 -2
  76. package/src/triggers/triggers-provider.js +37 -37
  77. package/src/ui/js/attach-css.js +1 -1
  78. package/src/ui/js/load-font-awesome.js +1 -1
  79. package/src/util/braze-actions.js +4 -4
  80. package/src/util/browser-detector.js +2 -2
  81. package/src/util/dom-utils.js +8 -8
  82. package/src/util/key-codes.js +1 -1
  83. package/src/util/net.js +3 -3
  84. package/src/util/window-utils.js +1 -1
@@ -9,7 +9,7 @@ import {
9
9
  } from "../util/code-utils.js";
10
10
  import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
11
11
  import wt from "../InAppMessage/models/templated-in-app-message.js";
12
- import mt from "./models/trigger.js";
12
+ import pt from "./models/trigger.js";
13
13
  import V from "./models/trigger-events.js";
14
14
  import r from "../../shared-lib/braze-shared-lib.js";
15
15
  export default class gr extends y {
@@ -34,14 +34,14 @@ export default class gr extends y {
34
34
  (this.ng = this.h.I(o.q.Ga) || this.ng);
35
35
  for (let t = 0; t < this.cg.length; t++) {
36
36
  const i = this.cg[t];
37
- null != this.ng[i.id] && i.Zh(this.ng[i.id]);
37
+ null != this.ng[i.id] && i.ju(this.ng[i.id]);
38
38
  }
39
39
  }
40
40
  ag() {
41
41
  this.fg = this.h.I(o.q.Da) || 0;
42
42
  const t = this.h.I(o.q.Ya) || [],
43
43
  i = [];
44
- for (let s = 0; s < t.length; s++) i.push(mt.Sn(t[s]));
44
+ for (let s = 0; s < t.length; s++) i.push(pt.jn(t[s]));
45
45
  (this.cg = i), this.gg();
46
46
  }
47
47
  lg() {
@@ -61,19 +61,19 @@ export default class gr extends y {
61
61
  h = [];
62
62
  for (let e = 0; e < t.length; e++) {
63
63
  const o = t[e],
64
- n = r.gu(o.Si);
64
+ n = r.wu(o.qi);
65
65
  if (n > 0) {
66
66
  let t, e;
67
67
  h.push(o),
68
68
  null != o.dg && (t = o.dg),
69
- null != o.mg && ue.Fa(o.mg) && (e = ue.Sn(o.mg));
69
+ null != o.mg && ue.Fa(o.mg) && (e = ue.jn(o.mg));
70
70
  const a = [];
71
71
  if (p(o.pg))
72
72
  for (let t = 0; t < o.pg.length; t++) {
73
73
  const i = s[o.pg[t]];
74
74
  null != i && a.push(i);
75
75
  }
76
- this.eg.push(setTimeout(i(r, o.Si, t, e, a), n));
76
+ this.eg.push(setTimeout(i(r, o.qi, t, e, a), n));
77
77
  }
78
78
  }
79
79
  this.og[r.id].length > h.length &&
@@ -102,12 +102,12 @@ export default class gr extends y {
102
102
  e = {};
103
103
  this.cg = [];
104
104
  for (let r = 0; r < t.triggers.length; r++) {
105
- const h = mt.fromJson(t.triggers[r]);
105
+ const h = pt.fromJson(t.triggers[r]);
106
106
  null != this.ng[h.id] &&
107
- (h.Zh(this.ng[h.id]), (s[h.id] = this.ng[h.id])),
107
+ (h.ju(this.ng[h.id]), (s[h.id] = this.ng[h.id])),
108
108
  null != this.og[h.id] && (e[h.id] = this.og[h.id]);
109
- for (let t = 0; t < h.Ph.length; t++)
110
- if (h.Ph[t].ec(V.ks, null)) {
109
+ for (let t = 0; t < h.$h.length; t++)
110
+ if (h.$h[t].ec(V.ks, null)) {
111
111
  i = !0;
112
112
  break;
113
113
  }
@@ -129,13 +129,13 @@ export default class gr extends y {
129
129
  const o = e => {
130
130
  this.gg();
131
131
  const h = new Date().valueOf();
132
- if (!t.pu(i))
133
- return !1 === navigator.onLine && t.type === mt._i.Ti && e.imageUrl
132
+ if (!t.Eu(i))
133
+ return !1 === navigator.onLine && t.type === pt.Fi.Ei && e.imageUrl
134
134
  ? (r.D.info(
135
135
  `Not showing ${t.type} trigger action ${t.id} due to offline state.`
136
136
  ),
137
- void this.ig.ni(t.id, InAppMessage.li.nh))
138
- : void (t.Yh(h) && this.yg(t, h, s)
137
+ void this.ig.di(t.id, InAppMessage.Ge.Th))
138
+ : void (t.yu(h) && this.yg(t, h, s)
139
139
  ? 0 === this.yt.bu()
140
140
  ? r.D.info(
141
141
  `Not displaying trigger ${t.id} because neither automaticallyShowInAppMessages() nor subscribeToInAppMessage() were called.`
@@ -144,25 +144,25 @@ export default class gr extends y {
144
144
  : r.D.info(
145
145
  `Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`
146
146
  ));
147
- t.type === mt._i.Tu
148
- ? this.ig.ni(t.id, InAppMessage.li.zi)
149
- : this.ig.ni(t.id, InAppMessage.li.rh);
147
+ t.type === pt.Fi.Nu
148
+ ? this.ig.di(t.id, InAppMessage.Ge.$i)
149
+ : this.ig.di(t.id, InAppMessage.Ge.ah);
150
150
  },
151
151
  n = () => {
152
152
  this.gg();
153
153
  const o = h.pop();
154
154
  if (null != o)
155
- if ((this.wg(o, i, s, e, h), o.pu(i))) {
155
+ if ((this.wg(o, i, s, e, h), o.Eu(i))) {
156
156
  let t = `Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;
157
157
  h.length > 0 && (t += " Continuing to fall back."),
158
158
  r.D.info(t),
159
- this.ig.ni(o.id, InAppMessage.li.rh),
159
+ this.ig.di(o.id, InAppMessage.Ge.ah),
160
160
  n();
161
161
  } else {
162
162
  r.D.info(
163
163
  `Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`
164
164
  );
165
- const n = 1e3 * o.$h - (new Date().valueOf() - i);
165
+ const n = 1e3 * o.Zh - (new Date().valueOf() - i);
166
166
  n > 0
167
167
  ? this.eg.push(
168
168
  setTimeout(() => {
@@ -173,38 +173,38 @@ export default class gr extends y {
173
173
  }
174
174
  };
175
175
  switch (t.type) {
176
- case mt._i.Ti:
176
+ case pt.Fi.Ei:
177
177
  const h = lt(t.data);
178
178
  if (null == h) {
179
179
  r.D.error(
180
180
  `Could not parse trigger data for trigger ${t.id}, ignoring.`
181
181
  ),
182
- this.ig.ni(t.id, InAppMessage.li.ki);
182
+ this.ig.di(t.id, InAppMessage.Ge.Gi);
183
183
  break;
184
184
  }
185
- let a = this.ig.vi(h);
185
+ let a = this.ig.zi(h);
186
186
  if (a) {
187
187
  r.D.error(a), n();
188
188
  break;
189
189
  }
190
190
  o(h);
191
191
  break;
192
- case mt._i.Tu:
193
- const l = wt.fromJson(t.data, o, n, i, t.$i);
192
+ case pt.Fi.Nu:
193
+ const l = wt.fromJson(t.data, o, n, i, t.xi);
194
194
  if (null == l) {
195
195
  r.D.error(
196
196
  `Could not parse trigger data for trigger ${t.id}, ignoring.`
197
197
  ),
198
- this.ig.ni(t.id, InAppMessage.li.ki);
198
+ this.ig.di(t.id, InAppMessage.Ge.Gi);
199
199
  break;
200
200
  }
201
- this.ig.Ii(l, s, e);
201
+ this.ig.ki(l, s, e);
202
202
  break;
203
203
  default:
204
204
  r.D.error(
205
205
  `Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`
206
206
  ),
207
- this.ig.ni(t.id, InAppMessage.li.ki);
207
+ this.ig.di(t.id, InAppMessage.Ge.Gi);
208
208
  }
209
209
  }
210
210
  je(t, i, s) {
@@ -224,15 +224,15 @@ export default class gr extends y {
224
224
  const a = [];
225
225
  for (let s = 0; s < this.cg.length; s++) {
226
226
  const r = this.cg[s],
227
- h = e + 1e3 * r.$h;
227
+ h = e + 1e3 * r.Zh;
228
228
  if (
229
- r.Yh(h) &&
229
+ r.yu(h) &&
230
230
  (null == r.startTime || r.startTime <= e) &&
231
231
  (null == r.endTime || r.endTime >= e)
232
232
  ) {
233
233
  let s = !1;
234
- for (let e = 0; e < r.Ph.length; e++)
235
- if (r.Ph[e].ec(t, i)) {
234
+ for (let e = 0; e < r.$h.length; e++)
235
+ if (r.$h[e].ec(t, i)) {
236
236
  s = !0;
237
237
  break;
238
238
  }
@@ -255,12 +255,12 @@ export default class gr extends y {
255
255
  `Firing ${l.type} trigger action ${l.id} from trigger event ${t}.`
256
256
  ),
257
257
  this.wg(l, e, t, s, a),
258
- 0 === l.$h
258
+ 0 === l.Zh
259
259
  ? this.ug(l, e, t, s, a)
260
260
  : this.eg.push(
261
261
  setTimeout(() => {
262
262
  this.ug(l, e, t, s, a);
263
- }, 1e3 * l.$h)
263
+ }, 1e3 * l.Zh)
264
264
  ));
265
265
  }
266
266
  changeUser(t) {
@@ -284,21 +284,21 @@ export default class gr extends y {
284
284
  ),
285
285
  !0
286
286
  );
287
- let e = t.Kh;
287
+ let e = t.Du;
288
288
  return null == e && (e = this.tg), i - this.hg >= 1e3 * e;
289
289
  }
290
290
  wg(t, i, s, e, r) {
291
291
  this.gg(), (this.og[t.id] = this.og[t.id] || []);
292
292
  const h = {};
293
293
  let n;
294
- (h.Si = i), (h.dg = s), null != e && (n = e.ss()), (h.mg = n);
294
+ (h.qi = i), (h.dg = s), null != e && (n = e.ss()), (h.mg = n);
295
295
  const a = [];
296
296
  for (let t = 0; t < r.length; t++) a.push(r[t].id);
297
297
  (h.pg = a), this.og[t.id].push(h), this.h.B(o.q.va, this.og);
298
298
  }
299
299
  vg(t, i) {
300
300
  this.gg(),
301
- t.Zh(i),
301
+ t.ju(i),
302
302
  (this.hg = i),
303
303
  this.h.B(o.q.Na, i),
304
304
  (this.ng[t.id] = i),
@@ -1,7 +1,7 @@
1
1
  import e, { OPTIONS as T } 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-${"4.5.1".replace(/\./g, "-")}`,
4
+ s = `ab-${t}-css-definitions-${"4.6.0".replace(/\./g, "-")}`,
5
5
  a = c.ownerDocument || document;
6
6
  if (null == a.getElementById(s)) {
7
7
  const n = a.createElement("style");
@@ -1,6 +1,6 @@
1
1
  import e, { OPTIONS as T } from "../../managers/braze-instance.js";
2
2
  export function loadFontAwesome() {
3
- if (e.nn(T.Oo)) return;
3
+ if (e.nn(T.vo)) return;
4
4
  const t = "https://use.fontawesome.com/7f85a56ba4.css";
5
5
  if (
6
6
  !(null !== document.querySelector('link[rel=stylesheet][href="' + t + '"]'))
@@ -24,14 +24,14 @@ export const BRAZE_ACTIONS = {
24
24
  properties: { type: "type", me: "steps", fe: "args" }
25
25
  };
26
26
  export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES = {
27
- yi: "unknownBrazeAction",
28
- bi: "noPushPrompt"
27
+ Di: "unknownBrazeAction",
28
+ _i: "noPushPrompt"
29
29
  };
30
30
  export const ineligibleBrazeActionURLErrorMessage = (t, o) => {
31
31
  switch (t) {
32
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.yi:
32
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Di:
33
33
  return `${o} contains an unknown braze action type and will not be displayed.`;
34
- case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.bi:
34
+ case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES._i:
35
35
  return `${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;
36
36
  default:
37
37
  return "";
@@ -16,12 +16,12 @@ class si {
16
16
  navigator.systemLanguage ||
17
17
  ""
18
18
  ).toLowerCase()),
19
- (this.Wo = si.Bg(this.userAgent));
19
+ (this.Fo = si.Bg(this.userAgent));
20
20
  }
21
21
  Og() {
22
22
  return this.browser !== ri.Pg || this.version > 8;
23
23
  }
24
- Ja() {
24
+ ka() {
25
25
  return this.browser === ri.kg;
26
26
  }
27
27
  Xo() {
@@ -16,22 +16,22 @@ export function _isInView(t, n, e, s) {
16
16
  !s)
17
17
  );
18
18
  }
19
- export const DOMUtils = { wu: null, eo: _isInView };
20
- export const DIRECTIONS = { He: "up", Je: "down", ot: "left", et: "right" };
19
+ export const DOMUtils = { vu: null, eo: _isInView };
20
+ export const DIRECTIONS = { We: "up", Xe: "down", ot: "left", et: "right" };
21
21
  export function supportsPassive() {
22
- if (null == DOMUtils.wu) {
23
- DOMUtils.wu = !1;
22
+ if (null == DOMUtils.vu) {
23
+ DOMUtils.vu = !1;
24
24
  try {
25
25
  const t = Object.defineProperty({}, "passive", {
26
26
  get: () => {
27
- DOMUtils.wu = !0;
27
+ DOMUtils.vu = !0;
28
28
  }
29
29
  });
30
30
  window.addEventListener("testPassive", null, t),
31
31
  window.removeEventListener("testPassive", null, t);
32
32
  } catch (t) {}
33
33
  }
34
- return DOMUtils.wu;
34
+ return DOMUtils.vu;
35
35
  }
36
36
  export function addPassiveEventListener(t, n, e) {
37
37
  t.addEventListener(n, e, !!supportsPassive() && { passive: !0 });
@@ -65,9 +65,9 @@ export function detectSwipe(t, n, e) {
65
65
  (i = null))
66
66
  : Math.abs(u) >= 25 &&
67
67
  (((u > 0 &&
68
- n === DIRECTIONS.He &&
68
+ n === DIRECTIONS.We &&
69
69
  t.scrollTop === t.scrollHeight - t.offsetHeight) ||
70
- (u < 0 && n === DIRECTIONS.Je && 0 === t.scrollTop)) &&
70
+ (u < 0 && n === DIRECTIONS.Xe && 0 === t.scrollTop)) &&
71
71
  e(o),
72
72
  (s = null),
73
73
  (i = null));
@@ -1 +1 @@
1
- export const KeyCodes = { fo: 32, oo: 9, co: 13, Vi: 27 };
1
+ export const KeyCodes = { fo: 32, oo: 9, co: 13, ih: 27 };
package/src/util/net.js CHANGED
@@ -13,7 +13,7 @@ const b = {
13
13
  ) {
14
14
  const r = () => {
15
15
  "function" == typeof t.error && t.error(e.status),
16
- "function" == typeof t.Pl && t.Pl(!1);
16
+ "function" == typeof t.Ue && t.Ue(!1);
17
17
  };
18
18
  (e.onload = () => {
19
19
  let o = !1;
@@ -28,14 +28,14 @@ const b = {
28
28
  (r = e.getAllResponseHeaders());
29
29
  } catch (o) {
30
30
  const n = {
31
- error: "" === e.responseText ? qt.fa : qt.ma,
31
+ error: "" === e.responseText ? qt.ma : qt.pa,
32
32
  response: e.responseText
33
33
  };
34
34
  t.S(n, r);
35
35
  }
36
36
  o && t.S(o, r);
37
37
  }
38
- "function" == typeof t.Pl && t.Pl(!0);
38
+ "function" == typeof t.Ue && t.Ue(!0);
39
39
  } else r();
40
40
  }),
41
41
  (e.onerror = () => {
@@ -31,5 +31,5 @@ export const WindowUtils = {
31
31
  openUri: _openUri,
32
32
  so: _isPhone,
33
33
  io: _getOrientation,
34
- gn: _getCurrentUrl
34
+ yn: _getCurrentUrl
35
35
  };