@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.
- package/index.d.ts +54 -5
- package/package.json +1 -1
- package/shared-lib/event-types.js +14 -14
- package/shared-lib/indexed-db-adapter.js +51 -51
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +7 -7
- package/src/ContentCards/content-cards-provider.js +107 -135
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +1 -1
- package/src/FeatureFlags/feature-flag.js +41 -30
- package/src/FeatureFlags/feature-flags-provider.js +88 -84
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +24 -24
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +9 -9
- package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
- package/src/InAppMessage/display/modal-utils.js +5 -5
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +78 -75
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +12 -12
- package/src/InAppMessage/models/html-message.js +9 -9
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +84 -82
- package/src/InAppMessage/models/modal-message.js +12 -12
- package/src/InAppMessage/models/slide-up-message.js +17 -17
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +17 -17
- package/src/Push/push-manager-factory.js +6 -6
- package/src/Push/push-manager.js +2 -2
- package/src/Push/utils/push-utils.js +1 -1
- package/src/User/user.js +12 -12
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +0 -2
- package/src/common/event-logger.js +2 -2
- package/src/common/feed-display.js +1 -1
- package/src/managers/auth-manager.js +3 -3
- package/src/managers/braze-instance.js +73 -73
- package/src/managers/device-manager.js +15 -15
- package/src/managers/network-manager.js +190 -145
- package/src/managers/server-config-manager.js +43 -47
- package/src/managers/session-manager.js +21 -21
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +107 -107
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +6 -6
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +8 -8
- package/src/models/server-config.js +25 -25
- package/src/request-controller.js +115 -108
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +3 -3
- package/src/triggers/models/filter.js +55 -55
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +40 -40
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +31 -31
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +40 -40
- package/src/ui/js/attach-css.js +2 -2
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +23 -23
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/dom-utils.js +6 -6
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -37
- package/src/util/user-agent-parser.js +7 -7
- 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
|
|
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
|
|
13
|
+
import { getAlias as Gt } from "./utils.js";
|
|
14
14
|
export default class Rt {
|
|
15
|
-
constructor(t, e,
|
|
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.
|
|
19
|
-
(this.wt =
|
|
20
|
-
(this.
|
|
18
|
+
(this.zo = i),
|
|
19
|
+
(this.wt = s),
|
|
20
|
+
(this.ri = r),
|
|
21
21
|
(this.yt = n),
|
|
22
22
|
(this.rn = o),
|
|
23
|
-
(this.
|
|
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
|
|
28
|
+
(this.$h = (t) => (null == t ? "" : `${t} `)),
|
|
29
29
|
(this.on = t),
|
|
30
30
|
(this.u = e),
|
|
31
|
-
(this.
|
|
32
|
-
(this.wt =
|
|
33
|
-
(this.
|
|
31
|
+
(this.zo = i),
|
|
32
|
+
(this.wt = s),
|
|
33
|
+
(this.ri = r),
|
|
34
34
|
(this.yt = n),
|
|
35
35
|
(this.rn = o),
|
|
36
|
-
(this.
|
|
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.
|
|
41
|
+
(this.Hh = ["npm"]);
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
r =
|
|
46
|
-
n = this.u.j(o.C.
|
|
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.
|
|
51
|
-
u = this.u.j(o.C.
|
|
50
|
+
const a = this.u.j(o.C.Yh) || [],
|
|
51
|
+
u = this.u.j(o.C.Jh) || "";
|
|
52
52
|
if (
|
|
53
|
-
(this.
|
|
54
|
-
(!ii(a, this.
|
|
55
|
-
(t.sdk_metadata = this.
|
|
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 =
|
|
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.
|
|
67
|
-
const e =
|
|
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
|
-
|
|
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.
|
|
79
|
-
const
|
|
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] && (
|
|
81
|
+
j(t) && "X-Braze-Auth-Signature" === t[0] && (i.signature = t[1]);
|
|
82
82
|
t.respond_with && t.respond_with.user_id
|
|
83
|
-
? (
|
|
84
|
-
: t.user_id && (
|
|
85
|
-
const
|
|
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
|
-
|
|
88
|
-
? ((
|
|
87
|
+
s
|
|
88
|
+
? ((i.reason = s), (e = `due to ${s}`))
|
|
89
89
|
: (e = `with error code ${o.error_code}.`),
|
|
90
|
-
this.
|
|
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.
|
|
95
|
-
this.
|
|
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.
|
|
103
|
+
case qt.Zh:
|
|
104
104
|
return (
|
|
105
105
|
(n = "Received successful response with empty body."),
|
|
106
|
-
s.q(i.
|
|
106
|
+
s.q(i.qs, { e: n }),
|
|
107
107
|
r.info(n),
|
|
108
108
|
!1
|
|
109
109
|
);
|
|
110
|
-
case qt.
|
|
110
|
+
case qt.Ra:
|
|
111
111
|
return (
|
|
112
112
|
(n = "Received successful response with invalid JSON"),
|
|
113
|
-
s.q(i.
|
|
113
|
+
s.q(i.qs, { e: n + ": " + e.response }),
|
|
114
114
|
r.info(n),
|
|
115
115
|
!1
|
|
116
116
|
);
|
|
117
|
-
case qt.
|
|
118
|
-
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.
|
|
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.
|
|
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
|
|
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
|
-
|
|
132
|
-
return !!((t && 0 !== t.length) || (e && 0 !== e.length) ||
|
|
131
|
+
Na(t, e, i, s) {
|
|
132
|
+
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i || s);
|
|
133
133
|
}
|
|
134
|
-
|
|
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 (
|
|
143
|
+
if (i.length > 0) {
|
|
144
144
|
const t = [];
|
|
145
|
-
for (const e of
|
|
146
|
-
if (((c = e.
|
|
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 (
|
|
160
|
+
if (s.length > 0) {
|
|
161
161
|
const t = [];
|
|
162
|
-
for (const e of
|
|
163
|
-
e && (this.
|
|
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.
|
|
167
|
-
d = this.
|
|
168
|
-
const t = { requestData: d, headers: this
|
|
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.
|
|
172
|
-
const f = { requestData: a, headers: this
|
|
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
|
-
|
|
175
|
+
Qh(t, e) {
|
|
176
176
|
if (t) {
|
|
177
177
|
const e = [];
|
|
178
|
-
for (const
|
|
179
|
-
const t = ue.fromJson(
|
|
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.
|
|
182
|
+
this.u.xo(e);
|
|
183
183
|
}
|
|
184
|
-
if (e) for (const t of e) this.u.
|
|
184
|
+
if (e) for (const t of e) this.u.La(t);
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
let
|
|
188
|
-
null != t && (
|
|
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.
|
|
191
|
+
return s.q(i.Ea, { n: t });
|
|
192
192
|
}
|
|
193
|
-
Zi(t, e,
|
|
194
|
-
const
|
|
195
|
-
t && (
|
|
196
|
-
const r = null !=
|
|
197
|
-
if ((r && (
|
|
198
|
-
const t =
|
|
199
|
-
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 (
|
|
201
|
+
return (s.config = { config_time: this.yt.ii() }), { respond_with: s };
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
Ka(t) {
|
|
204
204
|
const e = new Date().valueOf();
|
|
205
|
-
let
|
|
206
|
-
const
|
|
207
|
-
if (-1 !==
|
|
208
|
-
|
|
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
|
|
210
|
+
return i;
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
r = this.
|
|
215
|
-
|
|
216
|
-
const n =
|
|
217
|
-
|
|
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
|
-
(
|
|
222
|
+
(s.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
|
|
223
223
|
null != t.respond_with &&
|
|
224
224
|
t.respond_with.feed &&
|
|
225
|
-
(
|
|
226
|
-
e ===
|
|
225
|
+
(s.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
|
|
226
|
+
e === D.Ps.Bs)
|
|
227
227
|
) {
|
|
228
|
-
|
|
228
|
+
s.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
229
229
|
let t = this.u.j(o.C.As);
|
|
230
|
-
(t &&
|
|
231
|
-
|
|
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 ===
|
|
236
|
-
(
|
|
237
|
-
h &&
|
|
238
|
-
this.
|
|
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.
|
|
241
|
-
null != t &&
|
|
240
|
+
const t = this.zo.kh();
|
|
241
|
+
null != t && s.push(["X-Braze-Auth-Signature", t]);
|
|
242
242
|
}
|
|
243
|
-
return
|
|
243
|
+
return s;
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
Ga(t, e, i, s) {
|
|
246
246
|
window.setTimeout(() => {
|
|
247
|
-
r.info(`Retrying rate limited ${this
|
|
248
|
-
this.
|
|
247
|
+
r.info(`Retrying rate limited ${this.$h(s)}SDK request.`),
|
|
248
|
+
this.Xs(e, i, s);
|
|
249
249
|
}, t);
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
|
257
|
-
|
|
261
|
+
`${this.$h(
|
|
262
|
+
i,
|
|
258
263
|
)}SDK request being rate limited. Request will be retried in ${Math.trunc(
|
|
259
|
-
|
|
264
|
+
n.Ja / 1e3,
|
|
260
265
|
)} seconds.`,
|
|
261
266
|
),
|
|
262
|
-
void this.
|
|
267
|
+
void this.Ga(n.Ja, t, e, i)
|
|
263
268
|
);
|
|
264
|
-
this.u.k(o.C.
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
?
|
|
268
|
-
(t.device.os_version =
|
|
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
|
-
|
|
277
|
+
Za(t) {
|
|
273
278
|
var e;
|
|
274
|
-
null === (e = this.u) || void 0 === e || e.k(o.C.
|
|
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
|
-
|
|
289
|
+
fu() {
|
|
277
290
|
var t;
|
|
278
|
-
return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.
|
|
291
|
+
return null === (t = this.u) || void 0 === t ? void 0 : t.j(o.C.vu);
|
|
279
292
|
}
|
|
280
|
-
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
302
|
+
pu(t, e) {
|
|
287
303
|
return Math.max(0, (1 - t) * e * 1e3);
|
|
288
304
|
}
|
|
289
|
-
|
|
290
|
-
var
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
304
|
-
this.
|
|
348
|
+
Os() {
|
|
349
|
+
this.zo.Os();
|
|
305
350
|
}
|
|
306
|
-
|
|
307
|
-
return this.
|
|
351
|
+
Hs() {
|
|
352
|
+
return this.Go;
|
|
308
353
|
}
|
|
309
354
|
addSdkMetadata(t) {
|
|
310
|
-
for (const e of t) -1 === this.
|
|
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
|
|
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.
|
|
23
|
-
this.rl = null != t ?
|
|
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
|
-
|
|
28
|
-
return this.ll().
|
|
23
|
+
ii() {
|
|
24
|
+
return this.ll().hl;
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
al(t) {
|
|
31
27
|
if (null != t && null != t.config) {
|
|
32
28
|
const e = t.config;
|
|
33
|
-
if (e.time > this.ll().
|
|
34
|
-
const t = (t) => (null == t ? this.ll().
|
|
35
|
-
i = new
|
|
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.
|
|
45
|
+
null != i.ml.enabled && this.si() !== i.ml.enabled && (r = !0);
|
|
50
46
|
let n = !1;
|
|
51
|
-
null != i.
|
|
47
|
+
null != i.hi.enabled && this.ci() !== i.hi.enabled && (n = !0),
|
|
52
48
|
(this.rl = i),
|
|
53
|
-
this.u.k(o.C.
|
|
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
|
-
|
|
60
|
+
Is(t) {
|
|
65
61
|
return this.el.It(t);
|
|
66
62
|
}
|
|
67
|
-
|
|
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().
|
|
76
|
+
return this.ll().Rl;
|
|
81
77
|
}
|
|
82
78
|
Wn() {
|
|
83
79
|
return this.ll().cl;
|
|
84
80
|
}
|
|
85
|
-
|
|
81
|
+
si() {
|
|
86
82
|
return this.ll().ml.enabled || !1;
|
|
87
83
|
}
|
|
88
|
-
|
|
89
|
-
const t = this.ll().
|
|
84
|
+
Cl() {
|
|
85
|
+
const t = this.ll().ol;
|
|
90
86
|
return !(!t || null == t.enabled) && t.enabled;
|
|
91
87
|
}
|
|
92
|
-
|
|
93
|
-
if (!this.
|
|
94
|
-
const t = this.ll().
|
|
95
|
-
return null == 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
|
-
|
|
98
|
-
if (!this.
|
|
99
|
-
const t = this.ll().
|
|
100
|
-
return null == 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
|
-
|
|
103
|
-
const
|
|
104
|
-
return
|
|
98
|
+
vl(t) {
|
|
99
|
+
const e = this.ll().ol.endpoint_overrides;
|
|
100
|
+
return null == e ? null : e[t];
|
|
105
101
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
117
|
-
return this.ll().
|
|
118
|
-
? (s.q(i.
|
|
119
|
-
: this.ll().
|
|
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
|
-
|
|
122
|
-
return this.ll().
|
|
117
|
+
Ri() {
|
|
118
|
+
return this.ll().hi.refresh_rate_limit;
|
|
123
119
|
}
|
|
124
120
|
}
|