@braze/web-sdk 6.7.1 → 6.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 (97) hide show
  1. package/index.d.ts +74 -27
  2. package/package.json +1 -1
  3. package/shared-lib/encoding-utils.js +2 -2
  4. package/shared-lib/event-types.js +13 -13
  5. package/shared-lib/indexed-db-adapter.js +3 -3
  6. package/shared-lib/logger.js +2 -2
  7. package/shared-lib/supported-options.js +8 -8
  8. package/src/Banner/log-banner-impressions.js +20 -11
  9. package/src/ContentCards/content-cards-provider-factory.js +13 -11
  10. package/src/ContentCards/content-cards-provider.js +4 -4
  11. package/src/ContentCards/get-cached-content-cards.js +2 -2
  12. package/src/ContentCards/request-content-cards-refresh.js +2 -2
  13. package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
  14. package/src/ContentCards/ui/show-content-cards.js +3 -3
  15. package/src/Core/change-user.js +2 -2
  16. package/src/Core/index.js +1 -0
  17. package/src/Core/log-ecommerce-event.js +29 -0
  18. package/src/Core/log-purchase.js +17 -192
  19. package/src/Core/open-session.js +6 -6
  20. package/src/Core/set-sdk-authentication-signature.js +1 -1
  21. package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
  22. package/src/DUST/dust-connection-core.js +1 -0
  23. package/src/DUST/dust-provider-factory.js +10 -10
  24. package/src/DUST/dust-provider.js +181 -158
  25. package/src/DUST/dust-shared-worker-code.js +1 -1
  26. package/src/DUST/dust-shared-worker-impl.js +93 -100
  27. package/src/DUST/dust-worker-bridge.js +27 -27
  28. package/src/DUST/subscribe-to-dust.js +7 -7
  29. package/src/InAppMessage/defer-in-app-message.js +1 -1
  30. package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
  31. package/src/InAppMessage/display/modal-utils.js +2 -2
  32. package/src/InAppMessage/in-app-message-manager.js +64 -64
  33. package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
  34. package/src/InAppMessage/log-in-app-message-click.js +1 -1
  35. package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
  36. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  37. package/src/InAppMessage/models/full-screen-message.js +7 -7
  38. package/src/InAppMessage/models/html-message.js +1 -1
  39. package/src/InAppMessage/models/in-app-message-button.js +4 -4
  40. package/src/InAppMessage/models/in-app-message.js +22 -22
  41. package/src/InAppMessage/models/modal-message.js +5 -5
  42. package/src/InAppMessage/models/slide-up-message.js +6 -6
  43. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  44. package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
  45. package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
  46. package/src/InAppMessage/ui/show-in-app-message.js +20 -20
  47. package/src/Push/push-manager-factory.js +2 -2
  48. package/src/Push/push-manager.js +8 -8
  49. package/src/Push/utils/push-utils.js +6 -6
  50. package/src/User/user-manager.js +5 -5
  51. package/src/User/user.js +8 -8
  52. package/src/common/constants.js +1 -0
  53. package/src/common/content-cards-display.js +2 -2
  54. package/src/l10n/l10n-manager-factory.js +1 -1
  55. package/src/l10n/l10n-manager.js +1 -1
  56. package/src/managers/braze-instance.js +21 -21
  57. package/src/managers/device-manager.js +6 -6
  58. package/src/managers/network-manager.js +93 -92
  59. package/src/managers/server-config-manager.js +68 -68
  60. package/src/managers/session-manager.js +2 -2
  61. package/src/managers/storage-manager-factory.js +4 -4
  62. package/src/managers/storage-manager.js +120 -120
  63. package/src/managers/subscription-manager.js +1 -1
  64. package/src/managers/utils.js +1 -1
  65. package/src/models/backend-errors.js +5 -5
  66. package/src/models/braze-event.js +3 -3
  67. package/src/models/device.js +1 -1
  68. package/src/models/identifier.js +3 -3
  69. package/src/models/push-token.js +5 -5
  70. package/src/models/server-config.js +27 -27
  71. package/src/request-controller.js +99 -99
  72. package/src/triggers/models/custom-event-data.js +4 -4
  73. package/src/triggers/models/custom-event-property-data.js +5 -5
  74. package/src/triggers/models/filter-set.js +2 -2
  75. package/src/triggers/models/filter.js +1 -1
  76. package/src/triggers/models/in-app-message-click-data.js +5 -5
  77. package/src/triggers/models/purchase-data.js +1 -1
  78. package/src/triggers/models/purchase-property-data.js +2 -2
  79. package/src/triggers/models/push-click-data.js +5 -5
  80. package/src/triggers/models/trigger-condition.js +42 -42
  81. package/src/triggers/models/trigger-events.js +2 -2
  82. package/src/triggers/models/trigger.js +10 -10
  83. package/src/triggers/triggers-provider-factory.js +1 -1
  84. package/src/triggers/triggers-provider.js +30 -30
  85. package/src/types.js +5 -1
  86. package/src/ui/js/attach-css.js +1 -1
  87. package/src/util/braze-actions.js +5 -5
  88. package/src/util/browser-detector.js +13 -13
  89. package/src/util/client-hints-parser.js +2 -2
  90. package/src/util/dom-utils.js +2 -2
  91. package/src/util/ecommerce-event-validation.js +326 -0
  92. package/src/util/iso-4217-currency-codes.js +176 -0
  93. package/src/util/net.js +3 -3
  94. package/src/util/request-header-utils.js +18 -18
  95. package/src/util/user-agent-parser.js +14 -14
  96. package/src/util/validation-utils.js +2 -2
  97. package/src/util/window-utils.js +2 -2
