@braze/web-sdk 4.8.0 → 4.8.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 +6 -3
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +11 -11
- package/shared-lib/indexed-db-adapter.js +67 -67
- package/shared-lib/logger.js +7 -7
- package/src/Card/card-manager.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +1 -1
- package/src/Core/disable-sdk.js +5 -4
- package/src/Core/enable-sdk.js +1 -1
- package/src/Core/is-disabled.js +1 -1
- package/src/FeatureFlags/feature-flags-provider.js +12 -12
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +40 -34
- 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 +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +13 -13
- package/src/InAppMessage/models/slide-up-message.js +2 -2
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +2 -2
- package/src/Push/push-manager.js +82 -81
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +5 -5
- package/src/common/feed-display.js +82 -72
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/managers/auth-manager.js +18 -15
- package/src/managers/braze-instance.js +125 -109
- package/src/managers/device-manager.js +40 -35
- package/src/managers/network-manager.js +90 -81
- package/src/managers/server-config-manager.js +36 -34
- package/src/managers/session-manager.js +44 -37
- package/src/managers/storage-manager-factory.js +23 -16
- package/src/managers/storage-manager.js +251 -239
- package/src/managers/subscription-manager.js +10 -7
- package/src/managers/types.js +1 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +10 -4
- package/src/models/device.js +10 -18
- package/src/models/identifier.js +10 -11
- package/src/models/push-token.js +14 -9
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +32 -16
- package/src/models/types.js +1 -0
- package/src/request-controller.js +109 -109
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +60 -60
- package/src/triggers/models/in-app-message-click-data.js +9 -9
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +7 -7
- package/src/triggers/models/push-click-data.js +6 -6
- package/src/triggers/models/trigger-condition.js +46 -46
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +27 -27
- package/src/triggers/triggers-provider.js +126 -126
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +18 -18
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/device-constants.js +6 -6
- package/src/util/dom-utils.js +5 -5
- package/src/util/error-utils.js +2 -0
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +9 -9
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/window-utils.js +1 -1
|
@@ -11,40 +11,51 @@ import { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
|
11
11
|
import T from "../util/request-header-utils.js";
|
|
12
12
|
import { LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Ht } from "../common/constants.js";
|
|
13
13
|
export default class Pt {
|
|
14
|
-
constructor(t, e, s, i, r, o, n, a,
|
|
15
|
-
(this.
|
|
16
|
-
(this.
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
23
|
-
(this.
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
26
|
-
(this.
|
|
14
|
+
constructor(t, e, s, i, r, o, n, a, h, u, c) {
|
|
15
|
+
(this.Zr = t),
|
|
16
|
+
(this.u = e),
|
|
17
|
+
(this.jo = s),
|
|
18
|
+
(this.ft = i),
|
|
19
|
+
(this._e = r),
|
|
20
|
+
(this.wt = o),
|
|
21
|
+
(this.Xr = n),
|
|
22
|
+
(this.Do = a),
|
|
23
|
+
(this.Ro = h),
|
|
24
|
+
(this.Mo = u),
|
|
25
|
+
(this.appVersion = c),
|
|
26
|
+
(this.Zr = t),
|
|
27
|
+
(this.u = e),
|
|
28
|
+
(this.jo = s),
|
|
29
|
+
(this.ft = i),
|
|
30
|
+
(this._e = r),
|
|
31
|
+
(this.wt = o),
|
|
32
|
+
(this.Xr = n),
|
|
33
|
+
(this.Do = a),
|
|
34
|
+
(this.Ro = h),
|
|
35
|
+
(this.Mo = u),
|
|
36
|
+
(this.appVersion = c),
|
|
37
|
+
(this.ha = ["npm"]);
|
|
27
38
|
}
|
|
28
|
-
Gs(t, e) {
|
|
29
|
-
const s = this.
|
|
30
|
-
r = s.
|
|
31
|
-
o = this.
|
|
39
|
+
Gs(t, e = !1) {
|
|
40
|
+
const s = this.Zr.te(),
|
|
41
|
+
r = s.Xi(),
|
|
42
|
+
o = this.u.v(i.k.la);
|
|
32
43
|
ii(o, r) || (t.device = r),
|
|
33
|
-
(t.api_key = this.
|
|
44
|
+
(t.api_key = this.Xr),
|
|
34
45
|
(t.time = h(new Date().valueOf(), !0));
|
|
35
|
-
const n = this.
|
|
36
|
-
a = this.
|
|
46
|
+
const n = this.u.v(i.k.ua) || [],
|
|
47
|
+
a = this.u.v(i.k.ma) || "";
|
|
37
48
|
if (
|
|
38
|
-
(this.
|
|
39
|
-
(!ii(n, this.
|
|
40
|
-
(t.sdk_metadata = this.
|
|
41
|
-
(t.sdk_version = this.
|
|
42
|
-
this.
|
|
43
|
-
(t.app_version = this.
|
|
49
|
+
(this.ha.length > 0 &&
|
|
50
|
+
(!ii(n, this.ha) || a !== this._e.pa()) &&
|
|
51
|
+
(t.sdk_metadata = this.ha),
|
|
52
|
+
(t.sdk_version = this.Ro),
|
|
53
|
+
this.Mo && (t.sdk_flavor = this.Mo),
|
|
54
|
+
(t.app_version = this.appVersion),
|
|
44
55
|
(t.device_id = s.id),
|
|
45
56
|
e)
|
|
46
57
|
) {
|
|
47
|
-
const e = this.
|
|
58
|
+
const e = this.ft.getUserId();
|
|
48
59
|
null != e && (t.user_id = e);
|
|
49
60
|
}
|
|
50
61
|
return t;
|
|
@@ -55,7 +66,7 @@ export default class Pt {
|
|
|
55
66
|
if (!o && !n) return !0;
|
|
56
67
|
if (o) {
|
|
57
68
|
let e;
|
|
58
|
-
this.
|
|
69
|
+
this.jo.Ch();
|
|
59
70
|
const s = { errorCode: o.error_code };
|
|
60
71
|
for (const t of i)
|
|
61
72
|
p(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
|
|
@@ -67,12 +78,12 @@ export default class Pt {
|
|
|
67
78
|
n
|
|
68
79
|
? ((s.reason = n), (e = `due to ${n}`))
|
|
69
80
|
: (e = `with error code ${o.error_code}.`),
|
|
70
|
-
this.
|
|
81
|
+
this.jo.Zn() ||
|
|
71
82
|
(e +=
|
|
72
83
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
73
84
|
r.j.error(`SDK Authentication failed ${e}`),
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
85
|
+
this.Ra(t.events || [], t.attributes || []),
|
|
86
|
+
this.jo.wh(s),
|
|
76
87
|
!1
|
|
77
88
|
);
|
|
78
89
|
}
|
|
@@ -80,120 +91,118 @@ export default class Pt {
|
|
|
80
91
|
let i,
|
|
81
92
|
o = n;
|
|
82
93
|
switch (o) {
|
|
83
|
-
case qt.
|
|
94
|
+
case qt.ga:
|
|
84
95
|
return (
|
|
85
96
|
(i = "Received successful response with empty body."),
|
|
86
97
|
s.N(r.q.Is, { e: i }),
|
|
87
98
|
r.j.info(i),
|
|
88
99
|
!1
|
|
89
100
|
);
|
|
90
|
-
case qt.
|
|
101
|
+
case qt.qa:
|
|
91
102
|
return (
|
|
92
103
|
(i = "Received successful response with invalid JSON"),
|
|
93
104
|
s.N(r.q.Is, { e: i + ": " + e.response }),
|
|
94
105
|
r.j.info(i),
|
|
95
106
|
!1
|
|
96
107
|
);
|
|
97
|
-
case qt.
|
|
98
|
-
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.
|
|
108
|
+
case qt.ba:
|
|
109
|
+
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Do}`;
|
|
99
110
|
break;
|
|
100
|
-
case qt.
|
|
111
|
+
case qt.Aa:
|
|
101
112
|
o =
|
|
102
113
|
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
103
114
|
break;
|
|
104
|
-
case qt.
|
|
115
|
+
case qt.za:
|
|
105
116
|
o = "No device identifier. Please contact support@braze.com";
|
|
106
117
|
}
|
|
107
118
|
r.j.error("Backend error: " + o);
|
|
108
119
|
}
|
|
109
120
|
return !1;
|
|
110
121
|
}
|
|
111
|
-
|
|
122
|
+
Ba(t, e, s, i) {
|
|
112
123
|
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
|
|
113
124
|
}
|
|
114
|
-
|
|
125
|
+
Da(t, e, s, i) {
|
|
115
126
|
const r = [],
|
|
116
127
|
o = t => t || "",
|
|
117
|
-
n = o(this.
|
|
118
|
-
let a,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
l =
|
|
128
|
+
n = o(this.ft.getUserId());
|
|
129
|
+
let a = this.Wi(t, e);
|
|
130
|
+
const h = [],
|
|
131
|
+
u = [];
|
|
132
|
+
let c,
|
|
133
|
+
l = null;
|
|
123
134
|
if (s.length > 0) {
|
|
124
135
|
const t = [];
|
|
125
136
|
for (const e of s) {
|
|
126
|
-
if (((
|
|
127
|
-
if (n && !
|
|
128
|
-
|
|
137
|
+
if (((c = e.Xi()), this.jo.Zn())) {
|
|
138
|
+
if (n && !c.user_id) {
|
|
139
|
+
l || (l = {}), l.events || (l.events = []), l.events.push(c);
|
|
129
140
|
continue;
|
|
130
141
|
}
|
|
131
|
-
if (o(
|
|
132
|
-
u
|
|
142
|
+
if (o(c.user_id) !== n) {
|
|
143
|
+
u.push(c);
|
|
133
144
|
continue;
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
|
-
t.push(
|
|
147
|
+
t.push(c);
|
|
137
148
|
}
|
|
138
|
-
t.length > 0 && (
|
|
149
|
+
t.length > 0 && (a.events = t);
|
|
139
150
|
}
|
|
140
151
|
if (i.length > 0) {
|
|
141
152
|
const t = [];
|
|
142
153
|
for (const e of i)
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
: t.push(e);
|
|
146
|
-
t.length > 0 && (l.attributes = t);
|
|
154
|
+
this.jo.Zn() && o(e.user_id) !== n ? h.push(e) : t.push(e);
|
|
155
|
+
t.length > 0 && (a.attributes = t);
|
|
147
156
|
}
|
|
148
|
-
if ((this.
|
|
149
|
-
|
|
150
|
-
const t = { requestData:
|
|
157
|
+
if ((this.Ra(u, h), (a = this.Gs(a, !0)), l)) {
|
|
158
|
+
l = this.Gs(l, !1);
|
|
159
|
+
const t = { requestData: l, headers: this.Ks(l, T.Qs.Sa) };
|
|
151
160
|
r.push(t);
|
|
152
161
|
}
|
|
153
|
-
if (
|
|
154
|
-
const f = { requestData:
|
|
162
|
+
if (a && !this.Ba(a.events, a.attributes, t, e)) return l ? r : null;
|
|
163
|
+
const f = { requestData: a, headers: this.Ks(a, T.Qs.Sa) };
|
|
155
164
|
return r.push(f), r;
|
|
156
165
|
}
|
|
157
|
-
|
|
166
|
+
Ra(t, e) {
|
|
158
167
|
if (t) {
|
|
159
168
|
const e = [];
|
|
160
169
|
for (const s of t) {
|
|
161
170
|
const t = ue.fromJson(s);
|
|
162
171
|
(t.time = Xt(t.time)), e.push(t);
|
|
163
172
|
}
|
|
164
|
-
this.
|
|
173
|
+
this.u.co(e);
|
|
165
174
|
}
|
|
166
|
-
if (e) for (const t of e) this.
|
|
175
|
+
if (e) for (const t of e) this.u.va(t);
|
|
167
176
|
}
|
|
168
177
|
ii(t, e) {
|
|
169
178
|
let s = "HTTP error ";
|
|
170
179
|
null != t && (s += t + " "), (s += e), r.j.error(s);
|
|
171
180
|
}
|
|
172
181
|
qr(t) {
|
|
173
|
-
return s.N(r.q.
|
|
182
|
+
return s.N(r.q.ka, { n: t });
|
|
174
183
|
}
|
|
175
|
-
|
|
184
|
+
Wi(t, e, s) {
|
|
176
185
|
const i = {};
|
|
177
186
|
t && (i.feed = !0), e && (i.triggers = !0);
|
|
178
|
-
const r = null != s ? s : this.
|
|
187
|
+
const r = null != s ? s : this.ft.getUserId();
|
|
179
188
|
return (
|
|
180
189
|
r && (i.user_id = r),
|
|
181
|
-
(i.config = { config_time: this.
|
|
190
|
+
(i.config = { config_time: this.wt.oi() }),
|
|
182
191
|
{ respond_with: i }
|
|
183
192
|
);
|
|
184
193
|
}
|
|
185
|
-
|
|
194
|
+
Ta(t) {
|
|
186
195
|
const e = new Date().valueOf();
|
|
187
|
-
let s = Ht.toString()
|
|
188
|
-
|
|
196
|
+
let s = Ht.toString();
|
|
197
|
+
const i = T.Xa(this.u, t);
|
|
189
198
|
if (-1 !== i) {
|
|
190
199
|
s = (e - i).toString();
|
|
191
200
|
}
|
|
192
201
|
return s;
|
|
193
202
|
}
|
|
194
|
-
Ks(t, e, s) {
|
|
195
|
-
const r = [["X-Braze-Api-Key", this.
|
|
196
|
-
|
|
203
|
+
Ks(t, e, s = !1) {
|
|
204
|
+
const r = [["X-Braze-Api-Key", this.Xr]],
|
|
205
|
+
o = this.Ta(e);
|
|
197
206
|
r.push(["X-Braze-Last-Req-Ms-Ago", o]);
|
|
198
207
|
let n = !1;
|
|
199
208
|
if (
|
|
@@ -206,8 +215,8 @@ export default class Pt {
|
|
|
206
215
|
e === T.Qs.Os)
|
|
207
216
|
) {
|
|
208
217
|
r.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
209
|
-
let t = this.
|
|
210
|
-
(t && s) || ((t = 0), this.
|
|
218
|
+
let t = this.u.v(i.k.Fs);
|
|
219
|
+
(t && s) || ((t = 0), this.u.D(i.k.Fs, t)),
|
|
211
220
|
r.push(["BRAZE-SYNC-RETRY-COUNT", t.toString()]),
|
|
212
221
|
(n = !0);
|
|
213
222
|
}
|
|
@@ -215,9 +224,9 @@ export default class Pt {
|
|
|
215
224
|
(e === T.Qs.xi &&
|
|
216
225
|
(r.push(["X-Braze-FeatureFlagsRequest", "true"]), (n = !0)),
|
|
217
226
|
n && r.push(["X-Braze-DataRequest", "true"]),
|
|
218
|
-
this.
|
|
227
|
+
this.jo.Zn())
|
|
219
228
|
) {
|
|
220
|
-
const t = this.gh
|
|
229
|
+
const t = this.jo.gh();
|
|
221
230
|
null != t && r.push(["X-Braze-Auth-Signature", t]);
|
|
222
231
|
}
|
|
223
232
|
return r;
|
|
@@ -231,12 +240,12 @@ export default class Pt {
|
|
|
231
240
|
: e();
|
|
232
241
|
}
|
|
233
242
|
si() {
|
|
234
|
-
this.
|
|
243
|
+
this.jo.si();
|
|
235
244
|
}
|
|
236
245
|
Zs() {
|
|
237
|
-
return this.
|
|
246
|
+
return this.Do;
|
|
238
247
|
}
|
|
239
248
|
addSdkMetadata(t) {
|
|
240
|
-
for (const e of t) -1 === this.
|
|
249
|
+
for (const e of t) -1 === this.ha.indexOf(e) && this.ha.push(e);
|
|
241
250
|
}
|
|
242
251
|
}
|
|
@@ -4,31 +4,33 @@ import Kt from "../models/server-config.js";
|
|
|
4
4
|
import s from "../common/event-logger.js";
|
|
5
5
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
6
|
import {
|
|
7
|
-
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as
|
|
8
|
-
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as
|
|
7
|
+
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as Vt,
|
|
8
|
+
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Gt
|
|
9
9
|
} from "../common/constants.js";
|
|
10
10
|
export default class Mt {
|
|
11
11
|
constructor(t) {
|
|
12
|
-
(this.
|
|
12
|
+
(this.u = t),
|
|
13
|
+
(this.u = t),
|
|
13
14
|
(this.tl = new E()),
|
|
14
15
|
(this.el = new E()),
|
|
15
16
|
(this.sl = new E()),
|
|
16
|
-
(this.il = null)
|
|
17
|
+
(this.il = null),
|
|
18
|
+
(this.rl = null);
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
if (null == this.
|
|
20
|
-
const t = this.
|
|
21
|
-
this.
|
|
20
|
+
ll() {
|
|
21
|
+
if (null == this.rl) {
|
|
22
|
+
const t = this.u.v(i.k.hl);
|
|
23
|
+
this.rl = null != t ? Kt.zn(t) : new Kt();
|
|
22
24
|
}
|
|
23
|
-
return this.
|
|
25
|
+
return this.rl;
|
|
24
26
|
}
|
|
25
27
|
oi() {
|
|
26
|
-
return this.
|
|
28
|
+
return this.ll().ol;
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
ul(t) {
|
|
29
31
|
if (null != t && null != t.config) {
|
|
30
32
|
const e = t.config;
|
|
31
|
-
if (e.time > this.
|
|
33
|
+
if (e.time > this.ll().ol) {
|
|
32
34
|
const t = new Kt(
|
|
33
35
|
e.time,
|
|
34
36
|
e.events_blacklist,
|
|
@@ -40,22 +42,22 @@ export default class Mt {
|
|
|
40
42
|
e.feature_flags
|
|
41
43
|
);
|
|
42
44
|
let s = !1;
|
|
43
|
-
null != t.al && this.
|
|
45
|
+
null != t.al && this.Un() !== t.al && (s = !0);
|
|
44
46
|
let r = !1;
|
|
45
|
-
null != t.
|
|
47
|
+
null != t.ml.enabled && this.ni() !== t.ml.enabled && (r = !0);
|
|
46
48
|
let n = !1;
|
|
47
49
|
null != t.mi.enabled && this.bi() !== t.mi.enabled && (n = !0),
|
|
48
|
-
(this.
|
|
49
|
-
this.
|
|
50
|
+
(this.rl = t),
|
|
51
|
+
this.u.D(i.k.hl, t.ss()),
|
|
50
52
|
s && this.tl.Et(),
|
|
51
53
|
r && this.el.Et(),
|
|
52
54
|
n && this.sl.Et();
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return this.
|
|
58
|
+
Wn(t) {
|
|
59
|
+
const e = this.tl.lt(t);
|
|
60
|
+
return this.il && this.tl.removeSubscription(this.il), (this.il = e), e;
|
|
59
61
|
}
|
|
60
62
|
$s(t) {
|
|
61
63
|
return this.el.lt(t);
|
|
@@ -64,43 +66,43 @@ export default class Mt {
|
|
|
64
66
|
return this.sl.lt(t);
|
|
65
67
|
}
|
|
66
68
|
ge(t) {
|
|
67
|
-
return -1 !== this.
|
|
69
|
+
return -1 !== this.ll().cl.indexOf(t);
|
|
68
70
|
}
|
|
69
71
|
hu(t) {
|
|
70
|
-
return -1 !== this.
|
|
72
|
+
return -1 !== this.ll().gl.indexOf(t);
|
|
71
73
|
}
|
|
72
74
|
Dr(t) {
|
|
73
|
-
return -1 !== this.
|
|
75
|
+
return -1 !== this.ll().fl.indexOf(t);
|
|
74
76
|
}
|
|
75
77
|
dl() {
|
|
76
|
-
return this.
|
|
78
|
+
return this.ll().bl;
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
return this.
|
|
80
|
+
Un() {
|
|
81
|
+
return this.ll().al;
|
|
80
82
|
}
|
|
81
83
|
ni() {
|
|
82
|
-
return this.
|
|
84
|
+
return this.ll().ml.enabled || !1;
|
|
83
85
|
}
|
|
84
86
|
_s() {
|
|
85
|
-
const t = this.
|
|
87
|
+
const t = this.ll().ml.rate_limit;
|
|
86
88
|
return !(!t || null == t.enabled) && t.enabled;
|
|
87
89
|
}
|
|
88
90
|
fi() {
|
|
89
91
|
if (!this._s()) return -1;
|
|
90
|
-
const t = this.
|
|
91
|
-
return null == t.capacity ?
|
|
92
|
+
const t = this.ll().ml.rate_limit;
|
|
93
|
+
return null == t.capacity ? Vt : t.capacity <= 0 ? -1 : t.capacity;
|
|
92
94
|
}
|
|
93
95
|
di() {
|
|
94
96
|
if (!this._s()) return -1;
|
|
95
|
-
const t = this.
|
|
96
|
-
return null == t.refill_rate ?
|
|
97
|
+
const t = this.ll().ml.rate_limit;
|
|
98
|
+
return null == t.refill_rate ? Gt : t.refill_rate <= 0 ? -1 : t.refill_rate;
|
|
97
99
|
}
|
|
98
100
|
bi() {
|
|
99
|
-
return this.
|
|
101
|
+
return this.ll().mi.enabled && null == this.Si()
|
|
100
102
|
? (s.N(r.q.Is, { e: "Missing feature flag refresh_rate_limit." }), !1)
|
|
101
|
-
: this.
|
|
103
|
+
: this.ll().mi.enabled || !1;
|
|
102
104
|
}
|
|
103
105
|
Si() {
|
|
104
|
-
return this.
|
|
106
|
+
return this.ll().mi.refresh_rate_limit;
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -4,65 +4,72 @@ import _t from "../models/identifier.js";
|
|
|
4
4
|
import { convertMsToSeconds as h } from "../util/date-utils.js";
|
|
5
5
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
6
|
export default class Dt {
|
|
7
|
-
constructor(s, t,
|
|
8
|
-
(this.
|
|
9
|
-
(this.
|
|
10
|
-
(this.
|
|
11
|
-
(this.
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
constructor(s, t, i, e) {
|
|
8
|
+
(this.u = s),
|
|
9
|
+
(this.ft = t),
|
|
10
|
+
(this.wt = i),
|
|
11
|
+
(this.wl = e),
|
|
12
|
+
(this.u = s),
|
|
13
|
+
(this.ft = t),
|
|
14
|
+
(this.wt = i),
|
|
15
|
+
(this.Sl = 1e3),
|
|
16
|
+
(null == e || isNaN(e)) && (e = 1800),
|
|
17
|
+
e < this.Sl / 1e3 &&
|
|
15
18
|
(r.j.info(
|
|
16
19
|
"Specified session timeout of " +
|
|
17
|
-
|
|
20
|
+
e +
|
|
18
21
|
"s is too small, using the minimum session timeout of " +
|
|
19
|
-
this.
|
|
22
|
+
this.Sl / 1e3 +
|
|
20
23
|
"s instead."
|
|
21
24
|
),
|
|
22
|
-
(
|
|
23
|
-
(this.
|
|
25
|
+
(e = this.Sl / 1e3)),
|
|
26
|
+
(this.wl = e);
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
return new ue(this.
|
|
28
|
+
jl(s, t) {
|
|
29
|
+
return new ue(this.ft.getUserId(), r.q.xl, s, t.iu, { d: h(s - t.vl) });
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
const s = this.
|
|
31
|
+
pa() {
|
|
32
|
+
const s = this.u.tu(i.eu.Dl);
|
|
30
33
|
return null == s ? null : s.iu;
|
|
31
34
|
}
|
|
32
|
-
|
|
35
|
+
El() {
|
|
33
36
|
const s = new Date().valueOf(),
|
|
34
|
-
t = this.
|
|
35
|
-
e = this.
|
|
37
|
+
t = this.wt.dl(),
|
|
38
|
+
e = this.u.v(i.k.zl);
|
|
36
39
|
if (null != e && null == t) return !1;
|
|
37
|
-
|
|
38
|
-
return
|
|
40
|
+
let n = !1;
|
|
41
|
+
return (
|
|
42
|
+
null == e ? (n = !0) : null != t && (n = s - e > 1e3 * t),
|
|
43
|
+
n && this.u.D(i.k.zl, s),
|
|
44
|
+
n
|
|
45
|
+
);
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
return null == t || (!(s - t.
|
|
47
|
+
Cl(s, t) {
|
|
48
|
+
return null == t || null == t.Gl || (!(s - t.vl < this.Sl) && t.Gl < s);
|
|
42
49
|
}
|
|
43
50
|
bo() {
|
|
44
51
|
const s = new Date().valueOf(),
|
|
45
|
-
t = s + 1e3 * this.
|
|
46
|
-
e = this.
|
|
47
|
-
if (this.
|
|
52
|
+
t = s + 1e3 * this.wl,
|
|
53
|
+
e = this.u.tu(i.eu.Dl);
|
|
54
|
+
if (this.Cl(s, e)) {
|
|
48
55
|
let n = "Generating session start event with time " + s;
|
|
49
56
|
if (null != e) {
|
|
50
|
-
let s = e.
|
|
51
|
-
s - e.
|
|
52
|
-
this.
|
|
57
|
+
let s = e.Nl;
|
|
58
|
+
s - e.vl < this.Sl && (s = e.vl + this.Sl),
|
|
59
|
+
this.u.Hl(this.jl(s, e)),
|
|
53
60
|
(n += " (old session ended " + s + ")");
|
|
54
61
|
}
|
|
55
62
|
(n += ". Will expire " + t.valueOf()), r.j.info(n);
|
|
56
|
-
const
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
return null == this.
|
|
63
|
+
const l = new _t(r.Z.Y(), t);
|
|
64
|
+
this.u.Hl(new ue(this.ft.getUserId(), r.q.Wl, s, l.iu)),
|
|
65
|
+
this.u.uu(i.eu.Dl, l);
|
|
66
|
+
return null == this.u.v(i.k.zl) && this.u.D(i.k.zl, s), l.iu;
|
|
60
67
|
}
|
|
61
|
-
return (e.
|
|
68
|
+
if (null != e) return (e.Nl = s), (e.Gl = t), this.u.uu(i.eu.Dl, e), e.iu;
|
|
62
69
|
}
|
|
63
|
-
|
|
64
|
-
const s = this.
|
|
70
|
+
kl() {
|
|
71
|
+
const s = this.u.tu(i.eu.Dl);
|
|
65
72
|
null != s &&
|
|
66
|
-
(this.
|
|
73
|
+
(this.u.ql(i.eu.Dl), this.u.Hl(this.jl(new Date().valueOf(), s)));
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import O, { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
2
2
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
3
3
|
const Bt = {
|
|
4
|
-
|
|
4
|
+
$o: function(e, o = !1) {
|
|
5
5
|
let t = !1;
|
|
6
6
|
try {
|
|
7
7
|
if (localStorage && localStorage.getItem)
|
|
8
8
|
try {
|
|
9
|
-
localStorage.setItem(i.k.
|
|
10
|
-
localStorage.getItem(i.k.
|
|
11
|
-
(localStorage.removeItem(i.k.
|
|
9
|
+
localStorage.setItem(i.k.Ea, "true"),
|
|
10
|
+
localStorage.getItem(i.k.Ea) &&
|
|
11
|
+
(localStorage.removeItem(i.k.Ea), (t = !0));
|
|
12
12
|
} catch (e) {
|
|
13
13
|
if (
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
!(
|
|
15
|
+
e instanceof Error &&
|
|
16
|
+
("QuotaExceededError" === e.name ||
|
|
17
|
+
"NS_ERROR_DOM_QUOTA_REACHED" === e.name) &&
|
|
18
|
+
localStorage.length > 0
|
|
19
|
+
)
|
|
17
20
|
)
|
|
18
21
|
throw e;
|
|
19
22
|
t = !0;
|
|
@@ -21,15 +24,19 @@ const Bt = {
|
|
|
21
24
|
} catch (e) {
|
|
22
25
|
r.j.info("Local Storage not supported!");
|
|
23
26
|
}
|
|
24
|
-
const a = Bt.
|
|
25
|
-
|
|
26
|
-
let c
|
|
27
|
-
return (c = t ? new O.
|
|
27
|
+
const a = Bt.wa(),
|
|
28
|
+
n = new O._a(e, a && !o, t);
|
|
29
|
+
let c;
|
|
30
|
+
return (c = t ? new O.Oa(e) : new O.xa()), new O(n, c);
|
|
28
31
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
(document.cookie
|
|
32
|
+
wa: function() {
|
|
33
|
+
return (
|
|
34
|
+
navigator.cookieEnabled ||
|
|
35
|
+
("cookie" in document &&
|
|
36
|
+
(document.cookie.length > 0 ||
|
|
37
|
+
(document.cookie = "test").indexOf.call(document.cookie, "test") >
|
|
38
|
+
-1))
|
|
39
|
+
);
|
|
40
|
+
}
|
|
34
41
|
};
|
|
35
42
|
export default Bt;
|