@braze/web-sdk 6.10.2 → 6.12.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 (109) hide show
  1. package/index.d.ts +61 -6
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +3 -3
  4. package/shared-lib/event-types.js +12 -12
  5. package/shared-lib/indexed-db-adapter.js +52 -52
  6. package/shared-lib/logger.js +7 -7
  7. package/shared-lib/supported-options.js +10 -10
  8. package/src/Core/logout.js +2 -2
  9. package/src/DUST/dust-config-store.js +89 -0
  10. package/src/DUST/dust-connection-core.js +7 -21
  11. package/src/DUST/dust-message-dedup.js +33 -0
  12. package/src/DUST/dust-provider.js +367 -397
  13. package/src/DUST/dust-tab-identity.js +30 -0
  14. package/src/DUST/index.js +7 -9
  15. package/src/DUST/subscribe-to-dust.js +5 -5
  16. package/src/FeatureFlags/feature-flag-factory.js +4 -4
  17. package/src/FeatureFlags/feature-flag.js +5 -5
  18. package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
  19. package/src/FeatureFlags/feature-flags-provider.js +74 -74
  20. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  21. package/src/FeatureFlags/get-feature-flag.js +2 -2
  22. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  23. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
  24. package/src/InAppMessage/constants.js +39 -47
  25. package/src/InAppMessage/defer-in-app-message.js +2 -2
  26. package/src/InAppMessage/display/get-animation-effect.js +1 -1
  27. package/src/InAppMessage/display/html-message-display-utils.js +4 -4
  28. package/src/InAppMessage/display/html-message-to-html.js +10 -10
  29. package/src/InAppMessage/display/in-app-message-to-html.js +68 -66
  30. package/src/InAppMessage/display/modal-utils.js +14 -14
  31. package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
  32. package/src/InAppMessage/in-app-message-factory.js +6 -6
  33. package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
  34. package/src/InAppMessage/in-app-message-manager.js +101 -80
  35. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  36. package/src/InAppMessage/log-in-app-message-click.js +2 -2
  37. package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
  38. package/src/InAppMessage/log-in-app-message-impression.js +3 -3
  39. package/src/InAppMessage/models/full-screen-message.js +25 -25
  40. package/src/InAppMessage/models/html-message.js +14 -14
  41. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  42. package/src/InAppMessage/models/in-app-message.js +100 -98
  43. package/src/InAppMessage/models/modal-message.js +23 -23
  44. package/src/InAppMessage/models/slide-up-message.js +29 -29
  45. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  46. package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
  47. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +2 -2
  48. package/src/InAppMessage/ui/show-in-app-message.js +42 -40
  49. package/src/Push/index.js +1 -0
  50. package/src/Push/is-push-blocked.js +2 -2
  51. package/src/Push/is-push-permission-granted.js +2 -2
  52. package/src/Push/is-push-supported.js +2 -2
  53. package/src/Push/push-manager-factory.js +6 -6
  54. package/src/Push/push-manager.js +228 -185
  55. package/src/Push/register-push.js +9 -0
  56. package/src/Push/unregister-push-token-on-server.js +4 -4
  57. package/src/Push/utils/push-utils.js +16 -16
  58. package/src/User/user-manager.js +19 -19
  59. package/src/User/user.js +36 -36
  60. package/src/common/constants.js +1 -1
  61. package/src/common/content-cards-display.js +21 -21
  62. package/src/common/event-logger.js +2 -2
  63. package/src/l10n/l10n-manager-factory.js +7 -7
  64. package/src/l10n/l10n-manager.js +5 -5
  65. package/src/managers/auth-manager.js +1 -1
  66. package/src/managers/braze-instance.js +70 -66
  67. package/src/managers/device-manager.js +12 -12
  68. package/src/managers/network-manager.js +118 -118
  69. package/src/managers/server-config-manager.js +84 -84
  70. package/src/managers/session-manager.js +10 -10
  71. package/src/managers/storage-manager-factory.js +4 -4
  72. package/src/managers/storage-manager.js +138 -136
  73. package/src/managers/subscription-manager.js +1 -1
  74. package/src/managers/utils.js +1 -1
  75. package/src/models/backend-errors.js +5 -5
  76. package/src/models/braze-event.js +7 -7
  77. package/src/models/device.js +2 -2
  78. package/src/models/identifier.js +6 -6
  79. package/src/models/push-token.js +6 -6
  80. package/src/models/server-config.js +31 -31
  81. package/src/request-controller.js +91 -91
  82. package/src/triggers/models/filter.js +58 -58
  83. package/src/triggers/models/in-app-message-click-data.js +4 -4
  84. package/src/triggers/models/push-click-data.js +2 -2
  85. package/src/triggers/models/trigger-condition.js +35 -35
  86. package/src/triggers/models/trigger.js +37 -37
  87. package/src/triggers/triggers-provider-factory.js +3 -3
  88. package/src/triggers/triggers-provider.js +61 -53
  89. package/src/types.js +1 -1
  90. package/src/ui/js/attach-css.js +1 -1
  91. package/src/ui/js/feed-css.js +2 -2
  92. package/src/ui/js/iam-css.js +2 -2
  93. package/src/util/base-device-parser.js +1 -1
  94. package/src/util/braze-actions.js +4 -4
  95. package/src/util/browser-detector.js +13 -13
  96. package/src/util/client-hints-parser.js +4 -4
  97. package/src/util/component-utils.js +4 -4
  98. package/src/util/dom-utils.js +5 -5
  99. package/src/util/ecommerce-event-validation.js +77 -48
  100. package/src/util/key-codes.js +1 -1
  101. package/src/util/net.js +4 -4
  102. package/src/util/request-header-utils.js +20 -20
  103. package/src/util/string-utils.js +5 -0
  104. package/src/util/user-agent-parser.js +15 -15
  105. package/src/util/validation-utils.js +9 -9
  106. package/src/util/window-utils.js +2 -2
  107. package/src/DUST/dust-shared-worker-code.js +0 -2
  108. package/src/DUST/dust-shared-worker-impl.js +0 -234
  109. package/src/DUST/dust-worker-bridge.js +0 -151
