@braze/web-sdk 5.4.0 → 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 +3 -3
- 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 +5 -5
- package/src/Card/card-manager.js +46 -42
- 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/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/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/Push/push-manager-factory.js +4 -4
- package/src/Push/push-manager.js +6 -6
- package/src/Push/utils/push-utils.js +1 -1
- package/src/User/user-manager.js +6 -6
- package/src/User/user.js +27 -27
- package/src/common/base-provider.js +1 -1
- package/src/common/event-logger.js +7 -7
- package/src/common/feed-display.js +1 -1
- package/src/managers/auth-manager.js +9 -9
- package/src/managers/braze-instance.js +44 -44
- package/src/managers/network-manager.js +100 -100
- package/src/managers/server-config-manager.js +24 -24
- package/src/managers/session-manager.js +10 -10
- package/src/managers/storage-manager.js +20 -20
- package/src/managers/subscription-manager.js +2 -2
- package/src/models/backend-errors.js +4 -4
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +5 -5
- package/src/request-controller.js +121 -121
- package/src/triggers/models/filter.js +9 -9
- package/src/triggers/models/trigger-condition.js +26 -26
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +7 -7
- package/src/triggers/triggers-provider.js +27 -27
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +17 -17
|
@@ -29,16 +29,16 @@ const L = {
|
|
|
29
29
|
_o: "baseUrl",
|
|
30
30
|
Io: "noCookies",
|
|
31
31
|
So: "devicePropertyAllowlist",
|
|
32
|
-
|
|
32
|
+
Aa: "disablePushTokenMaintenance",
|
|
33
33
|
Ao: "enableLogging",
|
|
34
34
|
No: "enableSdkAuthentication",
|
|
35
|
-
|
|
35
|
+
qa: "manageServiceWorkerExternally",
|
|
36
36
|
Oo: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
37
37
|
Ro: "sessionTimeoutInSeconds",
|
|
38
38
|
Po: "appVersion",
|
|
39
39
|
Lo: "appVersionNumber",
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
Ma: "serviceWorkerLocation",
|
|
41
|
+
ka: "safariWebsitePushId",
|
|
42
42
|
zn: "localization",
|
|
43
43
|
bo: "contentSecurityNonce",
|
|
44
44
|
Do: "allowUserSuppliedJavascript",
|
|
@@ -49,7 +49,7 @@ const L = {
|
|
|
49
49
|
Lh: "requireExplicitInAppMessageDismissal",
|
|
50
50
|
Mo: "doNotLoadFontAwesome",
|
|
51
51
|
Uo: "deviceId",
|
|
52
|
-
|
|
52
|
+
_a: "serviceWorkerScope",
|
|
53
53
|
Wo: "sdkFlavor",
|
|
54
54
|
};
|
|
55
55
|
class Vt {
|
|
@@ -59,12 +59,12 @@ class Vt {
|
|
|
59
59
|
(this.Vo = void 0),
|
|
60
60
|
(this.Ko = null),
|
|
61
61
|
(this.on = null),
|
|
62
|
+
(this.$t = null),
|
|
63
|
+
(this.Ui = null),
|
|
62
64
|
(this.qt = null),
|
|
63
|
-
(this.
|
|
64
|
-
(this.yt = null),
|
|
65
|
-
(this.ri = null),
|
|
65
|
+
(this.oi = null),
|
|
66
66
|
(this.u = null),
|
|
67
|
-
(this.
|
|
67
|
+
(this.yt = null),
|
|
68
68
|
(this.Go = ""),
|
|
69
69
|
(this.isInitialized = !1),
|
|
70
70
|
(this.$o = !1),
|
|
@@ -74,13 +74,13 @@ class Vt {
|
|
|
74
74
|
(this.Yo = []),
|
|
75
75
|
(this.Ho = []),
|
|
76
76
|
(this._e = []),
|
|
77
|
-
(this.Bo = "5.
|
|
77
|
+
(this.Bo = "5.5.0");
|
|
78
78
|
}
|
|
79
79
|
Xo(t) {
|
|
80
|
-
this.qo.
|
|
80
|
+
this.qo.Nt(t);
|
|
81
81
|
}
|
|
82
82
|
Sh(t) {
|
|
83
|
-
this.Jo.
|
|
83
|
+
this.Jo.Nt(t);
|
|
84
84
|
}
|
|
85
85
|
initialize(t, i) {
|
|
86
86
|
if (this.so())
|
|
@@ -157,20 +157,20 @@ class Vt {
|
|
|
157
157
|
this.u.uu(o.iu.Uo, t);
|
|
158
158
|
}
|
|
159
159
|
(this.on = new Ot(this.u, u)),
|
|
160
|
-
(this.
|
|
161
|
-
(this.
|
|
162
|
-
(this.
|
|
160
|
+
(this.qt = new Dt(this.u)),
|
|
161
|
+
(this.yt = new kt(this.qt, this.u)),
|
|
162
|
+
(this.oi = new Mt(this.u, this.yt, this.qt, this.nn(L.Ro)));
|
|
163
163
|
const f = new T();
|
|
164
164
|
return (
|
|
165
165
|
(this.Ko = new qt(this.u, this.nn(L.No), f)),
|
|
166
|
-
this
|
|
167
|
-
(this
|
|
166
|
+
this.Ht(f),
|
|
167
|
+
(this.$t = new Pt(
|
|
168
168
|
this.on,
|
|
169
169
|
this.u,
|
|
170
170
|
this.Ko,
|
|
171
|
-
this.wt,
|
|
172
|
-
this.ri,
|
|
173
171
|
this.yt,
|
|
172
|
+
this.oi,
|
|
173
|
+
this.qt,
|
|
174
174
|
this.rn,
|
|
175
175
|
this.Go,
|
|
176
176
|
this.Bo,
|
|
@@ -178,21 +178,21 @@ class Vt {
|
|
|
178
178
|
this.nn(L.Po),
|
|
179
179
|
this.nn(L.Lo),
|
|
180
180
|
)),
|
|
181
|
-
(this.
|
|
181
|
+
(this.Ui = new Lt(
|
|
182
182
|
this.rn,
|
|
183
183
|
this.Go,
|
|
184
|
-
this.
|
|
184
|
+
this.oi,
|
|
185
185
|
this.on,
|
|
186
|
-
this.wt,
|
|
187
186
|
this.yt,
|
|
187
|
+
this.qt,
|
|
188
188
|
this.u,
|
|
189
189
|
(t) => {
|
|
190
|
-
if (this.so()) for (const i of this.gr()) i.
|
|
190
|
+
if (this.so()) for (const i of this.gr()) i.Ss(t);
|
|
191
191
|
},
|
|
192
192
|
this.Ko,
|
|
193
|
-
this
|
|
193
|
+
this.$t,
|
|
194
194
|
)),
|
|
195
|
-
this.
|
|
195
|
+
this.Ui.initialize(),
|
|
196
196
|
a || this.u.Kh(),
|
|
197
197
|
r.info(
|
|
198
198
|
`Initialized for the Braze backend at "${this.nn(
|
|
@@ -200,25 +200,25 @@ class Vt {
|
|
|
200
200
|
)}" with API key "${this.rn}".`,
|
|
201
201
|
),
|
|
202
202
|
et.o(),
|
|
203
|
-
this.
|
|
203
|
+
this.qt.bi(() => {
|
|
204
204
|
var t;
|
|
205
205
|
this.isInitialized &&
|
|
206
|
-
(null === (t = this.
|
|
206
|
+
(null === (t = this.qt) || void 0 === t ? void 0 : t.mi()) &&
|
|
207
207
|
import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
|
|
208
208
|
if (!this.isInitialized) return;
|
|
209
209
|
(0, t.default)();
|
|
210
210
|
});
|
|
211
211
|
}),
|
|
212
|
-
this.
|
|
212
|
+
this.Ui.mr(() => {
|
|
213
213
|
var t;
|
|
214
214
|
this.isInitialized &&
|
|
215
|
-
(null === (t = this.
|
|
215
|
+
(null === (t = this.qt) || void 0 === t ? void 0 : t.mi()) &&
|
|
216
216
|
import("../FeatureFlags/refresh-feature-flags.js").then((t) => {
|
|
217
217
|
if (!this.isInitialized) return;
|
|
218
218
|
(0, t.default)(void 0, void 0, !0);
|
|
219
219
|
});
|
|
220
220
|
}),
|
|
221
|
-
this.qo.
|
|
221
|
+
this.qo.Rt(this.options),
|
|
222
222
|
(this.isInitialized = !0),
|
|
223
223
|
window.dispatchEvent(new CustomEvent("braze.initialized")),
|
|
224
224
|
!0
|
|
@@ -226,21 +226,21 @@ class Vt {
|
|
|
226
226
|
}
|
|
227
227
|
destroy(t) {
|
|
228
228
|
if ((r.destroy(), this.so())) {
|
|
229
|
-
this.Jo.
|
|
229
|
+
this.Jo.Rt(), this.Jo.removeAllSubscriptions();
|
|
230
230
|
for (const t of this.Yo) t.destroy();
|
|
231
231
|
this.Yo = [];
|
|
232
232
|
for (const t of this.Ho) t.clearData(!1);
|
|
233
233
|
(this.Ho = []),
|
|
234
234
|
this.removeAllSubscriptions(),
|
|
235
235
|
(this._e = []),
|
|
236
|
-
null != this.
|
|
237
|
-
(this.
|
|
236
|
+
null != this.Ui && this.Ui.destroy(),
|
|
237
|
+
(this.Ui = null),
|
|
238
238
|
(this.Ko = null),
|
|
239
239
|
(this.on = null),
|
|
240
|
+
(this.$t = null),
|
|
240
241
|
(this.qt = null),
|
|
242
|
+
(this.oi = null),
|
|
241
243
|
(this.yt = null),
|
|
242
|
-
(this.ri = null),
|
|
243
|
-
(this.wt = null),
|
|
244
244
|
(this.options = {}),
|
|
245
245
|
(this.Vo = void 0),
|
|
246
246
|
(this.isInitialized = !1),
|
|
@@ -257,14 +257,14 @@ class Vt {
|
|
|
257
257
|
Sr() {
|
|
258
258
|
return this.Ko;
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
Os() {
|
|
261
261
|
return this.Go;
|
|
262
262
|
}
|
|
263
263
|
te() {
|
|
264
264
|
return this.on;
|
|
265
265
|
}
|
|
266
266
|
nr() {
|
|
267
|
-
return this
|
|
267
|
+
return this.$t;
|
|
268
268
|
}
|
|
269
269
|
nn(t) {
|
|
270
270
|
return this.options[t];
|
|
@@ -273,22 +273,22 @@ class Vt {
|
|
|
273
273
|
return this.Ho;
|
|
274
274
|
}
|
|
275
275
|
cr() {
|
|
276
|
-
return this.
|
|
276
|
+
return this.Ui;
|
|
277
277
|
}
|
|
278
278
|
ir() {
|
|
279
|
-
return this.
|
|
279
|
+
return this.qt;
|
|
280
280
|
}
|
|
281
281
|
zr() {
|
|
282
|
-
return this.
|
|
282
|
+
return this.oi;
|
|
283
283
|
}
|
|
284
284
|
l() {
|
|
285
285
|
return this.u;
|
|
286
286
|
}
|
|
287
287
|
pr() {
|
|
288
|
-
if (this.
|
|
288
|
+
if (this.yt && this.Ui) return new User(this.yt, this.Ui);
|
|
289
289
|
}
|
|
290
290
|
er() {
|
|
291
|
-
return this.
|
|
291
|
+
return this.yt;
|
|
292
292
|
}
|
|
293
293
|
tr() {
|
|
294
294
|
return !0 === this.nn(L.Do);
|
|
@@ -303,7 +303,7 @@ class Vt {
|
|
|
303
303
|
for (const s of this.Ho) s.constructor === t.constructor && (i = !0);
|
|
304
304
|
t instanceof y && !i && this.Ho.push(t);
|
|
305
305
|
}
|
|
306
|
-
|
|
306
|
+
Ht(t) {
|
|
307
307
|
t instanceof T && this._e.push(t);
|
|
308
308
|
}
|
|
309
309
|
removeAllSubscriptions() {
|
|
@@ -321,7 +321,7 @@ class Vt {
|
|
|
321
321
|
$h() {
|
|
322
322
|
return this.$o;
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
ks() {
|
|
325
325
|
return this.Bo;
|
|
326
326
|
}
|
|
327
327
|
}
|
|
@@ -4,7 +4,7 @@ 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";
|
|
@@ -16,9 +16,9 @@ export default class Pt {
|
|
|
16
16
|
(this.on = t),
|
|
17
17
|
(this.u = e),
|
|
18
18
|
(this.Ko = i),
|
|
19
|
-
(this.
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
19
|
+
(this.yt = s),
|
|
20
|
+
(this.oi = r),
|
|
21
|
+
(this.qt = n),
|
|
22
22
|
(this.rn = o),
|
|
23
23
|
(this.Go = h),
|
|
24
24
|
(this.Bo = a),
|
|
@@ -29,9 +29,9 @@ export default class Pt {
|
|
|
29
29
|
(this.on = t),
|
|
30
30
|
(this.u = e),
|
|
31
31
|
(this.Ko = i),
|
|
32
|
-
(this.
|
|
33
|
-
(this.
|
|
34
|
-
(this.
|
|
32
|
+
(this.yt = s),
|
|
33
|
+
(this.oi = r),
|
|
34
|
+
(this.qt = n),
|
|
35
35
|
(this.rn = o),
|
|
36
36
|
(this.Go = h),
|
|
37
37
|
(this.Bo = a),
|
|
@@ -40,9 +40,9 @@ export default class Pt {
|
|
|
40
40
|
(this.Xh = c),
|
|
41
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.
|
|
45
|
+
r = s.Mr(),
|
|
46
46
|
n = this.u.j(o.C.Fa);
|
|
47
47
|
ii(n, r) || (t.device = r),
|
|
48
48
|
(t.api_key = this.rn),
|
|
@@ -51,7 +51,7 @@ export default class Pt {
|
|
|
51
51
|
u = this.u.j(o.C.Qh) || "";
|
|
52
52
|
if (
|
|
53
53
|
(this.Yh.length > 0 &&
|
|
54
|
-
(!ii(a, this.Yh) || u !== this.
|
|
54
|
+
(!ii(a, this.Yh) || u !== this.oi.xi()) &&
|
|
55
55
|
(t.sdk_metadata = this.Yh),
|
|
56
56
|
(t.sdk_version = this.Bo),
|
|
57
57
|
this.Vo && (t.sdk_flavor = this.Vo),
|
|
@@ -60,7 +60,7 @@ export default class Pt {
|
|
|
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
66
|
if (!t.user_id && !this.Ko.Fh()) {
|
|
@@ -69,29 +69,29 @@ export default class Pt {
|
|
|
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
|
|
77
|
+
let t;
|
|
78
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
|
-
: (
|
|
88
|
+
? ((i.reason = s), (t = `due to ${s}`))
|
|
89
|
+
: (t = `with error code ${o.error_code}.`),
|
|
90
90
|
this.Ko.Fh() ||
|
|
91
|
-
(
|
|
91
|
+
(t +=
|
|
92
92
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
93
|
-
r.error(`SDK Authentication failed ${
|
|
94
|
-
this.Zh(
|
|
93
|
+
r.error(`SDK Authentication failed ${t}`),
|
|
94
|
+
this.Zh(e.events || [], e.attributes || []),
|
|
95
95
|
this.Ko.qh(i),
|
|
96
96
|
!1
|
|
97
97
|
);
|
|
@@ -103,39 +103,39 @@ export default class Pt {
|
|
|
103
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 Pt {
|
|
|
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;
|
|
@@ -163,13 +163,13 @@ export default class Pt {
|
|
|
163
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.Zh(l, u), (a = 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) {
|
|
@@ -181,39 +181,39 @@ export default class Pt {
|
|
|
181
181
|
}
|
|
182
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.
|
|
196
|
+
const r = null != i ? i : this.yt.getUserId();
|
|
197
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,16 +223,16 @@ export default class Pt {
|
|
|
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
238
|
this.Ko.Fh())
|
|
@@ -242,76 +242,76 @@ export default class Pt {
|
|
|
242
242
|
}
|
|
243
243
|
return s;
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
Ja(t, e, i, s) {
|
|
246
246
|
window.setTimeout(() => {
|
|
247
247
|
r.info(`Retrying rate limited ${this.Hh(s)}SDK request.`),
|
|
248
|
-
this.
|
|
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
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
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,36 +319,36 @@ export default class Pt {
|
|
|
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.Ko.
|
|
348
|
+
Vs() {
|
|
349
|
+
this.Ko.Vs();
|
|
350
350
|
}
|
|
351
|
-
|
|
351
|
+
Os() {
|
|
352
352
|
return this.Go;
|
|
353
353
|
}
|
|
354
354
|
addSdkMetadata(t) {
|