@braze/web-sdk 5.1.1 → 5.3.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.
- package/index.d.ts +65 -10
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +20 -20
- package/shared-lib/indexed-db-adapter.js +52 -52
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +22 -21
- 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 +45 -42
- package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +23 -21
- package/src/InAppMessage/in-app-message-manager.js +95 -112
- 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/control-message.js +4 -2
- package/src/InAppMessage/models/full-screen-message.js +14 -11
- package/src/InAppMessage/models/html-message.js +11 -9
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +127 -120
- package/src/InAppMessage/models/modal-message.js +14 -11
- package/src/InAppMessage/models/slide-up-message.js +46 -21
- 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 +37 -43
- package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
- package/src/Push/push-manager-factory.js +4 -4
- package/src/Push/push-manager.js +118 -110
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +19 -19
- package/src/common/base-feed.js +1 -1
- 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 +12 -12
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +119 -112
- package/src/managers/device-manager.js +19 -19
- package/src/managers/network-manager.js +215 -165
- package/src/managers/server-config-manager.js +46 -50
- package/src/managers/session-manager.js +21 -21
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +128 -125
- package/src/managers/utils.js +6 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +19 -11
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +34 -20
- package/src/models/push-token.js +4 -4
- package/src/models/server-config.js +24 -24
- package/src/request-controller.js +134 -124
- package/src/triggers/models/filter-set.js +2 -2
- package/src/triggers/models/filter.js +56 -56
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +30 -30
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +2 -2
- package/src/triggers/triggers-provider.js +84 -95
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +25 -24
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +2 -2
- package/src/util/dom-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -37
- package/src/util/user-agent-parser.js +8 -8
- package/src/util/validation-utils.js +2 -0
- package/src/util/window-utils.js +3 -3
|
@@ -8,300 +8,350 @@ 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 Gt } from "./utils.js";
|
|
13
14
|
export default class Rt {
|
|
14
|
-
constructor(t, e,
|
|
15
|
-
(this.
|
|
15
|
+
constructor(t, e, i, s, r, n, o, h, a, u, l, c) {
|
|
16
|
+
(this.on = t),
|
|
16
17
|
(this.u = e),
|
|
17
|
-
(this.
|
|
18
|
-
(this.wt =
|
|
19
|
-
(this.
|
|
18
|
+
(this.zo = i),
|
|
19
|
+
(this.wt = s),
|
|
20
|
+
(this.ri = r),
|
|
20
21
|
(this.yt = n),
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.Wo =
|
|
22
|
+
(this.rn = o),
|
|
23
|
+
(this.Go = h),
|
|
24
|
+
(this.Wo = a),
|
|
24
25
|
(this.Vo = u),
|
|
25
26
|
(this.appVersion = l),
|
|
26
|
-
(this.
|
|
27
|
-
(this
|
|
28
|
-
(this.
|
|
27
|
+
(this.Xh = c),
|
|
28
|
+
(this.$h = (t) => (null == t ? "" : `${t} `)),
|
|
29
|
+
(this.on = t),
|
|
29
30
|
(this.u = e),
|
|
30
|
-
(this.
|
|
31
|
-
(this.wt =
|
|
32
|
-
(this.
|
|
31
|
+
(this.zo = i),
|
|
32
|
+
(this.wt = s),
|
|
33
|
+
(this.ri = r),
|
|
33
34
|
(this.yt = n),
|
|
34
|
-
(this.
|
|
35
|
-
(this.
|
|
36
|
-
(this.Wo =
|
|
35
|
+
(this.rn = o),
|
|
36
|
+
(this.Go = h),
|
|
37
|
+
(this.Wo = a),
|
|
37
38
|
(this.Vo = u),
|
|
38
39
|
(this.appVersion = l),
|
|
39
|
-
(this.
|
|
40
|
-
(this.
|
|
40
|
+
(this.Xh = c),
|
|
41
|
+
(this.Hh = ["npm"]);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
r =
|
|
45
|
-
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);
|
|
46
47
|
ii(n, r) || (t.device = r),
|
|
47
|
-
(t.api_key = this.
|
|
48
|
+
(t.api_key = this.rn),
|
|
48
49
|
(t.time = h(new Date().valueOf(), !0));
|
|
49
|
-
const a = this.u.j(o.C.
|
|
50
|
-
u = this.u.j(o.C
|
|
50
|
+
const a = this.u.j(o.C.Yh) || [],
|
|
51
|
+
u = this.u.j(o.C.Jh) || "";
|
|
51
52
|
if (
|
|
52
|
-
(this.
|
|
53
|
-
(!ii(a, this.
|
|
54
|
-
(t.sdk_metadata = this.
|
|
53
|
+
(this.Hh.length > 0 &&
|
|
54
|
+
(!ii(a, this.Hh) || u !== this.ri.Si()) &&
|
|
55
|
+
(t.sdk_metadata = this.Hh),
|
|
55
56
|
(t.sdk_version = this.Wo),
|
|
56
57
|
this.Vo && (t.sdk_flavor = this.Vo),
|
|
57
58
|
(t.app_version = this.appVersion),
|
|
58
|
-
(t.app_version_code = this.
|
|
59
|
-
(t.device_id =
|
|
59
|
+
(t.app_version_code = this.Xh),
|
|
60
|
+
(t.device_id = s.id),
|
|
60
61
|
e)
|
|
61
62
|
) {
|
|
62
63
|
const e = this.wt.getUserId();
|
|
63
64
|
null != e && (t.user_id = e);
|
|
64
65
|
}
|
|
66
|
+
if (!t.user_id && !this.zo.Fh()) {
|
|
67
|
+
const e = Gt(this.u);
|
|
68
|
+
e && (t.alias = e);
|
|
69
|
+
}
|
|
65
70
|
return t;
|
|
66
71
|
}
|
|
67
|
-
|
|
72
|
+
Ks(t, e, n) {
|
|
68
73
|
const o = e.auth_error,
|
|
69
|
-
|
|
70
|
-
if (!o && !
|
|
74
|
+
h = e.error;
|
|
75
|
+
if (!o && !h) return !0;
|
|
71
76
|
if (o) {
|
|
72
77
|
let e;
|
|
73
|
-
this.
|
|
74
|
-
const
|
|
78
|
+
this.zo.Bh();
|
|
79
|
+
const i = { errorCode: o.error_code };
|
|
75
80
|
for (const t of n)
|
|
76
|
-
j(t) && "X-Braze-Auth-Signature" === t[0] && (
|
|
81
|
+
j(t) && "X-Braze-Auth-Signature" === t[0] && (i.signature = t[1]);
|
|
77
82
|
t.respond_with && t.respond_with.user_id
|
|
78
|
-
? (
|
|
79
|
-
: t.user_id && (
|
|
80
|
-
const
|
|
83
|
+
? (i.userId = t.respond_with.user_id)
|
|
84
|
+
: t.user_id && (i.userId = t.user_id);
|
|
85
|
+
const s = o.reason;
|
|
81
86
|
return (
|
|
82
|
-
|
|
83
|
-
? ((
|
|
87
|
+
s
|
|
88
|
+
? ((i.reason = s), (e = `due to ${s}`))
|
|
84
89
|
: (e = `with error code ${o.error_code}.`),
|
|
85
|
-
this.
|
|
90
|
+
this.zo.Fh() ||
|
|
86
91
|
(e +=
|
|
87
92
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
88
93
|
r.error(`SDK Authentication failed ${e}`),
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
94
|
+
this.Qh(t.events || [], t.attributes || []),
|
|
95
|
+
this.zo.qh(i),
|
|
91
96
|
!1
|
|
92
97
|
);
|
|
93
98
|
}
|
|
94
|
-
if (
|
|
99
|
+
if (h) {
|
|
95
100
|
let n,
|
|
96
|
-
o =
|
|
101
|
+
o = h;
|
|
97
102
|
switch (o) {
|
|
98
|
-
case qt.
|
|
103
|
+
case qt.Zh:
|
|
99
104
|
return (
|
|
100
105
|
(n = "Received successful response with empty body."),
|
|
101
|
-
s.q(i.
|
|
106
|
+
s.q(i.qs, { e: n }),
|
|
102
107
|
r.info(n),
|
|
103
108
|
!1
|
|
104
109
|
);
|
|
105
|
-
case qt.
|
|
110
|
+
case qt.Ra:
|
|
106
111
|
return (
|
|
107
112
|
(n = "Received successful response with invalid JSON"),
|
|
108
|
-
s.q(i.
|
|
113
|
+
s.q(i.qs, { e: n + ": " + e.response }),
|
|
109
114
|
r.info(n),
|
|
110
115
|
!1
|
|
111
116
|
);
|
|
112
|
-
case qt.
|
|
113
|
-
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}`;
|
|
114
119
|
break;
|
|
115
|
-
case qt.
|
|
120
|
+
case qt.Aa:
|
|
116
121
|
o =
|
|
117
122
|
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
118
123
|
break;
|
|
119
|
-
case qt.
|
|
124
|
+
case qt.Ba:
|
|
120
125
|
o = "No device identifier. Please contact support@braze.com";
|
|
121
126
|
}
|
|
122
127
|
r.error("Backend error: " + o);
|
|
123
128
|
}
|
|
124
129
|
return !1;
|
|
125
130
|
}
|
|
126
|
-
|
|
127
|
-
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);
|
|
128
133
|
}
|
|
129
|
-
|
|
134
|
+
Xa(t, e, i, s, r = !1) {
|
|
130
135
|
const n = [],
|
|
131
136
|
o = (t) => t || "",
|
|
132
|
-
|
|
133
|
-
let
|
|
137
|
+
h = o(this.wt.getUserId());
|
|
138
|
+
let a = this.Zi(t, e);
|
|
134
139
|
const u = [],
|
|
135
140
|
l = [];
|
|
136
141
|
let c,
|
|
137
142
|
d = null;
|
|
138
|
-
if (
|
|
143
|
+
if (i.length > 0) {
|
|
139
144
|
const t = [];
|
|
140
|
-
for (const e of
|
|
141
|
-
if (((c = e.
|
|
142
|
-
if (
|
|
145
|
+
for (const e of i) {
|
|
146
|
+
if (((c = e.Ir()), this.zo.Fh())) {
|
|
147
|
+
if (h && !c.user_id) {
|
|
143
148
|
d || (d = {}), d.events || (d.events = []), d.events.push(c);
|
|
144
149
|
continue;
|
|
145
150
|
}
|
|
146
|
-
if (o(c.user_id) !==
|
|
151
|
+
if (o(c.user_id) !== h) {
|
|
147
152
|
l.push(c);
|
|
148
153
|
continue;
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
t.push(c);
|
|
152
157
|
}
|
|
153
|
-
t.length > 0 && (
|
|
158
|
+
t.length > 0 && (a.events = t);
|
|
154
159
|
}
|
|
155
|
-
if (
|
|
160
|
+
if (s.length > 0) {
|
|
156
161
|
const t = [];
|
|
157
|
-
for (const e of
|
|
158
|
-
e && (this.
|
|
159
|
-
t.length > 0 && (
|
|
162
|
+
for (const e of s)
|
|
163
|
+
e && (this.zo.Fh() && o(e.user_id) !== h ? u.push(e) : t.push(e));
|
|
164
|
+
t.length > 0 && (a.attributes = t);
|
|
160
165
|
}
|
|
161
|
-
if ((this.
|
|
162
|
-
d = this.
|
|
163
|
-
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) };
|
|
164
169
|
n.push(t);
|
|
165
170
|
}
|
|
166
|
-
if (
|
|
167
|
-
const f = { requestData:
|
|
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) };
|
|
168
173
|
return n.push(f), n;
|
|
169
174
|
}
|
|
170
|
-
|
|
175
|
+
Qh(t, e) {
|
|
171
176
|
if (t) {
|
|
172
177
|
const e = [];
|
|
173
|
-
for (const
|
|
174
|
-
const t = ue.fromJson(
|
|
178
|
+
for (const i of t) {
|
|
179
|
+
const t = ue.fromJson(i);
|
|
175
180
|
(t.time = Xt(t.time)), e.push(t);
|
|
176
181
|
}
|
|
177
|
-
this.u.
|
|
182
|
+
this.u.xo(e);
|
|
178
183
|
}
|
|
179
|
-
if (e) for (const t of e) this.u.
|
|
184
|
+
if (e) for (const t of e) this.u.La(t);
|
|
180
185
|
}
|
|
181
|
-
|
|
182
|
-
let
|
|
183
|
-
null != t && (
|
|
186
|
+
Vs(t, e) {
|
|
187
|
+
let i = "HTTP error ";
|
|
188
|
+
null != t && (i += t + " "), (i += e), r.error(i);
|
|
184
189
|
}
|
|
185
190
|
qr(t) {
|
|
186
|
-
return s.q(i.
|
|
191
|
+
return s.q(i.Ea, { n: t });
|
|
187
192
|
}
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
t && (
|
|
191
|
-
const r = null !=
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
(
|
|
195
|
-
|
|
196
|
-
);
|
|
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
|
+
}
|
|
201
|
+
return (s.config = { config_time: this.yt.ii() }), { respond_with: s };
|
|
197
202
|
}
|
|
198
|
-
|
|
203
|
+
Ka(t) {
|
|
199
204
|
const e = new Date().valueOf();
|
|
200
|
-
let
|
|
201
|
-
const
|
|
202
|
-
if (-1 !==
|
|
203
|
-
|
|
205
|
+
let i = Kt.toString();
|
|
206
|
+
const s = D.Pa(this.u, t);
|
|
207
|
+
if (-1 !== s) {
|
|
208
|
+
i = (e - s).toString();
|
|
204
209
|
}
|
|
205
|
-
return
|
|
210
|
+
return i;
|
|
206
211
|
}
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
r = this.
|
|
210
|
-
|
|
211
|
-
const n =
|
|
212
|
-
|
|
213
|
-
let
|
|
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
|
+
let h = !1;
|
|
214
219
|
if (
|
|
215
220
|
(null != t.respond_with &&
|
|
216
221
|
t.respond_with.triggers &&
|
|
217
|
-
(
|
|
222
|
+
(s.push(["X-Braze-TriggersRequest", "true"]), (h = !0)),
|
|
218
223
|
null != t.respond_with &&
|
|
219
224
|
t.respond_with.feed &&
|
|
220
|
-
(
|
|
221
|
-
e ===
|
|
225
|
+
(s.push(["X-Braze-FeedRequest", "true"]), (h = !0)),
|
|
226
|
+
e === D.Ps.Bs)
|
|
222
227
|
) {
|
|
223
|
-
|
|
228
|
+
s.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
224
229
|
let t = this.u.j(o.C.As);
|
|
225
|
-
(t &&
|
|
226
|
-
|
|
227
|
-
(
|
|
230
|
+
(t && i) || ((t = 0), this.u.k(o.C.As, t)),
|
|
231
|
+
s.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
|
|
232
|
+
(h = !0);
|
|
228
233
|
}
|
|
229
234
|
if (
|
|
230
|
-
(e ===
|
|
231
|
-
(
|
|
232
|
-
|
|
233
|
-
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())
|
|
234
239
|
) {
|
|
235
|
-
const t = this.
|
|
236
|
-
null != t &&
|
|
240
|
+
const t = this.zo.kh();
|
|
241
|
+
null != t && s.push(["X-Braze-Auth-Signature", t]);
|
|
237
242
|
}
|
|
238
|
-
return
|
|
243
|
+
return s;
|
|
239
244
|
}
|
|
240
|
-
|
|
245
|
+
Ga(t, e, i, s) {
|
|
241
246
|
window.setTimeout(() => {
|
|
242
|
-
r.info(`Retrying rate limited ${this
|
|
243
|
-
this.
|
|
247
|
+
r.info(`Retrying rate limited ${this.$h(s)}SDK request.`),
|
|
248
|
+
this.Xs(e, i, s);
|
|
244
249
|
}, t);
|
|
245
250
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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)
|
|
249
259
|
return (
|
|
250
260
|
r.info(
|
|
251
|
-
`${this
|
|
252
|
-
|
|
261
|
+
`${this.$h(
|
|
262
|
+
i,
|
|
253
263
|
)}SDK request being rate limited. Request will be retried in ${Math.trunc(
|
|
254
|
-
|
|
264
|
+
n.Ja / 1e3,
|
|
255
265
|
)} seconds.`,
|
|
256
266
|
),
|
|
257
|
-
void this.
|
|
267
|
+
void this.Ga(n.Ja, t, e, i)
|
|
258
268
|
);
|
|
259
|
-
this.u.k(o.C.
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
?
|
|
263
|
-
(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);
|
|
264
274
|
})
|
|
265
|
-
: e();
|
|
275
|
+
: e(n.Va);
|
|
266
276
|
}
|
|
267
|
-
|
|
277
|
+
Za(t) {
|
|
268
278
|
var e;
|
|
269
|
-
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);
|
|
270
288
|
}
|
|
271
|
-
|
|
289
|
+
fu() {
|
|
272
290
|
var t;
|
|
273
|
-
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);
|
|
274
292
|
}
|
|
275
|
-
|
|
276
|
-
let
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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;
|
|
280
301
|
}
|
|
281
|
-
|
|
302
|
+
pu(t, e) {
|
|
282
303
|
return Math.max(0, (1 - t) * e * 1e3);
|
|
283
304
|
}
|
|
284
|
-
|
|
285
|
-
var
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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);
|
|
297
347
|
}
|
|
298
|
-
|
|
299
|
-
this.
|
|
348
|
+
Os() {
|
|
349
|
+
this.zo.Os();
|
|
300
350
|
}
|
|
301
|
-
|
|
302
|
-
return this.
|
|
351
|
+
Hs() {
|
|
352
|
+
return this.Go;
|
|
303
353
|
}
|
|
304
354
|
addSdkMetadata(t) {
|
|
305
|
-
for (const e of t) -1 === this.
|
|
355
|
+
for (const e of t) -1 === this.Hh.indexOf(e) && this.Hh.push(e);
|
|
306
356
|
}
|
|
307
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 Vt,
|
|
8
|
-
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Ht,
|
|
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,
|
|
@@ -44,27 +40,27 @@ export default class Dt {
|
|
|
44
40
|
t(e.global_request_rate_limit),
|
|
45
41
|
);
|
|
46
42
|
let s = !1;
|
|
47
|
-
null != i.cl && this.
|
|
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();
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
|
-
|
|
56
|
+
_n(t) {
|
|
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
|
}
|