@braze/web-sdk 4.8.0 → 4.8.1

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 (72) hide show
  1. package/index.d.ts +6 -3
  2. package/package.json +1 -1
  3. package/shared-lib/braze-shared-lib.js +1 -1
  4. package/shared-lib/encoding-utils.js +1 -1
  5. package/shared-lib/event-types.js +11 -11
  6. package/shared-lib/indexed-db-adapter.js +67 -67
  7. package/shared-lib/logger.js +7 -7
  8. package/src/Card/card-manager.js +1 -1
  9. package/src/ContentCards/ui/show-content-cards.js +1 -1
  10. package/src/Core/disable-sdk.js +5 -4
  11. package/src/Core/enable-sdk.js +1 -1
  12. package/src/Core/is-disabled.js +1 -1
  13. package/src/FeatureFlags/feature-flags-provider.js +12 -12
  14. package/src/Feed/ui/show-feed.js +1 -1
  15. package/src/InAppMessage/in-app-message-manager.js +40 -34
  16. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  17. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  18. package/src/InAppMessage/log-in-app-message-html-click.js +1 -1
  19. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  20. package/src/InAppMessage/models/in-app-message.js +13 -13
  21. package/src/InAppMessage/models/slide-up-message.js +2 -2
  22. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  23. package/src/InAppMessage/ui/show-in-app-message.js +2 -2
  24. package/src/Push/push-manager.js +82 -81
  25. package/src/Push/utils/push-utils.js +4 -4
  26. package/src/User/user-manager.js +4 -4
  27. package/src/User/user.js +5 -5
  28. package/src/common/feed-display.js +82 -72
  29. package/src/l10n/l10n-manager-factory.js +7 -7
  30. package/src/managers/auth-manager.js +18 -15
  31. package/src/managers/braze-instance.js +125 -109
  32. package/src/managers/device-manager.js +40 -35
  33. package/src/managers/network-manager.js +90 -81
  34. package/src/managers/server-config-manager.js +36 -34
  35. package/src/managers/session-manager.js +44 -37
  36. package/src/managers/storage-manager-factory.js +23 -16
  37. package/src/managers/storage-manager.js +251 -239
  38. package/src/managers/subscription-manager.js +10 -7
  39. package/src/managers/types.js +1 -0
  40. package/src/models/backend-errors.js +5 -5
  41. package/src/models/braze-event.js +10 -4
  42. package/src/models/device.js +10 -18
  43. package/src/models/identifier.js +10 -11
  44. package/src/models/push-token.js +14 -9
  45. package/src/models/request-result.js +2 -2
  46. package/src/models/server-config.js +32 -16
  47. package/src/models/types.js +1 -0
  48. package/src/request-controller.js +109 -109
  49. package/src/triggers/models/custom-event-data.js +6 -6
  50. package/src/triggers/models/custom-event-property-data.js +9 -9
  51. package/src/triggers/models/filter-set.js +9 -9
  52. package/src/triggers/models/filter.js +60 -60
  53. package/src/triggers/models/in-app-message-click-data.js +9 -9
  54. package/src/triggers/models/purchase-data.js +3 -3
  55. package/src/triggers/models/purchase-property-data.js +7 -7
  56. package/src/triggers/models/push-click-data.js +6 -6
  57. package/src/triggers/models/trigger-condition.js +46 -46
  58. package/src/triggers/models/trigger-events.js +1 -1
  59. package/src/triggers/models/trigger.js +27 -27
  60. package/src/triggers/triggers-provider.js +126 -126
  61. package/src/ui/js/attach-css.js +1 -1
  62. package/src/util/base-device-parser.js +2 -2
  63. package/src/util/braze-actions.js +4 -4
  64. package/src/util/browser-detector.js +18 -18
  65. package/src/util/client-hints-parser.js +6 -6
  66. package/src/util/device-constants.js +6 -6
  67. package/src/util/dom-utils.js +5 -5
  68. package/src/util/error-utils.js +2 -0
  69. package/src/util/net.js +1 -1
  70. package/src/util/request-header-utils.js +9 -9
  71. package/src/util/user-agent-parser.js +21 -21
  72. package/src/util/window-utils.js +1 -1
