@braze/web-sdk 6.0.0 → 6.1.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 +103 -33
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +22 -22
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +15 -15
- package/src/Banner/banner-factory.js +2 -1
- package/src/Banner/banner-provider-factory.js +7 -7
- package/src/Banner/banner-provider.js +92 -98
- package/src/Banner/banner.js +21 -18
- package/src/Banner/display/banner-to-html.js +9 -9
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +2 -2
- package/src/Banner/get-all-banners.js +5 -5
- package/src/Banner/get-banner.js +7 -7
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-impressions.js +9 -9
- package/src/Banner/request-banners-refresh.js +16 -20
- package/src/Banner/subscribe-to-banners-updates.js +7 -7
- package/src/Banner/ui/insert-banner.js +6 -6
- package/src/Card/card-manager-factory.js +7 -7
- package/src/Card/card-manager.js +35 -35
- package/src/Card/display/card-display.js +11 -11
- package/src/Card/log-card-dismissal.js +4 -4
- package/src/Card/log-content-card-click.js +4 -4
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +68 -68
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +18 -18
- package/src/Card/util/card-factory.js +35 -35
- package/src/ContentCards/content-cards-provider-factory.js +13 -13
- package/src/ContentCards/content-cards-provider.js +136 -136
- 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 +6 -6
- package/src/ContentCards/ui/show-content-cards.js +7 -7
- package/src/Core/add-sdk-metadata.js +3 -3
- package/src/Core/change-user.js +7 -7
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +8 -8
- package/src/Core/enable-sdk.js +6 -6
- package/src/Core/get-device-id.js +4 -4
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +10 -10
- package/src/Core/log-purchase.js +13 -13
- package/src/Core/open-session.js +10 -10
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +10 -10
- package/src/FeatureFlags/feature-flag.js +20 -71
- package/src/FeatureFlags/feature-flags-provider-factory.js +12 -12
- package/src/FeatureFlags/feature-flags-provider.js +87 -87
- package/src/FeatureFlags/get-all-feature-flags.js +4 -4
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/log-feature-flag-impression.js +9 -9
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +28 -28
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +15 -15
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +100 -100
- package/src/InAppMessage/log-in-app-message-button-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-click.js +6 -6
- package/src/InAppMessage/log-in-app-message-html-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-impression.js +4 -4
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +35 -35
- package/src/InAppMessage/models/html-message.js +21 -21
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +75 -75
- package/src/InAppMessage/models/modal-message.js +34 -34
- package/src/InAppMessage/models/slide-up-message.js +31 -31
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +19 -19
- package/src/Push/push-manager-factory.js +9 -9
- package/src/Push/push-manager.js +118 -118
- package/src/Push/utils/push-utils.js +9 -9
- package/src/User/user-manager.js +20 -20
- package/src/User/user.js +44 -45
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +18 -18
- package/src/common/event-logger.js +10 -10
- package/src/common/properties-base.js +56 -0
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +143 -143
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +172 -168
- package/src/managers/server-config-manager.js +73 -73
- package/src/managers/session-manager.js +40 -40
- package/src/managers/storage-manager-factory.js +6 -6
- package/src/managers/storage-manager.js +97 -97
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +5 -5
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +13 -13
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +159 -159
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +2 -2
- package/src/triggers/models/filter-set.js +6 -6
- package/src/triggers/models/filter.js +26 -26
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- 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 +1 -1
- package/src/triggers/models/trigger-condition.js +37 -37
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +16 -16
- package/src/triggers/triggers-provider-factory.js +12 -12
- package/src/triggers/triggers-provider.js +61 -61
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +6 -6
- package/src/util/browser-detector.js +20 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/device-constants.js +4 -4
- package/src/util/dom-utils.js +9 -9
- package/src/util/html-display-utils.js +7 -7
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +12 -12
- package/src/util/request-header-utils.js +22 -22
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +16 -16
- package/src/util/validation-utils.js +12 -12
- package/src/util/window-utils.js +2 -2
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "../util/date-utils.js";
|
|
7
7
|
import c from "../common/event-logger.js";
|
|
8
8
|
import { isArray as D, isEqual as ii } from "../util/code-utils.js";
|
|
9
|
-
import { logger as
|
|
9
|
+
import { logger as E, EventTypes as m } 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 {
|
|
@@ -16,66 +16,66 @@ import {
|
|
|
16
16
|
import { getAlias as ce } from "./utils.js";
|
|
17
17
|
import { readResponseHeaders as ve } from "../util/net.js";
|
|
18
18
|
export default class Mt {
|
|
19
|
-
constructor(t, e, i, s, r, n, o, a, h,
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
22
|
-
(this.
|
|
19
|
+
constructor(t, e, i, s, r, n, o, a, h, u, l, c) {
|
|
20
|
+
(this.on = t),
|
|
21
|
+
(this.j = e),
|
|
22
|
+
(this.Qh = i),
|
|
23
23
|
(this.Cs = s),
|
|
24
|
-
(this.
|
|
25
|
-
(this.
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
29
|
-
(this.
|
|
30
|
-
(this.appVersion =
|
|
31
|
-
(this
|
|
32
|
-
(this.
|
|
33
|
-
(this.
|
|
34
|
-
(this.
|
|
35
|
-
(this.
|
|
24
|
+
(this.C = r),
|
|
25
|
+
(this.h = n),
|
|
26
|
+
(this.sn = o),
|
|
27
|
+
(this.Ea = a),
|
|
28
|
+
(this.Xh = h),
|
|
29
|
+
(this.Zh = u),
|
|
30
|
+
(this.appVersion = l),
|
|
31
|
+
(this.$a = c),
|
|
32
|
+
(this.Xa = (t) => (null == t ? "" : `${t} `)),
|
|
33
|
+
(this.on = t),
|
|
34
|
+
(this.j = e),
|
|
35
|
+
(this.Qh = i),
|
|
36
36
|
(this.Cs = s),
|
|
37
|
-
(this.
|
|
38
|
-
(this.
|
|
39
|
-
(this.
|
|
40
|
-
(this.
|
|
41
|
-
(this.
|
|
42
|
-
(this.
|
|
43
|
-
(this.appVersion =
|
|
44
|
-
(this
|
|
45
|
-
(this.
|
|
46
|
-
(this.
|
|
37
|
+
(this.C = r),
|
|
38
|
+
(this.h = n),
|
|
39
|
+
(this.sn = o),
|
|
40
|
+
(this.Ea = a),
|
|
41
|
+
(this.Xh = h),
|
|
42
|
+
(this.Zh = u),
|
|
43
|
+
(this.appVersion = l),
|
|
44
|
+
(this.$a = c),
|
|
45
|
+
(this.Ya = ["npm"]),
|
|
46
|
+
(this.Za = {});
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
const r = this.
|
|
50
|
-
n = r.
|
|
51
|
-
o = this.
|
|
48
|
+
$(t, e = !1, i = !1) {
|
|
49
|
+
const r = this.on.fe(!i),
|
|
50
|
+
n = r.Ar(),
|
|
51
|
+
o = this.j.lt(s.ct.Qa);
|
|
52
52
|
ii(o, n) || (t.device = n),
|
|
53
|
-
(t.api_key = this.
|
|
53
|
+
(t.api_key = this.sn),
|
|
54
54
|
(t.time = X(new Date().valueOf(), !0));
|
|
55
|
-
const a = this.
|
|
56
|
-
h = this.
|
|
57
|
-
this.
|
|
58
|
-
(!ii(a, this.
|
|
59
|
-
(t.sdk_metadata = this.
|
|
60
|
-
(t.sdk_version = this.
|
|
61
|
-
this.
|
|
55
|
+
const a = this.j.lt(s.ct.au) || [],
|
|
56
|
+
h = this.j.lt(s.ct.du) || "";
|
|
57
|
+
this.Ya.length > 0 &&
|
|
58
|
+
(!ii(a, this.Ya) || h !== this.C.bt()) &&
|
|
59
|
+
(t.sdk_metadata = this.Ya),
|
|
60
|
+
(t.sdk_version = this.Xh),
|
|
61
|
+
this.Zh && (t.sdk_flavor = this.Zh),
|
|
62
62
|
(t.app_version = this.appVersion),
|
|
63
|
-
(t.app_version_code = this
|
|
63
|
+
(t.app_version_code = this.$a),
|
|
64
64
|
(t.device_id = r.id);
|
|
65
|
-
const
|
|
66
|
-
if ((e && null !==
|
|
67
|
-
const e = ce(this.
|
|
65
|
+
const u = this.Cs.getUserId();
|
|
66
|
+
if ((e && null !== u && (t.user_id = u), !u && !this.Qh.fh())) {
|
|
67
|
+
const e = ce(this.j);
|
|
68
68
|
e && (t.alias = e);
|
|
69
69
|
}
|
|
70
70
|
return t;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
Y(t, e, i) {
|
|
73
73
|
const s = e.auth_error,
|
|
74
74
|
r = e.error;
|
|
75
75
|
if (!s && !r) return !0;
|
|
76
76
|
if (s) {
|
|
77
77
|
let e;
|
|
78
|
-
this.
|
|
78
|
+
this.Qh.Gh();
|
|
79
79
|
const r = { errorCode: s.error_code };
|
|
80
80
|
for (const t of i)
|
|
81
81
|
D(t) && "X-Braze-Auth-Signature" === t[0] && (r.signature = t[1]);
|
|
@@ -87,12 +87,12 @@ export default class Mt {
|
|
|
87
87
|
n
|
|
88
88
|
? ((r.reason = n), (e = `due to ${n}`))
|
|
89
89
|
: (e = `with error code ${s.error_code}.`),
|
|
90
|
-
this.
|
|
90
|
+
this.Qh.fh() ||
|
|
91
91
|
(e +=
|
|
92
92
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
93
|
+
E.error(`SDK Authentication failed ${e}`),
|
|
94
|
+
this.fu(t.events || [], t.attributes || []),
|
|
95
|
+
this.Qh.yh(r),
|
|
96
96
|
!1
|
|
97
97
|
);
|
|
98
98
|
}
|
|
@@ -100,56 +100,56 @@ export default class Mt {
|
|
|
100
100
|
let i,
|
|
101
101
|
s = r;
|
|
102
102
|
switch (s) {
|
|
103
|
-
case Xt.
|
|
103
|
+
case Xt.vu:
|
|
104
104
|
return (
|
|
105
105
|
(i = "Received successful response with empty body."),
|
|
106
|
-
c.
|
|
107
|
-
|
|
106
|
+
c.rt(m.pu, { e: i }),
|
|
107
|
+
E.info(i),
|
|
108
108
|
!1
|
|
109
109
|
);
|
|
110
|
-
case Xt.
|
|
110
|
+
case Xt.Ru:
|
|
111
111
|
return (
|
|
112
112
|
(i = "Received successful response with invalid JSON"),
|
|
113
|
-
c.
|
|
114
|
-
|
|
113
|
+
c.rt(m.pu, { e: i + ": " + e.response }),
|
|
114
|
+
E.info(i),
|
|
115
115
|
!1
|
|
116
116
|
);
|
|
117
|
-
case Xt.
|
|
118
|
-
s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.
|
|
117
|
+
case Xt.gu:
|
|
118
|
+
s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Ea}`;
|
|
119
119
|
break;
|
|
120
|
-
case Xt.
|
|
120
|
+
case Xt.bu:
|
|
121
121
|
s =
|
|
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.qu:
|
|
125
125
|
s = "No device identifier. Please contact support@braze.com";
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
E.error("Backend error: " + s);
|
|
128
128
|
}
|
|
129
129
|
return !1;
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
Au(t, e, i) {
|
|
132
132
|
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i);
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
Du(t, e, i, s = !1) {
|
|
135
135
|
const r = [],
|
|
136
136
|
n = (t) => t || "",
|
|
137
137
|
o = n(this.Cs.getUserId());
|
|
138
|
-
let a = this.
|
|
139
|
-
const
|
|
140
|
-
|
|
138
|
+
let a = this.Mr(t);
|
|
139
|
+
const u = [],
|
|
140
|
+
l = [];
|
|
141
141
|
let c,
|
|
142
142
|
d = null;
|
|
143
143
|
if (e.length > 0) {
|
|
144
144
|
const t = [];
|
|
145
145
|
for (const i of e) {
|
|
146
|
-
if (((c = i.
|
|
146
|
+
if (((c = i.Ar()), this.Qh.fh())) {
|
|
147
147
|
if (o && !c.user_id) {
|
|
148
148
|
d || (d = {}), d.events || (d.events = []), d.events.push(c);
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
151
|
if (n(c.user_id) !== o) {
|
|
152
|
-
|
|
152
|
+
l.push(c);
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -160,123 +160,127 @@ export default class Mt {
|
|
|
160
160
|
if (i.length > 0) {
|
|
161
161
|
const t = [];
|
|
162
162
|
for (const e of i)
|
|
163
|
-
e && (this.
|
|
163
|
+
e && (this.Qh.fh() && n(e.user_id) !== o ? 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.fu(l, u), (a = this.$(a, !1, s)), d)) {
|
|
167
|
+
d = this.$(d, !1, s);
|
|
168
|
+
const t = { requestData: d, headers: this.A(d, h.H.Tu) };
|
|
169
169
|
r.push(t);
|
|
170
170
|
}
|
|
171
|
-
if (a && !this.
|
|
172
|
-
const f = { requestData: a, headers: this.
|
|
171
|
+
if (a && !this.Au(a.events, a.attributes, t)) return d ? r : null;
|
|
172
|
+
const f = { requestData: a, headers: this.A(a, h.H.Tu) };
|
|
173
173
|
return r.push(f), r;
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
fu(t, e) {
|
|
176
176
|
if (t) {
|
|
177
177
|
const e = [];
|
|
178
178
|
for (const i of t) {
|
|
179
179
|
const t = ue.fromJson(i);
|
|
180
180
|
(t.time = Yt(t.time)), e.push(t);
|
|
181
181
|
}
|
|
182
|
-
this.
|
|
182
|
+
this.j.Eo(e);
|
|
183
183
|
}
|
|
184
|
-
if (e) for (const t of e) this.
|
|
184
|
+
if (e) for (const t of e) this.j.ku(t);
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
_(t, e) {
|
|
187
187
|
let i = "HTTP error ";
|
|
188
|
-
null != t && (i += t + " "), (i += e),
|
|
188
|
+
null != t && (i += t + " "), (i += e), E.error(i);
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
return c.
|
|
190
|
+
yu(t) {
|
|
191
|
+
return c.rt(m.wu, { n: t });
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
Mr(t, e) {
|
|
194
194
|
const i = {};
|
|
195
195
|
t && (i.triggers = !0);
|
|
196
196
|
const s = null != e ? e : this.Cs.getUserId();
|
|
197
|
-
if ((s && (i.user_id = s), !i.user_id && !this.
|
|
198
|
-
const t = ce(this.
|
|
197
|
+
if ((s && (i.user_id = s), !i.user_id && !this.Qh.fh())) {
|
|
198
|
+
const t = ce(this.j);
|
|
199
199
|
t && (i.alias = t);
|
|
200
200
|
}
|
|
201
|
-
return (i.config = { config_time: this.
|
|
201
|
+
return (i.config = { config_time: this.h.Ft() }), { respond_with: i };
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
Nu(t) {
|
|
204
204
|
const e = new Date().valueOf();
|
|
205
205
|
let i = Zt.toString();
|
|
206
|
-
const s = h.
|
|
206
|
+
const s = h.Cu(this.j, t);
|
|
207
207
|
if (-1 !== s) {
|
|
208
208
|
i = (e - s).toString();
|
|
209
209
|
}
|
|
210
210
|
return i;
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
const s = [["X-Braze-Api-Key", this.
|
|
214
|
-
r = this.
|
|
212
|
+
A(t, e, i = !1) {
|
|
213
|
+
const s = [["X-Braze-Api-Key", this.sn]],
|
|
214
|
+
r = this.Nu(e);
|
|
215
215
|
s.push(["X-Braze-Last-Req-Ms-Ago", r]);
|
|
216
|
-
const n = h.
|
|
216
|
+
const n = h.Su(this.j, e).toString();
|
|
217
217
|
s.push(["X-Braze-Req-Attempt", n]);
|
|
218
218
|
let o = !1;
|
|
219
219
|
if (
|
|
220
220
|
(null != t.respond_with &&
|
|
221
221
|
t.respond_with.triggers &&
|
|
222
222
|
(s.push(["X-Braze-TriggersRequest", "true"]), (o = !0)),
|
|
223
|
-
e === h.
|
|
223
|
+
e === h.H.bi)
|
|
224
224
|
) {
|
|
225
225
|
s.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
226
|
-
let t = h.
|
|
227
|
-
(t && !i) || ((t = 1), h.
|
|
226
|
+
let t = h.Su(this.j, h.H.bi);
|
|
227
|
+
(t && !i) || ((t = 1), h.Bu(this.j, h.H.bi, t));
|
|
228
228
|
const e = Math.max(0, t - 1);
|
|
229
229
|
s.push(["BRAZE-SYNC-RETRY-COUNT", e.toString()]), (o = !0);
|
|
230
230
|
}
|
|
231
231
|
if (
|
|
232
|
-
(e === h.
|
|
232
|
+
(e === h.H.$e &&
|
|
233
233
|
(s.push(["X-Braze-FeatureFlagsRequest", "true"]), (o = !0)),
|
|
234
234
|
o && s.push(["X-Braze-DataRequest", "true"]),
|
|
235
|
-
this.
|
|
235
|
+
this.Qh.fh())
|
|
236
236
|
) {
|
|
237
|
-
const t = this.
|
|
237
|
+
const t = this.Qh.wh();
|
|
238
238
|
null != t && s.push(["X-Braze-Auth-Signature", t]);
|
|
239
239
|
}
|
|
240
240
|
return s;
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
zu(t, e, i, s) {
|
|
243
|
+
if (this.Za[s]) return;
|
|
243
244
|
const r = window.setTimeout(() => {
|
|
244
|
-
|
|
245
|
-
this.
|
|
245
|
+
E.info(`Retrying rate limited ${this.Xa(s)}SDK request.`),
|
|
246
|
+
this.J(e, i, s);
|
|
246
247
|
}, t);
|
|
247
|
-
this.
|
|
248
|
+
this.Za[s] = r;
|
|
248
249
|
}
|
|
249
250
|
fo() {
|
|
250
|
-
for (const t
|
|
251
|
-
|
|
251
|
+
for (const t in this.Za) {
|
|
252
|
+
const e = this.Za[t];
|
|
253
|
+
window.clearTimeout(e);
|
|
254
|
+
}
|
|
255
|
+
this.Za = {};
|
|
252
256
|
}
|
|
253
|
-
|
|
254
|
-
if (!this.
|
|
257
|
+
J(t, e, i, r) {
|
|
258
|
+
if (!this.ju(i))
|
|
255
259
|
return (
|
|
256
|
-
|
|
260
|
+
E.info(`${this.Xa(i)}SDK request being rate limited.`),
|
|
257
261
|
void ("function" == typeof r && r())
|
|
258
262
|
);
|
|
259
|
-
const n = this.
|
|
260
|
-
if (!n
|
|
263
|
+
const n = this.Mu();
|
|
264
|
+
if (!n.$u)
|
|
261
265
|
return (
|
|
262
|
-
|
|
263
|
-
|
|
266
|
+
this.zu(n.Xu, t, e, i),
|
|
267
|
+
void E.info(
|
|
268
|
+
`${this.Xa(
|
|
264
269
|
i,
|
|
265
270
|
)}SDK request being rate limited. Request will be retried in ${Math.trunc(
|
|
266
|
-
n.
|
|
271
|
+
n.Xu / 1e3,
|
|
267
272
|
)} seconds.`,
|
|
268
|
-
)
|
|
269
|
-
void this.wl(n.Bl, t, e, i)
|
|
273
|
+
)
|
|
270
274
|
);
|
|
271
|
-
this.
|
|
275
|
+
this.j.ft(s.ct.Lu, new Date().valueOf());
|
|
272
276
|
const o = t.device;
|
|
273
277
|
o && o.os_version instanceof Promise
|
|
274
278
|
? o.os_version.then((i) => {
|
|
275
|
-
(t.device.os_version = i), e(n.
|
|
279
|
+
(t.device.os_version = i), e(n.Eu);
|
|
276
280
|
})
|
|
277
|
-
: e(n.
|
|
281
|
+
: e(n.Eu);
|
|
278
282
|
}
|
|
279
|
-
|
|
283
|
+
Fu(t) {
|
|
280
284
|
const e = t ? ve(t) : null;
|
|
281
285
|
if (!e || !e["retry-after"]) return null;
|
|
282
286
|
const i = e["retry-after"];
|
|
@@ -287,21 +291,21 @@ export default class Mt {
|
|
|
287
291
|
{
|
|
288
292
|
const t =
|
|
289
293
|
"Received unexpected value for retry-after header in /sync response";
|
|
290
|
-
c.
|
|
294
|
+
c.rt(m.pu, { e: t + ": " + i });
|
|
291
295
|
}
|
|
292
296
|
return null;
|
|
293
297
|
}
|
|
294
|
-
|
|
295
|
-
if (h.
|
|
298
|
+
st(t, e, i, s, r, n) {
|
|
299
|
+
if (h.Su(this.j, i) >= he) return;
|
|
296
300
|
let o;
|
|
297
301
|
n = n || 0;
|
|
298
|
-
const a = this.
|
|
302
|
+
const a = this.Fu(t);
|
|
299
303
|
r();
|
|
300
|
-
const
|
|
304
|
+
const u = (t) => {
|
|
301
305
|
const r = window.setTimeout(() => {
|
|
302
306
|
e();
|
|
303
307
|
}, t);
|
|
304
|
-
s(r), h
|
|
308
|
+
s(r), h.Ku(this.j, i);
|
|
305
309
|
};
|
|
306
310
|
if (a && !isNaN(a.value)) {
|
|
307
311
|
switch (a.type) {
|
|
@@ -311,86 +315,86 @@ export default class Mt {
|
|
|
311
315
|
case "timestamp":
|
|
312
316
|
o = a.value + n;
|
|
313
317
|
}
|
|
314
|
-
|
|
315
|
-
} else n ?
|
|
318
|
+
u(o);
|
|
319
|
+
} else n ? u(n) : h.Ci(this.j, i);
|
|
316
320
|
}
|
|
317
|
-
|
|
321
|
+
Iu(t) {
|
|
318
322
|
var e;
|
|
319
|
-
null === (e = this.
|
|
323
|
+
null === (e = this.j) || void 0 === e || e.ft(s.ct.Pu, t);
|
|
320
324
|
}
|
|
321
|
-
|
|
322
|
-
let i = this.
|
|
323
|
-
null == i && (i = {}), (i[t] = e), this.
|
|
325
|
+
Uu(t, e) {
|
|
326
|
+
let i = this.xu();
|
|
327
|
+
null == i && (i = {}), (i[t] = e), this.j.ft(s.ct.Hu, i);
|
|
324
328
|
}
|
|
325
|
-
|
|
329
|
+
Ou() {
|
|
326
330
|
var t;
|
|
327
|
-
return null === (t = this.
|
|
331
|
+
return null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.Pu);
|
|
328
332
|
}
|
|
329
|
-
|
|
333
|
+
xu() {
|
|
330
334
|
var t;
|
|
331
|
-
return null === (t = this.
|
|
335
|
+
return null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.Hu);
|
|
332
336
|
}
|
|
333
|
-
|
|
337
|
+
Gu(t, e, i, s, r = "") {
|
|
334
338
|
let n;
|
|
335
339
|
if (r) {
|
|
336
|
-
const t = this.
|
|
340
|
+
const t = this.xu();
|
|
337
341
|
n = null == t || isNaN(t[r]) ? e : t[r];
|
|
338
|
-
} else (n = this.
|
|
342
|
+
} else (n = this.Ou()), (null == n || isNaN(n)) && (n = e);
|
|
339
343
|
const o = (t - s) / 1e3;
|
|
340
344
|
return (n = Math.min(n + o / i, e)), n;
|
|
341
345
|
}
|
|
342
|
-
|
|
346
|
+
_u(t, e) {
|
|
343
347
|
return Math.max(0, (1 - t) * e * 1e3);
|
|
344
348
|
}
|
|
345
|
-
|
|
349
|
+
Wu(t, e = "") {
|
|
346
350
|
var i, r, n, o, a;
|
|
347
|
-
const
|
|
348
|
-
if ((null == t && (t = !0), !t && !e)) return
|
|
349
|
-
let
|
|
351
|
+
const u = { $u: !0, Eu: -1, Xu: 0 };
|
|
352
|
+
if ((null == t && (t = !0), !t && !e)) return u;
|
|
353
|
+
let l,
|
|
350
354
|
c,
|
|
351
355
|
d = null;
|
|
352
|
-
if (t) d = null === (i = this.
|
|
356
|
+
if (t) d = null === (i = this.j) || void 0 === i ? void 0 : i.lt(s.ct.Lu);
|
|
353
357
|
else {
|
|
354
|
-
const t = h.
|
|
355
|
-
if (null == t || null == t[e]) return
|
|
358
|
+
const t = h.Yu(this.j);
|
|
359
|
+
if (null == t || null == t[e]) return u;
|
|
356
360
|
d = t[e];
|
|
357
361
|
}
|
|
358
|
-
if (null == d || isNaN(d)) return
|
|
362
|
+
if (null == d || isNaN(d)) return u;
|
|
359
363
|
if (
|
|
360
364
|
(t
|
|
361
|
-
? ((
|
|
362
|
-
(null === (r = this.
|
|
363
|
-
(c = (null === (n = this.
|
|
364
|
-
: ((
|
|
365
|
-
(null === (o = this.
|
|
365
|
+
? ((l =
|
|
366
|
+
(null === (r = this.h) || void 0 === r ? void 0 : r.Ju()) || -1),
|
|
367
|
+
(c = (null === (n = this.h) || void 0 === n ? void 0 : n.Qu()) || -1))
|
|
368
|
+
: ((l =
|
|
369
|
+
(null === (o = this.h) || void 0 === o ? void 0 : o.Vu(e)) || -1),
|
|
366
370
|
(c =
|
|
367
|
-
(null === (a = this.
|
|
368
|
-
-1 ===
|
|
371
|
+
(null === (a = this.h) || void 0 === a ? void 0 : a.Zu(e)) || -1)),
|
|
372
|
+
-1 === l || -1 === c)
|
|
369
373
|
)
|
|
370
|
-
return
|
|
374
|
+
return u;
|
|
371
375
|
const f = new Date().valueOf();
|
|
372
|
-
let m = this.
|
|
376
|
+
let m = this.Gu(f, l, c, d, e);
|
|
373
377
|
return m < 1
|
|
374
|
-
? ((
|
|
378
|
+
? ((u.$u = !1), (u.Xu = this._u(m, c)), u)
|
|
375
379
|
: ((m = Math.trunc(m) - 1),
|
|
376
|
-
(
|
|
377
|
-
t ? this.
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
Cl() {
|
|
381
|
-
return this.xl(!0);
|
|
380
|
+
(u.Eu = m),
|
|
381
|
+
t ? this.Iu(m) : this.Uu(e, m),
|
|
382
|
+
u);
|
|
382
383
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return !(e && !e.Sl);
|
|
384
|
+
Mu() {
|
|
385
|
+
return this.Wu(!0);
|
|
386
386
|
}
|
|
387
|
-
|
|
388
|
-
this.
|
|
387
|
+
ju(t) {
|
|
388
|
+
const e = this.Wu(!1, t);
|
|
389
|
+
return !(e && !e.$u);
|
|
389
390
|
}
|
|
390
391
|
Z() {
|
|
391
|
-
|
|
392
|
+
this.Qh.Z();
|
|
393
|
+
}
|
|
394
|
+
V() {
|
|
395
|
+
return this.Ea;
|
|
392
396
|
}
|
|
393
397
|
addSdkMetadata(t) {
|
|
394
|
-
for (const e of t) -1 === this.
|
|
398
|
+
for (const e of t) -1 === this.Ya.indexOf(e) && this.Ya.push(e);
|
|
395
399
|
}
|
|
396
400
|
}
|