@braze/web-sdk 5.2.0 → 5.3.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 (90) hide show
  1. package/index.d.ts +54 -5
  2. package/package.json +1 -1
  3. package/shared-lib/event-types.js +14 -14
  4. package/shared-lib/indexed-db-adapter.js +51 -51
  5. package/shared-lib/logger.js +7 -7
  6. package/shared-lib/supported-options.js +7 -7
  7. package/src/ContentCards/content-cards-provider.js +107 -135
  8. package/src/ContentCards/get-cached-content-cards.js +1 -1
  9. package/src/ContentCards/request-content-cards-refresh.js +1 -1
  10. package/src/ContentCards/subscribe-to-content-cards-updates.js +2 -2
  11. package/src/ContentCards/ui/show-content-cards.js +1 -1
  12. package/src/FeatureFlags/feature-flag.js +41 -30
  13. package/src/FeatureFlags/feature-flags-provider.js +88 -84
  14. package/src/FeatureFlags/get-all-feature-flags.js +2 -2
  15. package/src/FeatureFlags/get-feature-flag.js +2 -2
  16. package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
  17. package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
  18. package/src/Feed/feed-provider.js +24 -24
  19. package/src/Feed/get-cached-feed.js +1 -1
  20. package/src/Feed/log-feed-displayed.js +1 -1
  21. package/src/Feed/request-feed-refresh.js +1 -1
  22. package/src/Feed/subscribe-to-feed-updates.js +1 -1
  23. package/src/Feed/ui/show-feed.js +1 -1
  24. package/src/InAppMessage/defer-in-app-message.js +1 -1
  25. package/src/InAppMessage/display/html-message-to-html.js +9 -9
  26. package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
  27. package/src/InAppMessage/display/modal-utils.js +5 -5
  28. package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
  29. package/src/InAppMessage/in-app-message-factory.js +4 -4
  30. package/src/InAppMessage/in-app-message-manager.js +78 -75
  31. package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
  32. package/src/InAppMessage/log-in-app-message-click.js +3 -3
  33. package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
  34. package/src/InAppMessage/log-in-app-message-impression.js +1 -1
  35. package/src/InAppMessage/models/full-screen-message.js +12 -12
  36. package/src/InAppMessage/models/html-message.js +9 -9
  37. package/src/InAppMessage/models/in-app-message-button.js +2 -2
  38. package/src/InAppMessage/models/in-app-message.js +84 -82
  39. package/src/InAppMessage/models/modal-message.js +12 -12
  40. package/src/InAppMessage/models/slide-up-message.js +17 -17
  41. package/src/InAppMessage/models/templated-in-app-message.js +8 -8
  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 +17 -17
  45. package/src/Push/push-manager-factory.js +6 -6
  46. package/src/Push/push-manager.js +2 -2
  47. package/src/Push/utils/push-utils.js +1 -1
  48. package/src/User/user.js +12 -12
  49. package/src/common/base-provider.js +1 -1
  50. package/src/common/constants.js +0 -2
  51. package/src/common/event-logger.js +2 -2
  52. package/src/common/feed-display.js +1 -1
  53. package/src/managers/auth-manager.js +3 -3
  54. package/src/managers/braze-instance.js +73 -73
  55. package/src/managers/device-manager.js +15 -15
  56. package/src/managers/network-manager.js +190 -145
  57. package/src/managers/server-config-manager.js +43 -47
  58. package/src/managers/session-manager.js +21 -21
  59. package/src/managers/storage-manager-factory.js +1 -1
  60. package/src/managers/storage-manager.js +107 -107
  61. package/src/managers/utils.js +1 -1
  62. package/src/models/backend-errors.js +5 -5
  63. package/src/models/braze-event.js +6 -6
  64. package/src/models/device.js +2 -2
  65. package/src/models/identifier.js +8 -8
  66. package/src/models/server-config.js +25 -25
  67. package/src/request-controller.js +115 -108
  68. package/src/triggers/models/custom-event-data.js +2 -2
  69. package/src/triggers/models/custom-event-property-data.js +4 -4
  70. package/src/triggers/models/filter-set.js +3 -3
  71. package/src/triggers/models/filter.js +55 -55
  72. package/src/triggers/models/in-app-message-click-data.js +8 -8
  73. package/src/triggers/models/purchase-data.js +2 -2
  74. package/src/triggers/models/purchase-property-data.js +4 -4
  75. package/src/triggers/models/push-click-data.js +3 -3
  76. package/src/triggers/models/trigger-condition.js +40 -40
  77. package/src/triggers/models/trigger-events.js +1 -1
  78. package/src/triggers/models/trigger.js +31 -31
  79. package/src/triggers/triggers-provider-factory.js +1 -1
  80. package/src/triggers/triggers-provider.js +40 -40
  81. package/src/ui/js/attach-css.js +2 -2
  82. package/src/util/base-device-parser.js +7 -7
  83. package/src/util/braze-actions.js +4 -4
  84. package/src/util/browser-detector.js +23 -23
  85. package/src/util/client-hints-parser.js +4 -4
  86. package/src/util/dom-utils.js +6 -6
  87. package/src/util/net.js +4 -4
  88. package/src/util/request-header-utils.js +36 -37
  89. package/src/util/user-agent-parser.js +7 -7
  90. package/src/util/window-utils.js +1 -1