@@ -1,6 +1,6 @@
1
1
  import { STORAGE_KEYS as s } from "./storage-manager.js";
2
2
  import f from "./subscription-manager.js";
3
- import di from "../models/server-config.js";
3
+ import vi from "../models/server-config.js";
4
4
  import v from "../common/event-logger.js";
5
5
  import { EventTypes as p } from "../../shared-lib/index.js";
6
6
  import {
@@ -9,36 +9,36 @@ import {
9
9
  REQUEST_BACKOFF_MIN_SLEEP_MS_DEFAULT as d,
10
10
  REQUEST_BACKOFF_SCALE_FACTOR_DEFAULT as m,
11
11
  } from "../common/constants.js";
12
- export default class Yt {
12
+ export default class li {
13
13
  constructor(t) {
14
14
  (this.j = t),
15
15
  (this.j = t),
16
+ (this.Gl = new f()),
16
17
  (this._l = new f()),
18
+ (this.Ol = new f()),
17
19
  (this.Vl = new f()),
20
+ (this.Hl = new f()),
18
21
  (this.Jl = new f()),
19
- (this.Ql = new f()),
20
- (this.Wl = new f()),
21
- (this.Yl = new f()),
22
- (this.Zl = null),
23
- (this.ed = null);
24
- }
25
- sd() {
26
- if (null == this.ed) {
27
- const t = this.j.St(s.It.nd);
28
- this.ed = null != t ? di._u(t) : new di();
22
+ (this.Ql = null),
23
+ (this.Wl = null);
24
+ }
25
+ Yl() {
26
+ if (null == this.Wl) {
27
+ const t = this.j.St(s.It.Zl);
28
+ this.Wl = null != t ? vi._u(t) : new vi();
29
29
  }
30
- return this.ed;
30
+ return this.Wl;
31
31
  }
32
32
  Qt() {
33
- return this.sd().ld;
33
+ return this.Yl().ed;
34
34
  }
35
- ud(t) {
35
+ sd(t) {
36
36
  var i, e, n, l, r, o;
37
37
  if (null != t && null != t.config) {
38
38
  const u = t.config;
39
- if (u.time > this.sd().ld) {
40
- const t = (t) => (null == t ? this.sd().ad : t),
41
- a = new di(
39
+ if (u.time > this.Yl().ed) {
40
+ const t = (t) => (null == t ? this.Yl().nd : t),
41
+ a = new vi(
42
42
  u.time,
43
43
  u.events_blacklist,
44
44
  u.attributes_blacklist,
@@ -55,11 +55,11 @@ export default class Yt {
55
55
  u.conversational_chat,
56
56
  );
57
57
  let h = !1;
58
- null != a.hd && this.ju() !== a.hd && (h = !0);
58
+ null != a.ld && this.Wu() !== a.ld && (h = !0);
59
59
  let d = !1;
60
- null != a.dd.enabled && this.Pi() !== a.dd.enabled && (d = !0);
60
+ null != a.ud.enabled && this.Pi() !== a.ud.enabled && (d = !0);
61
61
  let c = !1;
62
- null != a.Xr.enabled && this.lo() !== a.Xr.enabled && (c = !0);
62
+ null != a.Rr.enabled && this.Kr() !== a.Rr.enabled && (c = !0);
63
63
  let v = !1;
64
64
  null !=
65
65
  (null === (i = a.banners) || void 0 === i ? void 0 : i.enabled) &&
@@ -68,109 +68,109 @@ export default class Yt {
68
68
  (v = !0);
69
69
  let m = !1;
70
70
  null != (null === (n = a.dust) || void 0 === n ? void 0 : n.enabled) &&
71
- this.fn() !==
71
+ this.$n() !==
72
72
  (null === (l = a.dust) || void 0 === l ? void 0 : l.enabled) &&
73
73
  (m = !0);
74
74
  let g = !1;
75
- null != (null === (r = a.vd) || void 0 === r ? void 0 : r.enabled) &&
76
- this.md() !==
77
- (null === (o = a.vd) || void 0 === o ? void 0 : o.enabled) &&
75
+ null != (null === (r = a.ad) || void 0 === r ? void 0 : r.enabled) &&
76
+ this.hd() !==
77
+ (null === (o = a.ad) || void 0 === o ? void 0 : o.enabled) &&
78
78
  (g = !0),
79
- (this.ed = a),
80
- this.j.Pt(s.It.nd, a.qt()),
81
- h && this._l.A(),
82
- d && this.Vl.A(),
83
- c && this.Jl.A(),
84
- v && this.Ql.A(),
85
- m && this.Wl.A(),
86
- g && this.Yl.A();
79
+ (this.Wl = a),
80
+ this.j.Pt(s.It.Zl, a.qt()),
81
+ h && this.Gl.A(),
82
+ d && this._l.A(),
83
+ c && this.Ol.A(),
84
+ v && this.Vl.A(),
85
+ m && this.Hl.A(),
86
+ g && this.Jl.A();
87
87
  }
88
88
  }
89
89
  }
90
- xu(t) {
91
- const i = this._l.Ut(t);
92
- return this.Zl && this._l.removeSubscription(this.Zl), (this.Zl = i), i;
90
+ ju(t) {
91
+ const i = this.Gl.Ut(t);
92
+ return this.Ql && this.Gl.removeSubscription(this.Ql), (this.Ql = i), i;
93
93
  }
94
94
  $i(t) {
95
- return this.Vl.Ut(t);
95
+ return this._l.Ut(t);
96
96
  }
97
- bo(t) {
98
- return this.Jl.Ut(t);
97
+ do(t) {
98
+ return this.Ol.Ut(t);
99
99
  }
100
100
  V(t) {
101
- return this.Ql.Ut(t);
101
+ return this.Vl.Ut(t);
102
102
  }
103
103
  Tr(t) {
104
- return this.Wl.Ut(t);
104
+ return this.Hl.Ut(t);
105
105
  }
106
- gd(t) {
107
- return this.Yl.Ut(t);
106
+ dd(t) {
107
+ return this.Jl.Ut(t);
108
108
  }
109
109
  $e(t) {
110
- return -1 !== this.sd().bd.indexOf(t);
110
+ return -1 !== this.Yl().vd.indexOf(t);
111
111
  }
112
- qu(t) {
113
- return -1 !== this.sd().fd.indexOf(t);
112
+ zu(t) {
113
+ return -1 !== this.Yl().md.indexOf(t);
114
114
  }
115
115
  $r(t) {
116
- return -1 !== this.sd().pd.indexOf(t);
116
+ return -1 !== this.Yl().gd.indexOf(t);
117
117
  }
118
- Rd() {
119
- return this.sd().Cd;
118
+ bd() {
119
+ return this.Yl().fd;
120
120
  }
121
- ju() {
122
- return this.sd().hd;
121
+ Wu() {
122
+ return this.Yl().ld;
123
123
  }
124
124
  Pi() {
125
- return this.sd().dd.enabled || !1;
125
+ return this.Yl().ud.enabled || !1;
126
126
  }
127
- Ed() {
128
- const t = this.sd().ad;
127
+ pd() {
128
+ const t = this.Yl().nd;
129
129
  return !(!t || null == t.enabled) && t.enabled;
130
130
  }
131
- xl() {
132
- if (!this.Ed()) return -1;
133
- const t = this.sd().ad;
131
+ Kl() {
132
+ if (!this.pd()) return -1;
133
+ const t = this.Yl().nd;
134
134
  return null == t.capacity || t.capacity < 10 ? -1 : t.capacity;
135
135
  }
136
- Hl() {
137
- if (!this.Ed()) return -1;
138
- const t = this.sd().ad;
136
+ Pl() {
137
+ if (!this.pd()) return -1;
138
+ const t = this.Yl().nd;
139
139
  return null == t.refill_rate || t.refill_rate <= 0 ? -1 : t.refill_rate;
140
140
  }
141
- wd(t) {
142
- const i = this.sd().ad.endpoint_overrides;
141
+ Rd(t) {
142
+ const i = this.Yl().nd.endpoint_overrides;
143
143
  return null == i ? null : i[t];
144
144
  }
145
- Ol(t) {
146
- const i = this.wd(t);
145
+ Ul(t) {
146
+ const i = this.Rd(t);
147
147
  return null == i || isNaN(i.capacity) || i.capacity <= 0 ? -1 : i.capacity;
148
148
  }
149
- Gl(t) {
150
- const i = this.wd(t);
149
+ xl(t) {
150
+ const i = this.Rd(t);
151
151
  return null == i || isNaN(i.refill_rate) || i.refill_rate <= 0
152
152
  ? -1
153
153
  : i.refill_rate;
154
154
  }
155
- lo() {
156
- return this.sd().Xr.enabled && null == this.Ro()
157
- ? (v.Dt(p.Qa, { e: "Missing feature flag refresh_rate_limit." }), !1)
158
- : this.sd().Xr.enabled || !1;
155
+ Kr() {
156
+ return this.Yl().Rr.enabled && null == this.Fo()
157
+ ? (v.Dt(p._a, { e: "Missing feature flag refresh_rate_limit." }), !1)
158
+ : this.Yl().Rr.enabled || !1;
159
159
  }
160
- Ro() {
161
- return this.sd().Xr.refresh_rate_limit;
160
+ Fo() {
161
+ return this.Yl().Rr.refresh_rate_limit;
162
162
  }
163
163
  Ot() {
164
164
  var t;
165
165
  return (
166
- (null === (t = this.sd().banners) || void 0 === t ? void 0 : t.enabled) ||
166
+ (null === (t = this.Yl().banners) || void 0 === t ? void 0 : t.enabled) ||
167
167
  null
168
168
  );
169
169
  }
170
170
  re() {
171
171
  var t;
172
172
  return (
173
- (null === (t = this.sd().banners) || void 0 === t
173
+ (null === (t = this.Yl().banners) || void 0 === t
174
174
  ? void 0
175
175
  : t.max_placements) || 0
176
176
  );
@@ -178,27 +178,27 @@ export default class Yt {
178
178
  Gt() {
179
179
  var t;
180
180
  const i =
181
- null === (t = this.sd().banners) || void 0 === t
181
+ null === (t = this.Yl().banners) || void 0 === t
182
182
  ? void 0
183
183
  : t.dismissals_cache_size;
184
184
  return null != i && "number" == typeof i && i > 0 ? i : u;
185
185
  }
186
- fn() {
186
+ $n() {
187
187
  var t;
188
188
  return (
189
- (null === (t = this.sd().dust) || void 0 === t ? void 0 : t.enabled) || !1
189
+ (null === (t = this.Yl().dust) || void 0 === t ? void 0 : t.enabled) || !1
190
190
  );
191
191
  }
192
- md() {
192
+ hd() {
193
193
  var t;
194
194
  return (
195
- (null === (t = this.sd().vd) || void 0 === t ? void 0 : t.enabled) || !1
195
+ (null === (t = this.Yl().ad) || void 0 === t ? void 0 : t.enabled) || !1
196
196
  );
197
197
  }
198
198
  vt() {
199
199
  var t;
200
200
  const i =
201
- null === (t = this.sd().Bd) || void 0 === t
201
+ null === (t = this.Yl().Cd) || void 0 === t
202
202
  ? void 0
203
203
  : t.min_sleep_duration_ms;
204
204
  return null != i ? i : d;
@@ -206,18 +206,18 @@ export default class Yt {
206
206
  gt() {
207
207
  var t;
208
208
  const i =
209
- null === (t = this.sd().Bd) || void 0 === t ? void 0 : t.scale_factor;
209
+ null === (t = this.Yl().Cd) || void 0 === t ? void 0 : t.scale_factor;
210
210
  return null != i ? i : m;
211
211
  }
212
212
  bt() {
213
213
  var t;
214
214
  const i =
215
- null === (t = this.sd().Bd) || void 0 === t
215
+ null === (t = this.Yl().Cd) || void 0 === t
216
216
  ? void 0
217
217
  : t.max_sleep_duration_ms;
218
218
  return null != i ? i : c;
219
219
  }
220
- Td() {
221
- return this.sd().yd;
220
+ Ed() {
221
+ return this.Yl().wd;
222
222
  }
223
223
  }
@@ -1,5 +1,5 @@
1
1
  import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
2
- import Ie from "../models/braze-event.js";
2
+ import ve from "../models/braze-event.js";
3
3
  import _t from "../models/identifier.js";
4
4
  import { convertMsToSeconds as X } from "../util/date-utils.js";
5
5
  import {
@@ -8,7 +8,7 @@ import {
8
8
  EventTypes as p,
9
9
  } from "../../shared-lib/index.js";
10
10
  import { DEFAULT_MINIMUM_SESSION_TIMEOUT_IN_MS as ts } from "./constants.js";
11
- export default class Xt {
11
+ export default class fi {
12
12
  constructor(s, t, i, e) {
13
13
  (this.j = s),
14
14
  (this.Ss = t),
@@ -17,7 +17,7 @@ export default class Xt {
17
17
  (this.j = s),
18
18
  (this.Ss = t),
19
19
  (this.h = i);
20
- const n = this.h.Td();
20
+ const n = this.h.Ed();
21
21
  (this.im = n ? 1e3 * n : ts),
22
22
  (null == e || isNaN(e)) && (e = 1800),
23
23
  e < this.im / 1e3 &&
@@ -31,18 +31,18 @@ export default class Xt {
31
31
  (this.tm = Math.max(e, this.im / 1e3));
32
32
  }
33
33
  nm(s, t) {
34
- return new Ie(this.Ss.getUserId(), p.hm, s, t.Tu, { d: X(s - t.lm) });
34
+ return new ve(this.Ss.getUserId(), p.hm, s, t.Iu, { d: X(s - t.lm) });
35
35
  }
36
36
  al() {
37
37
  return this.j.$u(s.Ou.um);
38
38
  }
39
39
  $t() {
40
40
  const t = this.j.$u(s.Ou.um);
41
- return null == t ? null : t.Tu;
41
+ return null == t ? null : t.Iu;
42
42
  }
43
43
  am() {
44
44
  const t = new Date().valueOf(),
45
- i = this.h.Rd();
45
+ i = this.h.bd();
46
46
  if (null == i) return !1;
47
47
  const e = this.j.St(s.It.dm),
48
48
  n = null == e || t - e > 1e3 * i;
@@ -65,11 +65,11 @@ export default class Xt {
65
65
  }
66
66
  (n += ". Will expire " + i.valueOf()), b.info(n);
67
67
  const r = new _t(V.de(), i);
68
- this.j.gm(new Ie(this.Ss.getUserId(), p.wm, t, r.Tu)),
69
- this.j.Iu(s.Ou.um, r);
70
- return null == this.j.St(s.It.dm) && this.j.Pt(s.It.dm, t), r.Tu;
68
+ this.j.gm(new ve(this.Ss.getUserId(), p.wm, t, r.Iu)),
69
+ this.j.Ju(s.Ou.um, r);
70
+ return null == this.j.St(s.It.dm) && this.j.Pt(s.It.dm, t), r.Iu;
71
71
  }
72
- if (null != e) return (e.pm = t), (e.fm = i), this.j.Iu(s.Ou.um, e), e.Tu;
72
+ if (null != e) return (e.pm = t), (e.fm = i), this.j.Ju(s.Ou.um, e), e.Iu;
73
73
  }
74
74
  Sm() {
75
75
  const t = this.j.$u(s.Ou.um);
@@ -1,9 +1,9 @@
1
1
  import ne, { STORAGE_KEYS as s } from "./storage-manager.js";
2
2
  import { logger as b } from "../../shared-lib/index.js";
3
- const Zt = {
3
+ const di = {
4
4
  rl: function (o, t = !1, e) {
5
- const r = Zt.oc(),
6
- a = Zt.sl(),
5
+ const r = di.oc(),
6
+ a = di.sl(),
7
7
  n = new ne.tc(o, r && !t, a, e);
8
8
  let c;
9
9
  return (c = a ? new ne.ec(o) : new ne.rc()), new ne(n, c);
@@ -44,4 +44,4 @@ const Zt = {
44
44
  return o;
45
45
  },
46
46
  };
47
- export default Zt;
47
+ export default di;