@@ -5,7 +5,7 @@ import {
5
5
  convertSecondsToMs as Xe,
6
6
  } from "../util/date-utils.js";
7
7
  import v from "../common/event-logger.js";
8
- import { isArray as g, isEqual as ni } from "../util/code-utils.js";
8
+ import { isArray as g, isEqual as oi } from "../util/code-utils.js";
9
9
  import { logger as E, EventTypes as p } from "../../shared-lib/index.js";
10
10
  import { STORAGE_KEYS as s } from "./storage-manager.js";
11
11
  import h from "../util/request-header-utils.js";
@@ -29,7 +29,7 @@ export default class Vt {
29
29
  (this.Kh = u),
30
30
  (this.appVersion = l),
31
31
  (this.Ra = c),
32
- (this.$a = (t) => (null == t ? "" : `${t} `)),
32
+ (this.Xa = (t) => (null == t ? "" : `${t} `)),
33
33
  (this.eu = t),
34
34
  (this.C = e),
35
35
  (this.Gh = i),
@@ -42,21 +42,21 @@ export default class Vt {
42
42
  (this.Kh = u),
43
43
  (this.appVersion = l),
44
44
  (this.Ra = c),
45
- (this.Xa = ["npm"]),
46
- (this.La = {});
45
+ (this.$a = ["npm"]),
46
+ (this.Pa = {});
47
47
  }
48
48
  Z(t, e = !1, i = !1) {
49
49
  const r = this.eu.ve(!i),
50
- n = r.ta(),
51
- o = this.C.Rt(s.Tt.Ba);
52
- ni(o, n) || (t.device = n),
50
+ n = r.oa(),
51
+ o = this.C.Rt(s.Tt.Ka);
52
+ oi(o, n) || (t.device = n),
53
53
  (t.api_key = this.tu),
54
54
  (t.time = X(new Date().valueOf(), !0));
55
- const a = this.C.Rt(s.Tt.Ka) || [],
56
- h = this.C.Rt(s.Tt.Pa) || "";
57
- this.Xa.length > 0 &&
58
- (!ni(a, this.Xa) || h !== this.j.kt()) &&
59
- (t.sdk_metadata = this.Xa),
55
+ const a = this.C.Rt(s.Tt.Ua) || [],
56
+ h = this.C.Rt(s.Tt.Wa) || "";
57
+ this.$a.length > 0 &&
58
+ (!oi(a, this.$a) || h !== this.j.kt()) &&
59
+ (t.sdk_metadata = this.$a),
60
60
  (t.sdk_version = this.Vh),
61
61
  this.Kh && (t.sdk_flavor = this.Kh),
62
62
  (t.app_version = this.appVersion),
@@ -91,7 +91,7 @@ export default class Vt {
91
91
  (e +=
92
92
  ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
93
93
  E.error(`SDK Authentication failed ${e}`),
94
- this.Ua(t.events || [], t.attributes || []),
94
+ this.Ya(t.events || [], t.attributes || []),
95
95
  this.Gh.Ch(r),
96
96
  !1
97
97
  );
@@ -100,42 +100,42 @@ export default class Vt {
100
100
  let i,
101
101
  s = r;
102
102
  switch (s) {
103
- case Ne.Wa:
103
+ case Ne.Qa:
104
104
  return (
105
105
  (i = "Received successful response with empty body."),
106
- v.wt(p.Ya, { e: i }),
106
+ v.wt(p.Va, { e: i }),
107
107
  E.info(i),
108
108
  !1
109
109
  );
110
- case Ne.Qa:
110
+ case Ne.Za:
111
111
  return (
112
112
  (i = "Received successful response with invalid JSON"),
113
- v.wt(p.Ya, { e: i + ": " + e.response }),
113
+ v.wt(p.Va, { e: i + ": " + e.response }),
114
114
  E.info(i),
115
115
  !1
116
116
  );
117
- case Ne.Va:
117
+ case Ne.dl:
118
118
  s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Yh}`;
119
119
  break;
120
- case Ne.Za:
120
+ case Ne.fl:
121
121
  s =
122
122
  "Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
123
123
  break;
124
- case Ne.dl:
124
+ case Ne.ml:
125
125
  s = "No device identifier. Please contact support@braze.com";
126
126
  }
127
127
  E.error("Backend error: " + s);
128
128
  }
129
129
  return !1;
130
130
  }
131
- fl(t, e, i) {
131
+ vl(t, e, i) {
132
132
  return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i);
133
133
  }
134
- ml(t, e, i, s = !1) {
134
+ Rl(t, e, i, s = !1) {
135
135
  const r = [],
136
136
  n = (t) => t || "",
137
137
  o = n(this.Ss.getUserId());
138
- let a = this.Zo(t);
138
+ let a = this.ia(t);
139
139
  const u = [],
140
140
  l = [];
141
141
  let c,
@@ -143,7 +143,7 @@ export default class Vt {
143
143
  if (e.length > 0) {
144
144
  const t = [];
145
145
  for (const i of e) {
146
- if (((c = i.ta()), this.Gh.Fh())) {
146
+ if (((c = i.oa()), this.Gh.Fh())) {
147
147
  if (o && !c.user_id) {
148
148
  d || (d = {}), d.events || (d.events = []), d.events.push(c);
149
149
  continue;
@@ -163,16 +163,16 @@ export default class Vt {
163
163
  e && (this.Gh.Fh() && n(e.user_id) !== o ? u.push(e) : t.push(e));
164
164
  t.length > 0 && (a.attributes = t);
165
165
  }
166
- if ((this.Ua(l, u), (a = this.Z(a, !1, s)), d)) {
166
+ if ((this.Ya(l, u), (a = this.Z(a, !1, s)), d)) {
167
167
  d = this.Z(d, !1, s);
168
- const t = { requestData: d, headers: this.tt(d, h.it.pn) };
168
+ const t = { requestData: d, headers: this.tt(d, h.it.wn) };
169
169
  r.push(t);
170
170
  }
171
- if (a && !this.fl(a.events, a.attributes, t)) return d ? r : null;
172
- const f = { requestData: a, headers: this.tt(a, h.it.pn) };
171
+ if (a && !this.vl(a.events, a.attributes, t)) return d ? r : null;
172
+ const f = { requestData: a, headers: this.tt(a, h.it.wn) };
173
173
  return r.push(f), r;
174
174
  }
175
- Ua(t, e) {
175
+ Ya(t, e) {
176
176
  if (t) {
177
177
  const e = [];
178
178
  for (const i of t) {
@@ -181,16 +181,16 @@ export default class Vt {
181
181
  }
182
182
  this.C.ol(e);
183
183
  }
184
- if (e) for (const t of e) this.C.vl(t);
184
+ if (e) for (const t of e) this.C.gl(t);
185
185
  }
186
186
  dt(t, e) {
187
187
  let i = "HTTP error ";
188
188
  null != t && (i += t + " "), (i += e), E.error(i);
189
189
  }
190
- Rl(t) {
191
- return v.wt(p.gl, { n: t });
190
+ bl(t) {
191
+ return v.wt(p.ql, { n: t });
192
192
  }
193
- Zo(t, e) {
193
+ ia(t, e) {
194
194
  const i = {};
195
195
  t && (i.triggers = !0);
196
196
  const s = null != e ? e : this.Ss.getUserId();
@@ -200,20 +200,20 @@ export default class Vt {
200
200
  }
201
201
  return (i.config = { config_time: this.h.Ot() }), { respond_with: i };
202
202
  }
203
- bl(t) {
203
+ Al(t) {
204
204
  const e = new Date().valueOf();
205
205
  let i = Ke.toString();
206
- const s = h.ql(this.C, t);
206
+ const s = h.Dl(this.C, t);
207
207
  if (-1 !== s) {
208
208
  i = (e - s).toString();
209
209
  }
210
210
  return i;
211
211
  }
212
- tt(t, e, i = !1) {
212
+ tt(t, e, i = "sdk") {
213
213
  const s = [["X-Braze-Api-Key", this.tu]],
214
- r = this.bl(e);
214
+ r = this.Al(e);
215
215
  s.push(["X-Braze-Last-Req-Ms-Ago", r]);
216
- const n = h.Al(this.C, e).toString();
216
+ const n = h.kl(this.C, e).toString();
217
217
  s.push(["X-Braze-Req-Attempt", n]);
218
218
  let o = !1;
219
219
  if (
@@ -223,8 +223,8 @@ export default class Vt {
223
223
  e === h.it.Ji)
224
224
  ) {
225
225
  s.push(["X-Braze-ContentCardsRequest", "true"]);
226
- let t = h.Al(this.C, h.it.Ji);
227
- (t && !i) || ((t = 1), h.Dl(this.C, h.it.Ji, t));
226
+ let t = h.kl(this.C, h.it.Ji);
227
+ (t && "client" !== i) || ((t = 1), h.yl(this.C, h.it.Ji, t));
228
228
  const e = Math.max(0, t - 1);
229
229
  s.push(["BRAZE-SYNC-RETRY-COUNT", e.toString()]), (o = !0);
230
230
  }
@@ -232,6 +232,7 @@ export default class Vt {
232
232
  (e === h.it.Co &&
233
233
  (s.push(["X-Braze-FeatureFlagsRequest", "true"]), (o = !0)),
234
234
  o && s.push(["X-Braze-DataRequest", "true"]),
235
+ "dust" === i && s.push(["X-Braze-Request-Initiated-By", "di"]),
235
236
  this.Gh.Fh())
236
237
  ) {
237
238
  const t = this.Gh.kh();
@@ -240,47 +241,47 @@ export default class Vt {
240
241
  return s;
241
242
  }
242
243
  Tl(t, e, i, s) {
243
- if (this.La[s]) return;
244
+ if (this.Pa[s]) return;
244
245
  const r = window.setTimeout(() => {
245
- E.info(`Retrying rate limited ${this.$a(s)}SDK request.`),
246
+ E.info(`Retrying rate limited ${this.Xa(s)}SDK request.`),
246
247
  this.et(e, i, s);
247
248
  }, t);
248
- this.La[s] = r;
249
+ this.Pa[s] = r;
249
250
  }
250
251
  fo() {
251
- for (const t in this.La) {
252
- const e = this.La[t];
252
+ for (const t in this.Pa) {
253
+ const e = this.Pa[t];
253
254
  window.clearTimeout(e);
254
255
  }
255
- this.La = {};
256
+ this.Pa = {};
256
257
  }
257
258
  et(t, e, i, r) {
258
- if (!this.kl(i))
259
+ if (!this.wl(i))
259
260
  return (
260
- E.info(`${this.$a(i)}SDK request being rate limited.`),
261
+ E.info(`${this.Xa(i)}SDK request being rate limited.`),
261
262
  void ("function" == typeof r && r())
262
263
  );
263
- const n = this.yl();
264
- if (!n.wl)
264
+ const n = this.Nl();
265
+ if (!n.Bl)
265
266
  return (
266
- this.Tl(n.Nl, t, e, i),
267
+ this.Tl(n.Cl, t, e, i),
267
268
  void E.info(
268
- `${this.$a(
269
+ `${this.Xa(
269
270
  i,
270
271
  )}SDK request being rate limited. Request will be retried in ${Math.trunc(
271
- n.Nl / 1e3,
272
+ n.Cl / 1e3,
272
273
  )} seconds.`,
273
274
  )
274
275
  );
275
- this.C.It(s.Tt.Cl, new Date().valueOf());
276
+ this.C.It(s.Tt.Sl, new Date().valueOf());
276
277
  const o = t.device;
277
278
  o && o.os_version instanceof Promise
278
279
  ? o.os_version.then((i) => {
279
- (t.device.os_version = i), e(n.Sl);
280
+ (t.device.os_version = i), e(n.zl);
280
281
  })
281
- : e(n.Sl);
282
+ : e(n.zl);
282
283
  }
283
- Bl(t) {
284
+ jl(t) {
284
285
  const e = t ? Oe(t) : null;
285
286
  if (!e || !e["retry-after"]) return null;
286
287
  const i = e["retry-after"];
@@ -291,21 +292,21 @@ export default class Vt {
291
292
  {
292
293
  const t =
293
294
  "Received unexpected value for retry-after header in /sync response";
294
- v.wt(p.Ya, { e: t + ": " + i });
295
+ v.wt(p.Va, { e: t + ": " + i });
295
296
  }
296
297
  return null;
297
298
  }
298
299
  yt(t, e, i, s, r, n) {
299
- if (h.Al(this.C, i) >= Pe) return;
300
+ if (h.kl(this.C, i) >= Pe) return;
300
301
  let o;
301
302
  n = n || 0;
302
- const a = this.Bl(t);
303
+ const a = this.jl(t);
303
304
  r();
304
305
  const u = (t) => {
305
306
  const r = window.setTimeout(() => {
306
307
  e();
307
308
  }, t);
308
- s(r), h.zl(this.C, i);
309
+ s(r), h.Ml(this.C, i);
309
310
  };
310
311
  if (a && !isNaN(a.value)) {
311
312
  switch (a.type) {
@@ -318,44 +319,44 @@ export default class Vt {
318
319
  u(o);
319
320
  } else n ? u(n) : h.Li(this.C, i);
320
321
  }
321
- jl(t) {
322
+ Xl(t) {
322
323
  var e;
323
- null === (e = this.C) || void 0 === e || e.It(s.Tt.Ml, t);
324
+ null === (e = this.C) || void 0 === e || e.It(s.Tt.$l, t);
324
325
  }
325
- $l(t, e) {
326
- let i = this.Xl();
327
- null == i && (i = {}), (i[t] = e), this.C.It(s.Tt.Ll, i);
326
+ Ll(t, e) {
327
+ let i = this.El();
328
+ null == i && (i = {}), (i[t] = e), this.C.It(s.Tt.Fl, i);
328
329
  }
329
- El() {
330
+ Il() {
330
331
  var t;
331
- return null === (t = this.C) || void 0 === t ? void 0 : t.Rt(s.Tt.Ml);
332
+ return null === (t = this.C) || void 0 === t ? void 0 : t.Rt(s.Tt.$l);
332
333
  }
333
- Xl() {
334
+ El() {
334
335
  var t;
335
- return null === (t = this.C) || void 0 === t ? void 0 : t.Rt(s.Tt.Ll);
336
+ return null === (t = this.C) || void 0 === t ? void 0 : t.Rt(s.Tt.Fl);
336
337
  }
337
- Fl(t, e, i, s, r = "") {
338
+ Kl(t, e, i, s, r = "") {
338
339
  let n;
339
340
  if (r) {
340
- const t = this.Xl();
341
+ const t = this.El();
341
342
  n = null == t || isNaN(t[r]) ? e : t[r];
342
- } else (n = this.El()), (null == n || isNaN(n)) && (n = e);
343
+ } else (n = this.Il()), (null == n || isNaN(n)) && (n = e);
343
344
  const o = (t - s) / 1e3;
344
345
  return (n = Math.min(n + o / i, e)), n;
345
346
  }
346
- Kl(t, e) {
347
+ Pl(t, e) {
347
348
  return Math.max(0, (1 - t) * e * 1e3);
348
349
  }
349
- Il(t, e = "") {
350
+ Ul(t, e = "") {
350
351
  var i, r, n, o, a;
351
- const u = { wl: !0, Sl: -1, Nl: 0 };
352
+ const u = { Bl: !0, zl: -1, Cl: 0 };
352
353
  if ((null == t && (t = !0), !t && !e)) return u;
353
354
  let l,
354
355
  c,
355
356
  d = null;
356
- if (t) d = null === (i = this.C) || void 0 === i ? void 0 : i.Rt(s.Tt.Cl);
357
+ if (t) d = null === (i = this.C) || void 0 === i ? void 0 : i.Rt(s.Tt.Sl);
357
358
  else {
358
- const t = h.Pl(this.C);
359
+ const t = h.xl(this.C);
359
360
  if (null == t || null == t[e]) return u;
360
361
  d = t[e];
361
362
  }
@@ -363,30 +364,30 @@ export default class Vt {
363
364
  if (
364
365
  (t
365
366
  ? ((l =
366
- (null === (r = this.h) || void 0 === r ? void 0 : r.Ul()) || -1),
367
- (c = (null === (n = this.h) || void 0 === n ? void 0 : n.xl()) || -1))
367
+ (null === (r = this.h) || void 0 === r ? void 0 : r.Hl()) || -1),
368
+ (c = (null === (n = this.h) || void 0 === n ? void 0 : n.Ol()) || -1))
368
369
  : ((l =
369
- (null === (o = this.h) || void 0 === o ? void 0 : o.Hl(e)) || -1),
370
+ (null === (o = this.h) || void 0 === o ? void 0 : o.Gl(e)) || -1),
370
371
  (c =
371
- (null === (a = this.h) || void 0 === a ? void 0 : a.Ol(e)) || -1)),
372
+ (null === (a = this.h) || void 0 === a ? void 0 : a._l(e)) || -1)),
372
373
  -1 === l || -1 === c)
373
374
  )
374
375
  return u;
375
376
  const f = new Date().valueOf();
376
- let m = this.Fl(f, l, c, d, e);
377
+ let m = this.Kl(f, l, c, d, e);
377
378
  return m < 1
378
- ? ((u.wl = !1), (u.Nl = this.Kl(m, c)), u)
379
+ ? ((u.Bl = !1), (u.Cl = this.Pl(m, c)), u)
379
380
  : ((m = Math.trunc(m) - 1),
380
- (u.Sl = m),
381
- t ? this.jl(m) : this.$l(e, m),
381
+ (u.zl = m),
382
+ t ? this.Xl(m) : this.Ll(e, m),
382
383
  u);
383
384
  }
384
- yl() {
385
- return this.Il(!0);
385
+ Nl() {
386
+ return this.Ul(!0);
386
387
  }
387
- kl(t) {
388
- const e = this.Il(!1, t);
389
- return !(e && !e.wl);
388
+ wl(t) {
389
+ const e = this.Ul(!1, t);
390
+ return !(e && !e.Bl);
390
391
  }
391
392
  ct() {
392
393
  this.Gh.ct();
@@ -395,6 +396,6 @@ export default class Vt {
395
396
  return this.Yh;
396
397
  }
397
398
  addSdkMetadata(t) {
398
- for (const e of t) -1 === this.Xa.indexOf(e) && this.Xa.push(e);
399
+ for (const e of t) -1 === this.$a.indexOf(e) && this.$a.push(e);
399
400
  }
400
401
  }
@@ -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 ci from "../models/server-config.js";
3
+ import di 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 {
@@ -13,31 +13,31 @@ export default class Yt {
13
13
  constructor(t) {
14
14
  (this.C = t),
15
15
  (this.C = t),
16
- (this.Gl = new f()),
17
- (this._l = new f()),
18
16
  (this.Vl = new f()),
19
17
  (this.Jl = new f()),
20
18
  (this.Ql = new f()),
21
- (this.Wl = null),
22
- (this.Yl = null);
23
- }
24
- Zl() {
25
- if (null == this.Yl) {
26
- const t = this.C.Rt(s.Tt.tc);
27
- this.Yl = null != t ? ci._u(t) : new ci();
19
+ (this.Wl = new f()),
20
+ (this.Yl = new f()),
21
+ (this.Zl = null),
22
+ (this.tc = null);
23
+ }
24
+ ec() {
25
+ if (null == this.tc) {
26
+ const t = this.C.Rt(s.Tt.sc);
27
+ this.tc = null != t ? di._u(t) : new di();
28
28
  }
29
- return this.Yl;
29
+ return this.tc;
30
30
  }
31
31
  Ot() {
32
- return this.Zl().ec;
32
+ return this.ec().nc;
33
33
  }
34
- sc(t) {
34
+ rc(t) {
35
35
  var i, e, n, r;
36
36
  if (null != t && null != t.config) {
37
37
  const l = t.config;
38
- if (l.time > this.Zl().ec) {
39
- const t = (t) => (null == t ? this.Zl().nc : t),
40
- u = new ci(
38
+ if (l.time > this.ec().nc) {
39
+ const t = (t) => (null == t ? this.ec().lc : t),
40
+ u = new di(
41
41
  l.time,
42
42
  l.events_blacklist,
43
43
  l.attributes_blacklist,
@@ -53,9 +53,9 @@ export default class Yt {
53
53
  l.minimum_session_timeout,
54
54
  );
55
55
  let o = !1;
56
- null != u.rc && this.ju() !== u.rc && (o = !0);
56
+ null != u.uc && this.ju() !== u.uc && (o = !0);
57
57
  let a = !1;
58
- null != u.lc.enabled && this.Bi() !== u.lc.enabled && (a = !0);
58
+ null != u.oc.enabled && this.Bi() !== u.oc.enabled && (a = !0);
59
59
  let h = !1;
60
60
  null != u.Xr.enabled && this.lo() !== u.Xr.enabled && (h = !0);
61
61
  let c = !1;
@@ -66,100 +66,100 @@ export default class Yt {
66
66
  (c = !0);
67
67
  let d = !1;
68
68
  null != (null === (n = u.dust) || void 0 === n ? void 0 : n.enabled) &&
69
- this.fn() !==
69
+ this.vn() !==
70
70
  (null === (r = u.dust) || void 0 === r ? void 0 : r.enabled) &&
71
71
  (d = !0),
72
- (this.Yl = u),
73
- this.C.It(s.Tt.tc, u.qt()),
74
- o && this.Gl.A(),
75
- a && this._l.A(),
76
- h && this.Vl.A(),
77
- c && this.Jl.A(),
78
- d && this.Ql.A();
72
+ (this.tc = u),
73
+ this.C.It(s.Tt.sc, u.qt()),
74
+ o && this.Vl.A(),
75
+ a && this.Jl.A(),
76
+ h && this.Ql.A(),
77
+ c && this.Wl.A(),
78
+ d && this.Yl.A();
79
79
  }
80
80
  }
81
81
  }
82
82
  xu(t) {
83
- const i = this.Gl.Kt(t);
84
- return this.Wl && this.Gl.removeSubscription(this.Wl), (this.Wl = i), i;
83
+ const i = this.Vl.Kt(t);
84
+ return this.Zl && this.Vl.removeSubscription(this.Zl), (this.Zl = i), i;
85
85
  }
86
86
  Mi(t) {
87
- return this._l.Kt(t);
87
+ return this.Jl.Kt(t);
88
88
  }
89
89
  bo(t) {
90
- return this.Vl.Kt(t);
90
+ return this.Ql.Kt(t);
91
91
  }
92
92
  V(t) {
93
- return this.Jl.Kt(t);
93
+ return this.Wl.Kt(t);
94
94
  }
95
95
  Tr(t) {
96
- return this.Ql.Kt(t);
96
+ return this.Yl.Kt(t);
97
97
  }
98
98
  $e(t) {
99
- return -1 !== this.Zl().uc.indexOf(t);
99
+ return -1 !== this.ec().ac.indexOf(t);
100
100
  }
101
101
  qu(t) {
102
- return -1 !== this.Zl().oc.indexOf(t);
102
+ return -1 !== this.ec().hc.indexOf(t);
103
103
  }
104
- Dr(t) {
105
- return -1 !== this.Zl().ac.indexOf(t);
104
+ $r(t) {
105
+ return -1 !== this.ec().cc.indexOf(t);
106
106
  }
107
- hc() {
108
- return this.Zl().cc;
107
+ dc() {
108
+ return this.ec().mc;
109
109
  }
110
110
  ju() {
111
- return this.Zl().rc;
111
+ return this.ec().uc;
112
112
  }
113
113
  Bi() {
114
- return this.Zl().lc.enabled || !1;
114
+ return this.ec().oc.enabled || !1;
115
115
  }
116
- dc() {
117
- const t = this.Zl().nc;
116
+ vc() {
117
+ const t = this.ec().lc;
118
118
  return !(!t || null == t.enabled) && t.enabled;
119
119
  }
120
- Ul() {
121
- if (!this.dc()) return -1;
122
- const t = this.Zl().nc;
120
+ Hl() {
121
+ if (!this.vc()) return -1;
122
+ const t = this.ec().lc;
123
123
  return null == t.capacity || t.capacity < 10 ? -1 : t.capacity;
124
124
  }
125
- xl() {
126
- if (!this.dc()) return -1;
127
- const t = this.Zl().nc;
125
+ Ol() {
126
+ if (!this.vc()) return -1;
127
+ const t = this.ec().lc;
128
128
  return null == t.refill_rate || t.refill_rate <= 0 ? -1 : t.refill_rate;
129
129
  }
130
- mc(t) {
131
- const i = this.Zl().nc.endpoint_overrides;
130
+ gc(t) {
131
+ const i = this.ec().lc.endpoint_overrides;
132
132
  return null == i ? null : i[t];
133
133
  }
134
- Hl(t) {
135
- const i = this.mc(t);
134
+ Gl(t) {
135
+ const i = this.gc(t);
136
136
  return null == i || isNaN(i.capacity) || i.capacity <= 0 ? -1 : i.capacity;
137
137
  }
138
- Ol(t) {
139
- const i = this.mc(t);
138
+ _l(t) {
139
+ const i = this.gc(t);
140
140
  return null == i || isNaN(i.refill_rate) || i.refill_rate <= 0
141
141
  ? -1
142
142
  : i.refill_rate;
143
143
  }
144
144
  lo() {
145
- return this.Zl().Xr.enabled && null == this.Ro()
146
- ? (v.wt(p.Ya, { e: "Missing feature flag refresh_rate_limit." }), !1)
147
- : this.Zl().Xr.enabled || !1;
145
+ return this.ec().Xr.enabled && null == this.Ro()
146
+ ? (v.wt(p.Va, { e: "Missing feature flag refresh_rate_limit." }), !1)
147
+ : this.ec().Xr.enabled || !1;
148
148
  }
149
149
  Ro() {
150
- return this.Zl().Xr.refresh_rate_limit;
150
+ return this.ec().Xr.refresh_rate_limit;
151
151
  }
152
152
  Jt() {
153
153
  var t;
154
154
  return (
155
- (null === (t = this.Zl().banners) || void 0 === t ? void 0 : t.enabled) ||
155
+ (null === (t = this.ec().banners) || void 0 === t ? void 0 : t.enabled) ||
156
156
  null
157
157
  );
158
158
  }
159
159
  re() {
160
160
  var t;
161
161
  return (
162
- (null === (t = this.Zl().banners) || void 0 === t
162
+ (null === (t = this.ec().banners) || void 0 === t
163
163
  ? void 0
164
164
  : t.max_placements) || 0
165
165
  );
@@ -167,21 +167,21 @@ export default class Yt {
167
167
  Xt() {
168
168
  var t;
169
169
  const i =
170
- null === (t = this.Zl().banners) || void 0 === t
170
+ null === (t = this.ec().banners) || void 0 === t
171
171
  ? void 0
172
172
  : t.dismissals_cache_size;
173
173
  return null != i && "number" == typeof i && i > 0 ? i : u;
174
174
  }
175
- fn() {
175
+ vn() {
176
176
  var t;
177
177
  return (
178
- (null === (t = this.Zl().dust) || void 0 === t ? void 0 : t.enabled) || !1
178
+ (null === (t = this.ec().dust) || void 0 === t ? void 0 : t.enabled) || !1
179
179
  );
180
180
  }
181
181
  vt() {
182
182
  var t;
183
183
  const i =
184
- null === (t = this.Zl().vc) || void 0 === t
184
+ null === (t = this.ec().fc) || void 0 === t
185
185
  ? void 0
186
186
  : t.min_sleep_duration_ms;
187
187
  return null != i ? i : d;
@@ -189,18 +189,18 @@ export default class Yt {
189
189
  gt() {
190
190
  var t;
191
191
  const i =
192
- null === (t = this.Zl().vc) || void 0 === t ? void 0 : t.scale_factor;
192
+ null === (t = this.ec().fc) || void 0 === t ? void 0 : t.scale_factor;
193
193
  return null != i ? i : m;
194
194
  }
195
195
  bt() {
196
196
  var t;
197
197
  const i =
198
- null === (t = this.Zl().vc) || void 0 === t
198
+ null === (t = this.ec().fc) || void 0 === t
199
199
  ? void 0
200
200
  : t.max_sleep_duration_ms;
201
201
  return null != i ? i : c;
202
202
  }
203
- gc() {
204
- return this.Zl().fc;
203
+ bc() {
204
+ return this.ec().Rc;
205
205
  }
206
206
  }
@@ -17,7 +17,7 @@ export default class Xt {
17
17
  (this.C = s),
18
18
  (this.Ss = t),
19
19
  (this.h = i);
20
- const n = this.h.gc();
20
+ const n = this.h.bc();
21
21
  (this.im = n ? 1e3 * n : ts),
22
22
  (null == e || isNaN(e)) && (e = 1800),
23
23
  e < this.im / 1e3 &&
@@ -42,7 +42,7 @@ export default class Xt {
42
42
  }
43
43
  am() {
44
44
  const t = new Date().valueOf(),
45
- i = this.h.hc();
45
+ i = this.h.dc();
46
46
  if (null == i) return !1;
47
47
  const e = this.C.Rt(s.Tt.dm),
48
48
  n = null == e || t - e > 1e3 * i;