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