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