@@ -86,11 +86,11 @@ export default class aa {
86
86
  a
87
87
  );
88
88
  }
89
- l = this.Gi(e);
89
+ l = this.Pi(e);
90
90
  }
91
91
  return null == l ? a : (null != n && (l.bid = n), s.N(i, l));
92
92
  }
93
- Oi(e, i) {
93
+ Gi(e, i) {
94
94
  const n = new t();
95
95
  if (!e.p())
96
96
  return (
@@ -99,10 +99,10 @@ export default class aa {
99
99
  ),
100
100
  n
101
101
  );
102
- const o = this.Gi(i);
102
+ const o = this.Pi(i);
103
103
  return null == o
104
104
  ? n
105
- : e.id === InAppMessageButton.Pi
105
+ : e.id === InAppMessageButton.Oi
106
106
  ? (r.j.info(
107
107
  "This in-app message button does not have a tracking id. Not logging event to Braze servers."
108
108
  ),
@@ -110,17 +110,23 @@ export default class aa {
110
110
  : (null != e.id && (o.bid = e.id), s.N(r.q.Mi, o));
111
111
  }
112
112
  Hi(t) {
113
+ const s = t.messageFields;
114
+ return (null != s && s.is_push_primer) || !1;
115
+ }
116
+ Ji(t) {
113
117
  if (!(t instanceof InAppMessage)) return;
114
118
  const s = t => {
115
- if (!t) return;
116
- const s = Q(t);
117
- return ft(s)
118
- ? dt(vt.Ji, "In-App Message")
119
- : gt(s) && !yt.Ki()
120
- ? dt(vt.Li, "In-App Message")
121
- : void 0;
122
- },
123
- e = t.buttons || [];
119
+ if (!t) return;
120
+ const s = Q(t);
121
+ return ft(s)
122
+ ? dt(vt.Ki, "In-App Message")
123
+ : gt(s) && !yt.Li()
124
+ ? dt(vt.Qi, "In-App Message")
125
+ : void 0;
126
+ };
127
+ if (this.Hi(t) && !yt.Li())
128
+ return "In-App Message contains a push prompt, but is not eligible for a push prompt. Ignoring.";
129
+ const e = t.buttons || [];
124
130
  let i;
125
131
  for (const t of e)
126
132
  if (
@@ -136,16 +142,16 @@ export default class aa {
136
142
  ? s(t.uri)
137
143
  : void 0;
138
144
  }
139
- Qi(t, s, e, i) {
145
+ Vi(t, s, e, i) {
140
146
  if (!this.gt) return;
141
- const n = this.gt.Vi(!1, !1),
147
+ const n = this.gt.Wi(!1, !1),
142
148
  o = this.gt.Gs(n);
143
149
  (o.template = { trigger_id: t.triggerId, trigger_event_type: s }),
144
- null != e && (o.template.data = e.Wi());
145
- const a = this.gt.Ks(o, T.Qs.Xi);
150
+ null != e && (o.template.data = e.Xi());
151
+ const a = this.gt.Ks(o, T.Qs.Yi);
146
152
  this.gt.Vs(o, () => {
147
153
  this.gt &&
148
- (T.Xs(this.u, T.Qs.Xi, new Date().valueOf()),
154
+ (T.Xs(this.u, T.Qs.Yi, new Date().valueOf()),
149
155
  C.Ys({
150
156
  url: `${this.gt.Zs()}/template/`,
151
157
  data: o,
@@ -153,35 +159,35 @@ export default class aa {
153
159
  O: s => {
154
160
  if (!this.gt.ti(o, s, a))
155
161
  return (
156
- this.Ye(t.triggerId, InAppMessage.Me.Yi),
157
- void ("function" == typeof t.Zi && t.Zi())
162
+ this.Ye(t.triggerId, InAppMessage.Me.Zi),
163
+ void ("function" == typeof t.Mr && t.Mr())
158
164
  );
159
165
  if ((this.gt.si(), null == s || null == s.templated_message))
160
- return void this.Ye(t.triggerId, InAppMessage.Me.Yi);
166
+ return void this.Ye(t.triggerId, InAppMessage.Me.Zi);
161
167
  const e = s.templated_message;
162
- if (e.type !== mt._r.Mr)
163
- return void this.Ye(t.triggerId, InAppMessage.Me.Gr);
168
+ if (e.type !== mt.Gr._r)
169
+ return void this.Ye(t.triggerId, InAppMessage.Me.Or);
164
170
  const i = pt(e.data);
165
- if (null == i) return void this.Ye(t.triggerId, InAppMessage.Me.Gr);
166
- const n = this.Hi(i);
171
+ if (null == i) return void this.Ye(t.triggerId, InAppMessage.Me.Or);
172
+ const n = this.Ji(i);
167
173
  if (n)
168
- return r.j.error(n), void ("function" == typeof t.Zi && t.Zi());
169
- "function" == typeof t.Or
170
- ? t.Or(i)
171
- : this.Ye(t.triggerId, InAppMessage.Me.Yi);
174
+ return r.j.error(n), void ("function" == typeof t.Mr && t.Mr());
175
+ "function" == typeof t.Hr
176
+ ? t.Hr(i)
177
+ : this.Ye(t.triggerId, InAppMessage.Me.Zi);
172
178
  },
173
179
  error: r => {
174
180
  let n = `getting user personalization for message ${t.triggerId}`;
175
- if (new Date().valueOf() - t.Hr > t.Jr)
176
- this.Ye(t.triggerId, InAppMessage.Me.Yi);
181
+ if (new Date().valueOf() - t.Jr > t.Kr)
182
+ this.Ye(t.triggerId, InAppMessage.Me.Zi);
177
183
  else {
178
- const r = Math.min(t.Jr, this.Re),
184
+ const r = Math.min(t.Kr, this.Re),
179
185
  o = this.Oe;
180
186
  null == i && (i = o);
181
187
  const a = Math.min(r, D(o, 3 * i));
182
188
  (n += `. Retrying in ${a} ms`),
183
189
  setTimeout(() => {
184
- this.Qi(t, s, e, a);
190
+ this.Vi(t, s, e, a);
185
191
  }, a);
186
192
  }
187
193
  this.gt.ii(r, n);
@@ -189,7 +195,7 @@ export default class aa {
189
195
  }));
190
196
  });
191
197
  }
192
- Gi(t) {
198
+ Pi(t) {
193
199
  if (null == t.triggerId)
194
200
  return (
195
201
  r.j.info(
@@ -11,9 +11,9 @@ export function logInAppMessageButtonClick(t, o) {
11
11
  if (!(t instanceof InAppMessageButton))
12
12
  return r.j.error("button must be an InAppMessageButton object"), !1;
13
13
  if (!(o instanceof InAppMessage)) return r.j.error(or), !1;
14
- const s = ea.m().Oi(t, o);
14
+ const s = ea.m().Gi(t, o);
15
15
  if (s.O)
16
16
  for (let r = 0; r < s.ve.length; r++)
17
- et.er().je(tt.Kr, [o.triggerId, t.id], s.ve[r]);
17
+ et.er().je(tt.Lr, [o.triggerId, t.id], s.ve[r]);
18
18
  return s.O;
19
19
  }
@@ -11,9 +11,9 @@ export function logInAppMessageClick(o) {
11
11
  if (!(o instanceof InAppMessage)) return r.j.error(or), !1;
12
12
  const s = ea.m().N(o, r.q.Ii);
13
13
  if (s) {
14
- o.Lr() || logInAppMessageImpression(o);
14
+ o.Qr() || logInAppMessageImpression(o);
15
15
  for (let r = 0; r < s.ve.length; r++)
16
- et.er().je(tt.Kr, [o.triggerId], s.ve[r]);
16
+ et.er().je(tt.Lr, [o.triggerId], s.ve[r]);
17
17
  }
18
18
  return s.O;
19
19
  }
@@ -18,6 +18,6 @@ export function logInAppMessageHtmlClick(s, t, o) {
18
18
  const i = ea.m().N(s, m, t, o);
19
19
  if (i.O)
20
20
  for (let r = 0; r < i.ve.length; r++)
21
- et.er().je(tt.Kr, [s.triggerId, t], i.ve[r]);
21
+ et.er().je(tt.Lr, [s.triggerId, t], i.ve[r]);
22
22
  return i.O;
23
23
  }
@@ -10,12 +10,12 @@ export default class InAppMessageButton {
10
10
  (this.uri = e),
11
11
  (this.id = n),
12
12
  (this.text = s || ""),
13
- (this.backgroundColor = t || InAppMessage.Ur.Qr),
14
- (this.textColor = i || InAppMessage.Ur.Vr),
13
+ (this.backgroundColor = t || InAppMessage.Vr.Ur),
14
+ (this.textColor = i || InAppMessage.Vr.Wr),
15
15
  (this.borderColor = r || this.backgroundColor),
16
16
  (this.clickAction = h || InAppMessage.ClickAction.NONE),
17
17
  (this.uri = e),
18
- null == n && (n = InAppMessageButton.Pi),
18
+ null == n && (n = InAppMessageButton.Oi),
19
19
  (this.id = n),
20
20
  (this.vo = !1),
21
21
  (this.ht = new E());
@@ -44,4 +44,4 @@ export default class InAppMessageButton {
44
44
  );
45
45
  }
46
46
  }
47
- InAppMessageButton.Pi = -1;
47
+ InAppMessageButton.Oi = -1;
@@ -81,19 +81,19 @@ export default class InAppMessage {
81
81
  (this.icon = T),
82
82
  (this.imageUrl = a),
83
83
  (this.imageStyle = m || InAppMessage.ImageStyle.TOP),
84
- (this.iconColor = c || InAppMessage.Ur.Vr),
85
- (this.iconBackgroundColor = I || InAppMessage.Ur.Qr),
86
- (this.backgroundColor = L || InAppMessage.Ur.Vr),
87
- (this.textColor = A || InAppMessage.Ur.th),
88
- (this.closeButtonColor = N || InAppMessage.Ur.sh),
84
+ (this.iconColor = c || InAppMessage.Vr.Wr),
85
+ (this.iconBackgroundColor = I || InAppMessage.Vr.Ur),
86
+ (this.backgroundColor = L || InAppMessage.Vr.Wr),
87
+ (this.textColor = A || InAppMessage.Vr.th),
88
+ (this.closeButtonColor = N || InAppMessage.Vr.sh),
89
89
  (this.animateIn = d),
90
90
  null == this.animateIn && (this.animateIn = !0),
91
91
  (this.animateOut = _),
92
92
  null == this.animateOut && (this.animateOut = !0),
93
93
  (this.header = O),
94
94
  (this.headerAlignment = S || InAppMessage.TextAlignment.CENTER),
95
- (this.headerTextColor = D || InAppMessage.Ur.th),
96
- (this.frameColor = M || InAppMessage.Ur.ih),
95
+ (this.headerTextColor = D || InAppMessage.Vr.th),
96
+ (this.frameColor = M || InAppMessage.Vr.ih),
97
97
  (this.buttons = R || []),
98
98
  (this.cropType = b || InAppMessage.CropType.FIT_CENTER),
99
99
  (this.orientation = p),
@@ -143,7 +143,7 @@ export default class InAppMessage {
143
143
  M() {
144
144
  return !this.eh && ((this.eh = !0), !0);
145
145
  }
146
- Lr() {
146
+ Qr() {
147
147
  return this.eh;
148
148
  }
149
149
  p(t) {
@@ -257,10 +257,10 @@ export default class InAppMessage {
257
257
  (this.hh = !0));
258
258
  }
259
259
  }
260
- (InAppMessage.Ur = {
260
+ (InAppMessage.Vr = {
261
261
  th: 4281545523,
262
- Vr: 4294967295,
263
- Qr: 4278219733,
262
+ Wr: 4294967295,
263
+ Ur: 4278219733,
264
264
  dh: 4293914607,
265
265
  _h: 4283782485,
266
266
  ih: 3224580915,
@@ -271,8 +271,8 @@ export default class InAppMessage {
271
271
  ze: "ias",
272
272
  Sh: "of",
273
273
  Dh: "do",
274
- Gr: "umt",
275
- Yi: "tf",
274
+ Or: "umt",
275
+ Zi: "tf",
276
276
  Mh: "te"
277
277
  }),
278
278
  (InAppMessage.SlideFrom = { TOP: "TOP", BOTTOM: "BOTTOM" }),
@@ -2,8 +2,8 @@ import InAppMessage from "./in-app-message.js";
2
2
  import { DOMUtils as so } from "../../util/dom-utils.js";
3
3
  export default class SlideUpMessage extends InAppMessage {
4
4
  constructor(o, s, t, e, i, d, n, r, a, p, u, m, c, v, l, x, h, f, g, I, M) {
5
- (x = x || InAppMessage.Ur._h),
6
- (l = l || InAppMessage.Ur.dh),
5
+ (x = x || InAppMessage.Vr._h),
6
+ (l = l || InAppMessage.Vr.dh),
7
7
  super(
8
8
  o,
9
9
  (s = s || InAppMessage.TextAlignment.START),
@@ -1,15 +1,15 @@
1
1
  export default class wt {
2
2
  constructor(t, s, i, h, l) {
3
3
  (this.triggerId = t),
4
- (this.Or = s),
5
- (this.Zi = i),
6
- (this.Hr = h),
7
- (this.Jr = l),
4
+ (this.Hr = s),
5
+ (this.Mr = i),
6
+ (this.Jr = h),
7
+ (this.Kr = l),
8
8
  (this.triggerId = t),
9
- (this.Or = s),
10
- (this.Zi = i),
11
- (this.Hr = h),
12
- (this.Jr = l);
9
+ (this.Hr = s),
10
+ (this.Mr = i),
11
+ (this.Jr = h),
12
+ (this.Kr = l);
13
13
  }
14
14
  static fromJson(t, s, i, h, l) {
15
15
  return null == t || null == t.trigger_id
@@ -98,7 +98,7 @@ export function showInAppMessage(s, t, o) {
98
98
  (a.className += se(s)),
99
99
  a.setAttribute("role", "complementary"),
100
100
  s.$e() && (a.id = s.htmlId),
101
- e.nn(L.mo) && (a.style.zIndex = e.nn(L.mo) + 1),
101
+ e.nn(L.mo) && (a.style.zIndex = (e.nn(L.mo) + 1).toString()),
102
102
  t.appendChild(a),
103
103
  s.ye())
104
104
  ) {
@@ -122,7 +122,7 @@ export function showInAppMessage(s, t, o) {
122
122
  if (
123
123
  ((o.className = "ab-page-blocker"),
124
124
  s.ye() || (o.style.backgroundColor = me(s.frameColor)),
125
- e.nn(L.mo) && (o.style.zIndex = e.nn(L.mo)),
125
+ e.nn(L.mo) && (o.style.zIndex = e.nn(L.mo).toString()),
126
126
  a.appendChild(o),
127
127
  !e.nn(L.Lh))
128
128
  ) {