@@ -8,91 +8,91 @@ import s from "../common/event-logger.js";
8
8
  import { isArray as j, isEqual as ii } from "../util/code-utils.js";
9
9
  import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
10
10
  import { STORAGE_KEYS as o } from "./storage-manager.js";
11
- import S from "../util/request-header-utils.js";
11
+ import D from "../util/request-header-utils.js";
12
12
  import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Kt } from "../common/constants.js";
13
- import { getAlias as Ht } from "./utils.js";
13
+ import { getAlias as Gt } from "./utils.js";
14
14
  export default class Rt {
15
- constructor(t, e, s, i, r, n, o, h, a, u, l, c) {
15
+ constructor(t, e, i, s, r, n, o, h, a, u, l, c) {
16
16
  (this.on = t),
17
17
  (this.u = e),
18
- (this.Go = s),
19
- (this.wt = i),
20
- (this.di = r),
18
+ (this.zo = i),
19
+ (this.wt = s),
20
+ (this.ri = r),
21
21
  (this.yt = n),
22
22
  (this.rn = o),
23
- (this.Ko = h),
23
+ (this.Go = h),
24
24
  (this.Wo = a),
25
25
  (this.Vo = u),
26
26
  (this.appVersion = l),
27
27
  (this.Xh = c),
28
- (this.Hh = (t) => (null == t ? "" : `${t} `)),
28
+ (this.$h = (t) => (null == t ? "" : `${t} `)),
29
29
  (this.on = t),
30
30
  (this.u = e),
31
- (this.Go = s),
32
- (this.wt = i),
33
- (this.di = r),
31
+ (this.zo = i),
32
+ (this.wt = s),
33
+ (this.ri = r),
34
34
  (this.yt = n),
35
35
  (this.rn = o),
36
- (this.Ko = h),
36
+ (this.Go = h),
37
37
  (this.Wo = a),
38
38
  (this.Vo = u),
39
39
  (this.appVersion = l),
40
40
  (this.Xh = c),
41
- (this.Yh = ["npm"]);
41
+ (this.Hh = ["npm"]);
42
42
  }
43
- Ps(t, e = !1, s = !1) {
44
- const i = this.on.ce(!s),
45
- r = i.Mr(),
46
- n = this.u.j(o.C.Ga);
43
+ Js(t, e = !1, i = !1) {
44
+ const s = this.on.ce(!i),
45
+ r = s.Ir(),
46
+ n = this.u.j(o.C.Ca);
47
47
  ii(n, r) || (t.device = r),
48
48
  (t.api_key = this.rn),
49
49
  (t.time = h(new Date().valueOf(), !0));
50
- const a = this.u.j(o.C.Jh) || [],
51
- u = this.u.j(o.C.Qh) || "";
50
+ const a = this.u.j(o.C.Yh) || [],
51
+ u = this.u.j(o.C.Jh) || "";
52
52
  if (
53
- (this.Yh.length > 0 &&
54
- (!ii(a, this.Yh) || u !== this.di.ki()) &&
55
- (t.sdk_metadata = this.Yh),
53
+ (this.Hh.length > 0 &&
54
+ (!ii(a, this.Hh) || u !== this.ri.Si()) &&
55
+ (t.sdk_metadata = this.Hh),
56
56
  (t.sdk_version = this.Wo),
57
57
  this.Vo && (t.sdk_flavor = this.Vo),
58
58
  (t.app_version = this.appVersion),
59
59
  (t.app_version_code = this.Xh),
60
- (t.device_id = i.id),
60
+ (t.device_id = s.id),
61
61
  e)
62
62
  ) {
63
63
  const e = this.wt.getUserId();
64
64
  null != e && (t.user_id = e);
65
65
  }
66
- if (!t.user_id && !this.Go.Fh()) {
67
- const e = Ht(this.u);
66
+ if (!t.user_id && !this.zo.Fh()) {
67
+ const e = Gt(this.u);
68
68
  e && (t.alias = e);
69
69
  }
70
70
  return t;
71
71
  }
72
- Ws(t, e, n) {
72
+ Ks(t, e, n) {
73
73
  const o = e.auth_error,
74
74
  h = e.error;
75
75
  if (!o && !h) return !0;
76
76
  if (o) {
77
77
  let e;
78
- this.Go.Bh();
79
- const s = { errorCode: o.error_code };
78
+ this.zo.Bh();
79
+ const i = { errorCode: o.error_code };
80
80
  for (const t of n)
81
- j(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
81
+ j(t) && "X-Braze-Auth-Signature" === t[0] && (i.signature = t[1]);
82
82
  t.respond_with && t.respond_with.user_id
83
- ? (s.userId = t.respond_with.user_id)
84
- : t.user_id && (s.userId = t.user_id);
85
- const i = o.reason;
83
+ ? (i.userId = t.respond_with.user_id)
84
+ : t.user_id && (i.userId = t.user_id);
85
+ const s = o.reason;
86
86
  return (
87
- i
88
- ? ((s.reason = i), (e = `due to ${i}`))
87
+ s
88
+ ? ((i.reason = s), (e = `due to ${s}`))
89
89
  : (e = `with error code ${o.error_code}.`),
90
- this.Go.Fh() ||
90
+ this.zo.Fh() ||
91
91
  (e +=
92
92
  ' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
93
93
  r.error(`SDK Authentication failed ${e}`),
94
- this.Zh(t.events || [], t.attributes || []),
95
- this.Go.qh(s),
94
+ this.Qh(t.events || [], t.attributes || []),
95
+ this.zo.qh(i),
96
96
  !1
97
97
  );
98
98
  }
@@ -100,38 +100,38 @@ export default class Rt {
100
100
  let n,
101
101
  o = h;
102
102
  switch (o) {
103
- case qt.Ra:
103
+ case qt.Zh:
104
104
  return (
105
105
  (n = "Received successful response with empty body."),
106
- s.q(i.Ms, { e: n }),
106
+ s.q(i.qs, { e: n }),
107
107
  r.info(n),
108
108
  !1
109
109
  );
110
- case qt.Ba:
110
+ case qt.Ra:
111
111
  return (
112
112
  (n = "Received successful response with invalid JSON"),
113
- s.q(i.Ms, { e: n + ": " + e.response }),
113
+ s.q(i.qs, { e: n + ": " + e.response }),
114
114
  r.info(n),
115
115
  !1
116
116
  );
117
- case qt.Xa:
118
- o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Ko}`;
117
+ case qt.qa:
118
+ o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Go}`;
119
119
  break;
120
- case qt.Na:
120
+ case qt.Aa:
121
121
  o =
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 qt.$a:
124
+ case qt.Ba:
125
125
  o = "No device identifier. Please contact support@braze.com";
126
126
  }
127
127
  r.error("Backend error: " + o);
128
128
  }
129
129
  return !1;
130
130
  }
131
- Ea(t, e, s, i) {
132
- return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
131
+ Na(t, e, i, s) {
132
+ return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i || s);
133
133
  }
134
- Ka(t, e, s, i, r = !1) {
134
+ Xa(t, e, i, s, r = !1) {
135
135
  const n = [],
136
136
  o = (t) => t || "",
137
137
  h = o(this.wt.getUserId());
@@ -140,10 +140,10 @@ export default class Rt {
140
140
  l = [];
141
141
  let c,
142
142
  d = null;
143
- if (s.length > 0) {
143
+ if (i.length > 0) {
144
144
  const t = [];
145
- for (const e of s) {
146
- if (((c = e.Mr()), this.Go.Fh())) {
145
+ for (const e of i) {
146
+ if (((c = e.Ir()), this.zo.Fh())) {
147
147
  if (h && !c.user_id) {
148
148
  d || (d = {}), d.events || (d.events = []), d.events.push(c);
149
149
  continue;
@@ -157,156 +157,201 @@ export default class Rt {
157
157
  }
158
158
  t.length > 0 && (a.events = t);
159
159
  }
160
- if (i.length > 0) {
160
+ if (s.length > 0) {
161
161
  const t = [];
162
- for (const e of i)
163
- e && (this.Go.Fh() && o(e.user_id) !== h ? u.push(e) : t.push(e));
162
+ for (const e of s)
163
+ e && (this.zo.Fh() && o(e.user_id) !== h ? u.push(e) : t.push(e));
164
164
  t.length > 0 && (a.attributes = t);
165
165
  }
166
- if ((this.Zh(l, u), (a = this.Ps(a, !0, r)), d)) {
167
- d = this.Ps(d, !1, r);
168
- const t = { requestData: d, headers: this._s(d, S.Gs.La) };
166
+ if ((this.Qh(l, u), (a = this.Js(a, !0, r)), d)) {
167
+ d = this.Js(d, !1, r);
168
+ const t = { requestData: d, headers: this.$s(d, D.Ps.$a) };
169
169
  n.push(t);
170
170
  }
171
- if (a && !this.Ea(a.events, a.attributes, t, e)) return d ? n : null;
172
- const f = { requestData: a, headers: this._s(a, S.Gs.La) };
171
+ if (a && !this.Na(a.events, a.attributes, t, e)) return d ? n : null;
172
+ const f = { requestData: a, headers: this.$s(a, D.Ps.$a) };
173
173
  return n.push(f), n;
174
174
  }
175
- Zh(t, e) {
175
+ Qh(t, e) {
176
176
  if (t) {
177
177
  const e = [];
178
- for (const s of t) {
179
- const t = ue.fromJson(s);
178
+ for (const i of t) {
179
+ const t = ue.fromJson(i);
180
180
  (t.time = Xt(t.time)), e.push(t);
181
181
  }
182
- this.u.zo(e);
182
+ this.u.xo(e);
183
183
  }
184
- if (e) for (const t of e) this.u.Pa(t);
184
+ if (e) for (const t of e) this.u.La(t);
185
185
  }
186
- Zs(t, e) {
187
- let s = "HTTP error ";
188
- null != t && (s += t + " "), (s += e), r.error(s);
186
+ Vs(t, e) {
187
+ let i = "HTTP error ";
188
+ null != t && (i += t + " "), (i += e), r.error(i);
189
189
  }
190
190
  qr(t) {
191
- return s.q(i.Ua, { n: t });
191
+ return s.q(i.Ea, { n: t });
192
192
  }
193
- Zi(t, e, s) {
194
- const i = {};
195
- t && (i.feed = !0), e && (i.triggers = !0);
196
- const r = null != s ? s : this.wt.getUserId();
197
- if ((r && (i.user_id = r), !i.user_id && !this.Go.Fh())) {
198
- const t = Ht(this.u);
199
- t && (i.alias = t);
193
+ Zi(t, e, i) {
194
+ const s = {};
195
+ t && (s.feed = !0), e && (s.triggers = !0);
196
+ const r = null != i ? i : this.wt.getUserId();
197
+ if ((r && (s.user_id = r), !s.user_id && !this.zo.Fh())) {
198
+ const t = Gt(this.u);
199
+ t && (s.alias = t);
200
200
  }
201
- return (i.config = { config_time: this.yt.ni() }), { respond_with: i };
201
+ return (s.config = { config_time: this.yt.ii() }), { respond_with: s };
202
202
  }
203
- Ha(t) {
203
+ Ka(t) {
204
204
  const e = new Date().valueOf();
205
- let s = Kt.toString();
206
- const i = S.Wa(this.u, t);
207
- if (-1 !== i) {
208
- s = (e - i).toString();
205
+ let i = Kt.toString();
206
+ const s = D.Pa(this.u, t);
207
+ if (-1 !== s) {
208
+ i = (e - s).toString();
209
209
  }
210
- return s;
210
+ return i;
211
211
  }
212
- _s(t, e, s = !1) {
213
- const i = [["X-Braze-Api-Key", this.rn]],
214
- r = this.Ha(e);
215
- i.push(["X-Braze-Last-Req-Ms-Ago", r]);
216
- const n = S.Ya(this.u, e).toString();
217
- i.push(["X-Braze-Req-Attempt", n]);
212
+ $s(t, e, i = !1) {
213
+ const s = [["X-Braze-Api-Key", this.rn]],
214
+ r = this.Ka(e);
215
+ s.push(["X-Braze-Last-Req-Ms-Ago", r]);
216
+ const n = D.Ua(this.u, e).toString();
217
+ s.push(["X-Braze-Req-Attempt", n]);
218
218
  let h = !1;
219
219
  if (
220
220
  (null != t.respond_with &&
221
221
  t.respond_with.triggers &&
222
- (i.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
222
+ (s.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
223
223
  null != t.respond_with &&
224
224
  t.respond_with.feed &&
225
- (i.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
226
- e === S.Gs.Bs)
225
+ (s.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
226
+ e === D.Ps.Bs)
227
227
  ) {
228
- i.push(["X-Braze-ContentCardsRequest", "true"]);
228
+ s.push(["X-Braze-ContentCardsRequest", "true"]);
229
229
  let t = this.u.j(o.C.As);
230
- (t && s) || ((t = 0), this.u.k(o.C.As, t)),
231
- i.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
230
+ (t && i) || ((t = 0), this.u.k(o.C.As, t)),
231
+ s.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
232
232
  (h = !0);
233
233
  }
234
234
  if (
235
- (e === S.Gs.qi &&
236
- (i.push(["X-Braze-FeatureFlagsRequest", "true"]), (h = !0)),
237
- h && i.push(["X-Braze-DataRequest", "true"]),
238
- this.Go.Fh())
235
+ (e === D.Ps.bi &&
236
+ (s.push(["X-Braze-FeatureFlagsRequest", "true"]), (h = !0)),
237
+ h && s.push(["X-Braze-DataRequest", "true"]),
238
+ this.zo.Fh())
239
239
  ) {
240
- const t = this.Go.kh();
241
- null != t && i.push(["X-Braze-Auth-Signature", t]);
240
+ const t = this.zo.kh();
241
+ null != t && s.push(["X-Braze-Auth-Signature", t]);
242
242
  }
243
- return i;
243
+ return s;
244
244
  }
245
- Qa(t, e, s, i) {
245
+ Ga(t, e, i, s) {
246
246
  window.setTimeout(() => {
247
- r.info(`Retrying rate limited ${this.Hh(i)}SDK request.`),
248
- this.Hs(e, s, i);
247
+ r.info(`Retrying rate limited ${this.$h(s)}SDK request.`),
248
+ this.Xs(e, i, s);
249
249
  }, t);
250
250
  }
251
- Hs(t, e, s) {
252
- const i = this.Va();
253
- if (!i.Za)
251
+ Xs(t, e, i, s) {
252
+ if (!this.Ha(i))
253
+ return (
254
+ r.info(`${this.$h(i)}SDK request being rate limited.`),
255
+ void ("function" == typeof s && s())
256
+ );
257
+ const n = this.Wa();
258
+ if (!n.Ya)
254
259
  return (
255
260
  r.info(
256
- `${this.Hh(
257
- s,
261
+ `${this.$h(
262
+ i,
258
263
  )}SDK request being rate limited. Request will be retried in ${Math.trunc(
259
- i.au / 1e3,
264
+ n.Ja / 1e3,
260
265
  )} seconds.`,
261
266
  ),
262
- void this.Qa(i.au, t, e, s)
267
+ void this.Ga(n.Ja, t, e, i)
263
268
  );
264
- this.u.k(o.C.du, new Date().valueOf());
265
- const n = t.device;
266
- n && n.os_version instanceof Promise
267
- ? n.os_version.then((s) => {
268
- (t.device.os_version = s), e();
269
+ this.u.k(o.C.Qa, new Date().valueOf());
270
+ const h = t.device;
271
+ h && h.os_version instanceof Promise
272
+ ? h.os_version.then((i) => {
273
+ (t.device.os_version = i), e(n.Va);
269
274
  })
270
- : e();
275
+ : e(n.Va);
271
276
  }
272
- li(t) {
277
+ Za(t) {
273
278
  var e;
274
- null === (e = this.u) || void 0 === e || e.k(o.C.fu, t);
279
+ null === (e = this.u) || void 0 === e || e.k(o.C.au, t);
280
+ }
281
+ du(t, e) {
282
+ let i = this.fu();
283
+ null == i && (i = {}), (i[t] = e), this.u.k(o.C.vu, i);
284
+ }
285
+ Ru() {
286
+ var t;
287
+ return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.au);
275
288
  }
276
- ui() {
289
+ fu() {
277
290
  var t;
278
- return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.fu);
291
+ return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.vu);
279
292
  }
280
- Ru(t, e, s, i) {
281
- let r = this.ui();
282
- (null == r || isNaN(r)) && (r = e);
283
- const n = (t - i) / 1e3;
284
- return (r = Math.min(r + n / s, e)), r;
293
+ gu(t, e, i, s, r = "") {
294
+ let n;
295
+ if (r) {
296
+ const t = this.fu();
297
+ n = null == t || isNaN(t[r]) ? e : t[r];
298
+ } else (n = this.Ru()), (null == n || isNaN(n)) && (n = e);
299
+ const o = (t - s) / 1e3;
300
+ return (n = Math.min(n + o / i, e)), n;
285
301
  }
286
- vu(t, e) {
302
+ pu(t, e) {
287
303
  return Math.max(0, (1 - t) * e * 1e3);
288
304
  }
289
- Va() {
290
- var t, e, s;
291
- const i = { Za: !0, au: 0 },
292
- r = null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.du);
293
- if (null == r || isNaN(r)) return i;
294
- const n = (null === (e = this.yt) || void 0 === e ? void 0 : e.pu()) || -1,
295
- h = (null === (s = this.yt) || void 0 === s ? void 0 : s.gu()) || -1;
296
- if (-1 === n || -1 === h) return i;
297
- const a = new Date().valueOf();
298
- let u = this.Ru(a, n, h, r);
299
- return u < 1
300
- ? ((i.Za = !1), (i.au = this.vu(u, h)), i)
301
- : ((u = Math.trunc(u) - 1), this.li(u), i);
305
+ bu(t, e = "") {
306
+ var i, s, r, n, h;
307
+ const a = { Ya: !0, Va: -1, Ja: 0 };
308
+ if ((null == t && (t = !0), !t && !e)) return a;
309
+ let u,
310
+ l,
311
+ c = null;
312
+ if (t) c = null === (i = this.u) || void 0 === i ? void 0 : i.j(o.C.Qa);
313
+ else {
314
+ const t = D.qu(this.u);
315
+ if (null == t || null == t[e]) return a;
316
+ c = t[e];
317
+ }
318
+ if (null == c || isNaN(c)) return a;
319
+ if (
320
+ (t
321
+ ? ((u =
322
+ (null === (s = this.yt) || void 0 === s ? void 0 : s.Au()) || -1),
323
+ (l =
324
+ (null === (r = this.yt) || void 0 === r ? void 0 : r.Du()) || -1))
325
+ : ((u =
326
+ (null === (n = this.yt) || void 0 === n ? void 0 : n.Tu(e)) || -1),
327
+ (l =
328
+ (null === (h = this.yt) || void 0 === h ? void 0 : h.ku(e)) || -1)),
329
+ -1 === u || -1 === l)
330
+ )
331
+ return a;
332
+ const d = new Date().valueOf();
333
+ let f = this.gu(d, u, l, c, e);
334
+ return f < 1
335
+ ? ((a.Ya = !1), (a.Ja = this.pu(f, l)), a)
336
+ : ((f = Math.trunc(f) - 1),
337
+ (a.Va = f),
338
+ t ? this.Za(f) : this.du(e, f),
339
+ a);
340
+ }
341
+ Wa() {
342
+ return this.bu(!0);
343
+ }
344
+ Ha(t) {
345
+ const e = this.bu(!1, t);
346
+ return !(e && !e.Ya);
302
347
  }
303
- Xs() {
304
- this.Go.Xs();
348
+ Os() {
349
+ this.zo.Os();
305
350
  }
306
- Vs() {
307
- return this.Ko;
351
+ Hs() {
352
+ return this.Go;
308
353
  }
309
354
  addSdkMetadata(t) {
310
- for (const e of t) -1 === this.Yh.indexOf(e) && this.Yh.push(e);
355
+ for (const e of t) -1 === this.Hh.indexOf(e) && this.Hh.push(e);
311
356
  }
312
357
  }
@@ -1,12 +1,8 @@
1
1
  import { STORAGE_KEYS as o } from "./storage-manager.js";
2
2
  import T from "./subscription-manager.js";
3
- import Gt from "../models/server-config.js";
3
+ import Ht from "../models/server-config.js";
4
4
  import s from "../common/event-logger.js";
5
5
  import { EventTypes as i } from "../../shared-lib/index.js";
6
- import {
7
- CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as Jt,
8
- CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Qt,
9
- } from "../common/constants.js";
10
6
  export default class Dt {
11
7
  constructor(t) {
12
8
  (this.u = t),
@@ -19,20 +15,20 @@ export default class Dt {
19
15
  }
20
16
  ll() {
21
17
  if (null == this.rl) {
22
- const t = this.u.j(o.C.hl);
23
- this.rl = null != t ? Gt.qn(t) : new Gt();
18
+ const t = this.u.j(o.C.ul);
19
+ this.rl = null != t ? Ht.qn(t) : new Ht();
24
20
  }
25
21
  return this.rl;
26
22
  }
27
- ni() {
28
- return this.ll().ol;
23
+ ii() {
24
+ return this.ll().hl;
29
25
  }
30
- ul(t) {
26
+ al(t) {
31
27
  if (null != t && null != t.config) {
32
28
  const e = t.config;
33
- if (e.time > this.ll().ol) {
34
- const t = (t) => (null == t ? this.ll().al : t),
35
- i = new Gt(
29
+ if (e.time > this.ll().hl) {
30
+ const t = (t) => (null == t ? this.ll().ol : t),
31
+ i = new Ht(
36
32
  e.time,
37
33
  e.events_blacklist,
38
34
  e.attributes_blacklist,
@@ -46,11 +42,11 @@ export default class Dt {
46
42
  let s = !1;
47
43
  null != i.cl && this.Wn() !== i.cl && (s = !0);
48
44
  let r = !1;
49
- null != i.ml.enabled && this.ri() !== i.ml.enabled && (r = !0);
45
+ null != i.ml.enabled && this.si() !== i.ml.enabled && (r = !0);
50
46
  let n = !1;
51
- null != i.mi.enabled && this.yi() !== i.mi.enabled && (n = !0),
47
+ null != i.hi.enabled && this.ci() !== i.hi.enabled && (n = !0),
52
48
  (this.rl = i),
53
- this.u.k(o.C.hl, i.Y()),
49
+ this.u.k(o.C.ul, i.Y()),
54
50
  s && this.tl.Dt(),
55
51
  r && this.el.Dt(),
56
52
  n && this.il.Dt();
@@ -61,10 +57,10 @@ export default class Dt {
61
57
  const e = this.tl.It(t);
62
58
  return this.sl && this.tl.removeSubscription(this.sl), (this.sl = e), e;
63
59
  }
64
- qs(t) {
60
+ Is(t) {
65
61
  return this.el.It(t);
66
62
  }
67
- xi(t) {
63
+ ji(t) {
68
64
  return this.il.It(t);
69
65
  }
70
66
  me(t) {
@@ -77,48 +73,48 @@ export default class Dt {
77
73
  return -1 !== this.ll().bl.indexOf(t);
78
74
  }
79
75
  dl() {
80
- return this.ll().Cl;
76
+ return this.ll().Rl;
81
77
  }
82
78
  Wn() {
83
79
  return this.ll().cl;
84
80
  }
85
- ri() {
81
+ si() {
86
82
  return this.ll().ml.enabled || !1;
87
83
  }
88
- Is() {
89
- const t = this.ll().ml.rate_limit;
84
+ Cl() {
85
+ const t = this.ll().ol;
90
86
  return !(!t || null == t.enabled) && t.enabled;
91
87
  }
92
- ci() {
93
- if (!this.Is()) return -1;
94
- const t = this.ll().ml.rate_limit;
95
- return null == t.capacity ? Jt : t.capacity <= 0 ? -1 : t.capacity;
88
+ Au() {
89
+ if (!this.Cl()) return -1;
90
+ const t = this.ll().ol;
91
+ return null == t.capacity || t.capacity < 10 ? -1 : t.capacity;
96
92
  }
97
- fi() {
98
- if (!this.Is()) return -1;
99
- const t = this.ll().ml.rate_limit;
100
- return null == t.refill_rate ? Qt : t.refill_rate <= 0 ? -1 : t.refill_rate;
93
+ Du() {
94
+ if (!this.Cl()) return -1;
95
+ const t = this.ll().ol;
96
+ return null == t.refill_rate || t.refill_rate <= 0 ? -1 : t.refill_rate;
101
97
  }
102
- Rl() {
103
- const t = this.ll().al;
104
- return !(!t || null == t.enabled) && t.enabled;
98
+ vl(t) {
99
+ const e = this.ll().ol.endpoint_overrides;
100
+ return null == e ? null : e[t];
105
101
  }
106
- pu() {
107
- if (!this.Rl()) return -1;
108
- const t = this.ll().al;
109
- return null == t.capacity || t.capacity < 10 ? -1 : t.capacity;
102
+ Tu(t) {
103
+ const e = this.vl(t);
104
+ return null == e || isNaN(e.capacity) || e.capacity <= 0 ? -1 : e.capacity;
110
105
  }
111
- gu() {
112
- if (!this.Rl()) return -1;
113
- const t = this.ll().al;
114
- return null == t.refill_rate || t.refill_rate <= 0 ? -1 : t.refill_rate;
106
+ ku(t) {
107
+ const e = this.vl(t);
108
+ return null == e || isNaN(e.refill_rate) || e.refill_rate <= 0
109
+ ? -1
110
+ : e.refill_rate;
115
111
  }
116
- yi() {
117
- return this.ll().mi.enabled && null == this.zi()
118
- ? (s.q(i.Ms, { e: "Missing feature flag refresh_rate_limit." }), !1)
119
- : this.ll().mi.enabled || !1;
112
+ ci() {
113
+ return this.ll().hi.enabled && null == this.Ri()
114
+ ? (s.q(i.qs, { e: "Missing feature flag refresh_rate_limit." }), !1)
115
+ : this.ll().hi.enabled || !1;
120
116
  }
121
- zi() {
122
- return this.ll().mi.refresh_rate_limit;
117
+ Ri() {
118
+ return this.ll().hi.refresh_rate_limit;
123
119
  }
124
120
  }