@braze/web-sdk 5.9.1 → 6.0.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 +109 -253
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +24 -26
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +19 -19
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +21 -22
- package/src/Banner/display/banner-to-html.js +13 -25
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +11 -11
- package/src/Banner/index.js +0 -1
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +2 -2
- package/src/Banner/ui/insert-banner.js +7 -7
- package/src/Card/card-manager.js +35 -37
- package/src/Card/display/card-display.js +76 -74
- package/src/Card/index.js +0 -2
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +9 -2
- package/src/Card/log-content-card-impressions.js +11 -2
- package/src/Card/models/captioned-image.js +20 -20
- package/src/Card/models/card.js +110 -104
- package/src/Card/models/classic-card.js +20 -20
- package/src/Card/models/control-card.js +14 -14
- package/src/Card/models/image-only.js +19 -20
- package/src/Card/util/card-factory.js +57 -78
- package/src/ContentCards/content-cards-provider-factory.js +10 -10
- package/src/ContentCards/content-cards-provider.js +109 -109
- package/src/ContentCards/content-cards.js +21 -13
- 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 +5 -5
- package/src/ContentCards/ui/hide-content-cards.js +5 -5
- package/src/ContentCards/ui/show-content-cards.js +34 -34
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +7 -7
- package/src/Core/disable-sdk.js +6 -6
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +7 -7
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/log-custom-event.js +9 -9
- package/src/Core/log-purchase.js +7 -7
- package/src/Core/open-session.js +12 -12
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +7 -7
- package/src/FeatureFlags/feature-flag.js +6 -6
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +1 -1
- 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 +4 -4
- package/src/FeatureFlags/refresh-feature-flags.js +2 -2
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +37 -37
- package/src/InAppMessage/display/in-app-message-to-html.js +139 -133
- package/src/InAppMessage/display/modal-utils.js +39 -41
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +22 -14
- package/src/InAppMessage/in-app-message-manager.js +90 -88
- package/src/InAppMessage/log-in-app-message-button-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +40 -34
- package/src/InAppMessage/models/html-message.js +23 -21
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +137 -133
- package/src/InAppMessage/models/modal-message.js +39 -33
- package/src/InAppMessage/models/slide-up-message.js +36 -30
- 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 +56 -62
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +25 -15
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +55 -55
- package/src/common/content-cards-display.js +211 -0
- package/src/common/event-logger.js +6 -6
- package/src/index.js +0 -1
- package/src/l10n/l10n-manager-factory.js +9 -9
- package/src/l10n/l10n-manager.js +6 -6
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +136 -137
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +180 -183
- package/src/managers/server-config-manager.js +63 -63
- package/src/managers/session-manager.js +34 -34
- package/src/managers/storage-manager-factory.js +11 -11
- package/src/managers/storage-manager.js +139 -141
- package/src/managers/subscription-manager.js +3 -3
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +15 -15
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +13 -13
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +29 -29
- package/src/request-controller.js +175 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +7 -7
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +3 -3
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +47 -47
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +44 -44
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/banner-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +4 -4
- package/src/util/braze-actions.js +8 -14
- package/src/util/browser-detector.js +12 -12
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +14 -14
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +6 -6
- package/src/util/html-display-utils.js +37 -37
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +17 -17
- package/src/util/user-agent-parser.js +4 -4
- package/src/util/validation-utils.js +20 -20
- package/src/util/window-utils.js +1 -1
- package/src/Card/log-card-click.js +0 -11
- package/src/Card/log-card-impressions.js +0 -13
- package/src/Feed/feed-provider-factory.js +0 -18
- package/src/Feed/feed-provider.js +0 -90
- package/src/Feed/feed.js +0 -20
- package/src/Feed/get-cached-feed.js +0 -5
- package/src/Feed/index.js +0 -8
- package/src/Feed/log-feed-displayed.js +0 -7
- package/src/Feed/request-feed-refresh.js +0 -5
- package/src/Feed/subscribe-to-feed-updates.js +0 -5
- package/src/Feed/types.js +0 -1
- package/src/Feed/ui/hide-feed.js +0 -7
- package/src/Feed/ui/show-feed.js +0 -96
- package/src/Feed/ui/toggle-feed.js +0 -8
- package/src/common/base-feed.js +0 -29
- package/src/common/feed-display.js +0 -211
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
import Xt from "../models/backend-errors.js";
|
|
2
|
-
import
|
|
2
|
+
import ue from "../models/braze-event.js";
|
|
3
3
|
import {
|
|
4
|
-
convertMsToSeconds as
|
|
5
|
-
convertSecondsToMs as
|
|
4
|
+
convertMsToSeconds as X,
|
|
5
|
+
convertSecondsToMs as Yt,
|
|
6
6
|
} from "../util/date-utils.js";
|
|
7
7
|
import c from "../common/event-logger.js";
|
|
8
|
-
import { isArray as
|
|
8
|
+
import { isArray as D, isEqual as ii } from "../util/code-utils.js";
|
|
9
9
|
import { logger as N, EventTypes as d } 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 {
|
|
13
|
-
LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as
|
|
14
|
-
MAX_RETRY_COUNT_PER_REQUEST as
|
|
13
|
+
LAST_REQUEST_TO_ENDPOINT_MS_AGO_DEFAULT as Zt,
|
|
14
|
+
MAX_RETRY_COUNT_PER_REQUEST as he,
|
|
15
15
|
} from "../common/constants.js";
|
|
16
|
-
import { getAlias as
|
|
17
|
-
import { readResponseHeaders as
|
|
18
|
-
export default class
|
|
19
|
-
constructor(t, e, i, s, r, n, o, a, h,
|
|
20
|
-
(this.
|
|
16
|
+
import { getAlias as ce } from "./utils.js";
|
|
17
|
+
import { readResponseHeaders as ve } from "../util/net.js";
|
|
18
|
+
export default class Mt {
|
|
19
|
+
constructor(t, e, i, s, r, n, o, a, h, l, u, c) {
|
|
20
|
+
(this.un = t),
|
|
21
21
|
(this.C = e),
|
|
22
|
-
(this.
|
|
22
|
+
(this.Na = i),
|
|
23
23
|
(this.Cs = s),
|
|
24
24
|
(this.T = r),
|
|
25
25
|
(this.B = n),
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
29
|
-
(this.
|
|
30
|
-
(this.appVersion =
|
|
31
|
-
(this.
|
|
32
|
-
(this.
|
|
33
|
-
(this.
|
|
26
|
+
(this.on = o),
|
|
27
|
+
(this.Oa = a),
|
|
28
|
+
(this.Ia = h),
|
|
29
|
+
(this.Sa = l),
|
|
30
|
+
(this.appVersion = u),
|
|
31
|
+
(this.tl = c),
|
|
32
|
+
(this.el = (t) => (null == t ? "" : `${t} `)),
|
|
33
|
+
(this.un = t),
|
|
34
34
|
(this.C = e),
|
|
35
|
-
(this.
|
|
35
|
+
(this.Na = i),
|
|
36
36
|
(this.Cs = s),
|
|
37
37
|
(this.T = r),
|
|
38
38
|
(this.B = n),
|
|
39
|
-
(this.
|
|
40
|
-
(this.
|
|
41
|
-
(this.
|
|
42
|
-
(this.
|
|
43
|
-
(this.appVersion =
|
|
44
|
-
(this.
|
|
45
|
-
(this.
|
|
46
|
-
(this.
|
|
39
|
+
(this.on = o),
|
|
40
|
+
(this.Oa = a),
|
|
41
|
+
(this.Ia = h),
|
|
42
|
+
(this.Sa = l),
|
|
43
|
+
(this.appVersion = u),
|
|
44
|
+
(this.tl = c),
|
|
45
|
+
(this.il = ["npm"]),
|
|
46
|
+
(this.sl = []);
|
|
47
47
|
}
|
|
48
48
|
H(t, e = !1, i = !1) {
|
|
49
|
-
const r = this.
|
|
50
|
-
n = r.
|
|
51
|
-
o = this.C.ft(s.gt.
|
|
49
|
+
const r = this.un.ve(!i),
|
|
50
|
+
n = r.Tr(),
|
|
51
|
+
o = this.C.ft(s.gt.Za);
|
|
52
52
|
ii(o, n) || (t.device = n),
|
|
53
|
-
(t.api_key = this.
|
|
54
|
-
(t.time =
|
|
55
|
-
const a = this.C.ft(s.gt.
|
|
56
|
-
h = this.C.ft(s.gt.
|
|
57
|
-
this.
|
|
58
|
-
(!ii(a, this.
|
|
59
|
-
(t.sdk_metadata = this.
|
|
60
|
-
(t.sdk_version = this.
|
|
61
|
-
this.
|
|
53
|
+
(t.api_key = this.on),
|
|
54
|
+
(t.time = X(new Date().valueOf(), !0));
|
|
55
|
+
const a = this.C.ft(s.gt.rl) || [],
|
|
56
|
+
h = this.C.ft(s.gt.ol) || "";
|
|
57
|
+
this.il.length > 0 &&
|
|
58
|
+
(!ii(a, this.il) || h !== this.T.St()) &&
|
|
59
|
+
(t.sdk_metadata = this.il),
|
|
60
|
+
(t.sdk_version = this.Ia),
|
|
61
|
+
this.Sa && (t.sdk_flavor = this.Sa),
|
|
62
62
|
(t.app_version = this.appVersion),
|
|
63
|
-
(t.app_version_code = this.
|
|
63
|
+
(t.app_version_code = this.tl),
|
|
64
64
|
(t.device_id = r.id);
|
|
65
|
-
const
|
|
66
|
-
if ((e && null !==
|
|
67
|
-
const e =
|
|
65
|
+
const l = this.Cs.getUserId();
|
|
66
|
+
if ((e && null !== l && (t.user_id = l), !l && !this.Na.wh())) {
|
|
67
|
+
const e = ce(this.C);
|
|
68
68
|
e && (t.alias = e);
|
|
69
69
|
}
|
|
70
70
|
return t;
|
|
@@ -75,10 +75,10 @@ export default class Pt {
|
|
|
75
75
|
if (!s && !r) return !0;
|
|
76
76
|
if (s) {
|
|
77
77
|
let e;
|
|
78
|
-
this.
|
|
78
|
+
this.Na.Hh();
|
|
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]);
|
|
82
82
|
t.respond_with && t.respond_with.user_id
|
|
83
83
|
? (r.userId = t.respond_with.user_id)
|
|
84
84
|
: t.user_id && (r.userId = t.user_id);
|
|
@@ -87,12 +87,12 @@ export default class Pt {
|
|
|
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.Na.wh() ||
|
|
91
91
|
(e +=
|
|
92
92
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
93
93
|
N.error(`SDK Authentication failed ${e}`),
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
94
|
+
this.al(t.events || [], t.attributes || []),
|
|
95
|
+
this.Na.Bh(r),
|
|
96
96
|
!1
|
|
97
97
|
);
|
|
98
98
|
}
|
|
@@ -100,134 +100,131 @@ export default class Pt {
|
|
|
100
100
|
let i,
|
|
101
101
|
s = r;
|
|
102
102
|
switch (s) {
|
|
103
|
-
case Xt.
|
|
103
|
+
case Xt.hl:
|
|
104
104
|
return (
|
|
105
105
|
(i = "Received successful response with empty body."),
|
|
106
|
-
c.ut(d.
|
|
106
|
+
c.ut(d.ul, { e: i }),
|
|
107
107
|
N.info(i),
|
|
108
108
|
!1
|
|
109
109
|
);
|
|
110
|
-
case Xt.
|
|
110
|
+
case Xt.cl:
|
|
111
111
|
return (
|
|
112
112
|
(i = "Received successful response with invalid JSON"),
|
|
113
|
-
c.ut(d.
|
|
113
|
+
c.ut(d.ul, { e: i + ": " + e.response }),
|
|
114
114
|
N.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.dl:
|
|
118
|
+
s = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Oa}`;
|
|
119
119
|
break;
|
|
120
|
-
case Xt.
|
|
120
|
+
case Xt.fl:
|
|
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.ml:
|
|
125
125
|
s = "No device identifier. Please contact support@braze.com";
|
|
126
126
|
}
|
|
127
127
|
N.error("Backend error: " + s);
|
|
128
128
|
}
|
|
129
129
|
return !1;
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i
|
|
131
|
+
vl(t, e, i) {
|
|
132
|
+
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || i);
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let
|
|
134
|
+
Rl(t, e, i, s = !1) {
|
|
135
|
+
const r = [],
|
|
136
|
+
n = (t) => t || "",
|
|
137
|
+
o = n(this.Cs.getUserId());
|
|
138
|
+
let a = this.Ar(t);
|
|
139
139
|
const l = [],
|
|
140
|
-
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
if (
|
|
140
|
+
u = [];
|
|
141
|
+
let c,
|
|
142
|
+
d = null;
|
|
143
|
+
if (e.length > 0) {
|
|
144
144
|
const t = [];
|
|
145
|
-
for (const
|
|
146
|
-
if (((
|
|
147
|
-
if (
|
|
148
|
-
|
|
145
|
+
for (const i of e) {
|
|
146
|
+
if (((c = i.Tr()), this.Na.wh())) {
|
|
147
|
+
if (o && !c.user_id) {
|
|
148
|
+
d || (d = {}), d.events || (d.events = []), d.events.push(c);
|
|
149
149
|
continue;
|
|
150
150
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
151
|
+
if (n(c.user_id) !== o) {
|
|
152
|
+
u.push(c);
|
|
153
153
|
continue;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
t.push(
|
|
156
|
+
t.push(c);
|
|
157
157
|
}
|
|
158
|
-
t.length > 0 && (
|
|
158
|
+
t.length > 0 && (a.events = t);
|
|
159
159
|
}
|
|
160
|
-
if (
|
|
160
|
+
if (i.length > 0) {
|
|
161
161
|
const t = [];
|
|
162
|
-
for (const e of
|
|
163
|
-
e && (this.
|
|
164
|
-
t.length > 0 && (
|
|
162
|
+
for (const e of i)
|
|
163
|
+
e && (this.Na.wh() && n(e.user_id) !== o ? l.push(e) : t.push(e));
|
|
164
|
+
t.length > 0 && (a.attributes = t);
|
|
165
165
|
}
|
|
166
|
-
if ((this.
|
|
167
|
-
|
|
168
|
-
const t = { requestData:
|
|
169
|
-
|
|
166
|
+
if ((this.al(u, l), (a = this.H(a, !1, s)), d)) {
|
|
167
|
+
d = this.H(d, !1, s);
|
|
168
|
+
const t = { requestData: d, headers: this.J(d, h.O.gl) };
|
|
169
|
+
r.push(t);
|
|
170
170
|
}
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
return
|
|
171
|
+
if (a && !this.vl(a.events, a.attributes, t)) return d ? r : null;
|
|
172
|
+
const f = { requestData: a, headers: this.J(a, h.O.gl) };
|
|
173
|
+
return r.push(f), r;
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
al(t, e) {
|
|
176
176
|
if (t) {
|
|
177
177
|
const e = [];
|
|
178
178
|
for (const i of t) {
|
|
179
|
-
const t =
|
|
180
|
-
(t.time =
|
|
179
|
+
const t = ue.fromJson(i);
|
|
180
|
+
(t.time = Yt(t.time)), e.push(t);
|
|
181
181
|
}
|
|
182
|
-
this.C.
|
|
182
|
+
this.C.Wo(e);
|
|
183
183
|
}
|
|
184
|
-
if (e) for (const t of e) this.C.
|
|
184
|
+
if (e) for (const t of e) this.C.bl(t);
|
|
185
185
|
}
|
|
186
186
|
et(t, e) {
|
|
187
187
|
let i = "HTTP error ";
|
|
188
188
|
null != t && (i += t + " "), (i += e), N.error(i);
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
return c.ut(d.
|
|
190
|
+
ql(t) {
|
|
191
|
+
return c.ut(d.Al, { n: t });
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
t && (
|
|
196
|
-
const
|
|
197
|
-
if ((
|
|
198
|
-
const t =
|
|
199
|
-
t && (
|
|
193
|
+
Ar(t, e) {
|
|
194
|
+
const i = {};
|
|
195
|
+
t && (i.triggers = !0);
|
|
196
|
+
const s = null != e ? e : this.Cs.getUserId();
|
|
197
|
+
if ((s && (i.user_id = s), !i.user_id && !this.Na.wh())) {
|
|
198
|
+
const t = ce(this.C);
|
|
199
|
+
t && (i.alias = t);
|
|
200
200
|
}
|
|
201
|
-
return (
|
|
201
|
+
return (i.config = { config_time: this.B.Et() }), { respond_with: i };
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
Dl(t) {
|
|
204
204
|
const e = new Date().valueOf();
|
|
205
|
-
let i =
|
|
206
|
-
const s = h.
|
|
205
|
+
let i = Zt.toString();
|
|
206
|
+
const s = h.Tl(this.C, t);
|
|
207
207
|
if (-1 !== s) {
|
|
208
208
|
i = (e - s).toString();
|
|
209
209
|
}
|
|
210
210
|
return i;
|
|
211
211
|
}
|
|
212
212
|
J(t, e, i = !1) {
|
|
213
|
-
const s = [["X-Braze-Api-Key", this.
|
|
214
|
-
r = this.
|
|
213
|
+
const s = [["X-Braze-Api-Key", this.on]],
|
|
214
|
+
r = this.Dl(e);
|
|
215
215
|
s.push(["X-Braze-Last-Req-Ms-Ago", r]);
|
|
216
|
-
const n = h.
|
|
216
|
+
const n = h.kl(this.C, 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
|
-
|
|
224
|
-
t.respond_with.feed &&
|
|
225
|
-
(s.push(["X-Braze-FeedRequest", "true"]), (o = !0)),
|
|
226
|
-
e === h.O.wi)
|
|
223
|
+
e === h.O.vi)
|
|
227
224
|
) {
|
|
228
225
|
s.push(["X-Braze-ContentCardsRequest", "true"]);
|
|
229
|
-
let t = h.
|
|
230
|
-
(t && !i) || ((t = 1), h.
|
|
226
|
+
let t = h.kl(this.C, h.O.vi);
|
|
227
|
+
(t && !i) || ((t = 1), h.yl(this.C, h.O.vi, t));
|
|
231
228
|
const e = Math.max(0, t - 1);
|
|
232
229
|
s.push(["BRAZE-SYNC-RETRY-COUNT", e.toString()]), (o = !0);
|
|
233
230
|
}
|
|
@@ -235,52 +232,52 @@ export default class Pt {
|
|
|
235
232
|
(e === h.O.Le &&
|
|
236
233
|
(s.push(["X-Braze-FeatureFlagsRequest", "true"]), (o = !0)),
|
|
237
234
|
o && s.push(["X-Braze-DataRequest", "true"]),
|
|
238
|
-
this.
|
|
235
|
+
this.Na.wh())
|
|
239
236
|
) {
|
|
240
|
-
const t = this.
|
|
237
|
+
const t = this.Na.jh();
|
|
241
238
|
null != t && s.push(["X-Braze-Auth-Signature", t]);
|
|
242
239
|
}
|
|
243
240
|
return s;
|
|
244
241
|
}
|
|
245
|
-
|
|
242
|
+
wl(t, e, i, s) {
|
|
246
243
|
const r = window.setTimeout(() => {
|
|
247
|
-
N.info(`Retrying rate limited ${this.
|
|
244
|
+
N.info(`Retrying rate limited ${this.el(s)}SDK request.`),
|
|
248
245
|
this.V(e, i, s);
|
|
249
246
|
}, t);
|
|
250
|
-
this.
|
|
247
|
+
this.sl.push(r);
|
|
251
248
|
}
|
|
252
249
|
fo() {
|
|
253
|
-
for (const t of this.
|
|
254
|
-
this.
|
|
250
|
+
for (const t of this.sl) window.clearTimeout(t);
|
|
251
|
+
this.sl = [];
|
|
255
252
|
}
|
|
256
253
|
V(t, e, i, r) {
|
|
257
|
-
if (!this
|
|
254
|
+
if (!this.Nl(i))
|
|
258
255
|
return (
|
|
259
|
-
N.info(`${this.
|
|
256
|
+
N.info(`${this.el(i)}SDK request being rate limited.`),
|
|
260
257
|
void ("function" == typeof r && r())
|
|
261
258
|
);
|
|
262
|
-
const n = this.
|
|
263
|
-
if (!n.
|
|
259
|
+
const n = this.Cl();
|
|
260
|
+
if (!n.Sl)
|
|
264
261
|
return (
|
|
265
262
|
N.info(
|
|
266
|
-
`${this.
|
|
263
|
+
`${this.el(
|
|
267
264
|
i,
|
|
268
265
|
)}SDK request being rate limited. Request will be retried in ${Math.trunc(
|
|
269
|
-
n.
|
|
266
|
+
n.Bl / 1e3,
|
|
270
267
|
)} seconds.`,
|
|
271
268
|
),
|
|
272
|
-
void this.
|
|
269
|
+
void this.wl(n.Bl, t, e, i)
|
|
273
270
|
);
|
|
274
|
-
this.C.Bt(s.gt.
|
|
271
|
+
this.C.Bt(s.gt.zl, new Date().valueOf());
|
|
275
272
|
const o = t.device;
|
|
276
273
|
o && o.os_version instanceof Promise
|
|
277
274
|
? o.os_version.then((i) => {
|
|
278
|
-
(t.device.os_version = i), e(n.
|
|
275
|
+
(t.device.os_version = i), e(n.jl);
|
|
279
276
|
})
|
|
280
|
-
: e(n.
|
|
277
|
+
: e(n.jl);
|
|
281
278
|
}
|
|
282
|
-
|
|
283
|
-
const e = t ?
|
|
279
|
+
Ml(t) {
|
|
280
|
+
const e = t ? ve(t) : null;
|
|
284
281
|
if (!e || !e["retry-after"]) return null;
|
|
285
282
|
const i = e["retry-after"];
|
|
286
283
|
if (isNaN(i) && !isNaN(Date.parse(i)))
|
|
@@ -290,21 +287,21 @@ export default class Pt {
|
|
|
290
287
|
{
|
|
291
288
|
const t =
|
|
292
289
|
"Received unexpected value for retry-after header in /sync response";
|
|
293
|
-
c.ut(d.
|
|
290
|
+
c.ut(d.ul, { e: t + ": " + i });
|
|
294
291
|
}
|
|
295
292
|
return null;
|
|
296
293
|
}
|
|
297
294
|
rt(t, e, i, s, r, n) {
|
|
298
|
-
if (h.
|
|
295
|
+
if (h.kl(this.C, i) >= he) return;
|
|
299
296
|
let o;
|
|
300
297
|
n = n || 0;
|
|
301
|
-
const a = this.
|
|
298
|
+
const a = this.Ml(t);
|
|
302
299
|
r();
|
|
303
|
-
const
|
|
300
|
+
const l = (t) => {
|
|
304
301
|
const r = window.setTimeout(() => {
|
|
305
302
|
e();
|
|
306
303
|
}, t);
|
|
307
|
-
s(r), h
|
|
304
|
+
s(r), h.$l(this.C, i);
|
|
308
305
|
};
|
|
309
306
|
if (a && !isNaN(a.value)) {
|
|
310
307
|
switch (a.type) {
|
|
@@ -314,86 +311,86 @@ export default class Pt {
|
|
|
314
311
|
case "timestamp":
|
|
315
312
|
o = a.value + n;
|
|
316
313
|
}
|
|
317
|
-
|
|
318
|
-
} else n ?
|
|
314
|
+
l(o);
|
|
315
|
+
} else n ? l(n) : h.bi(this.C, i);
|
|
319
316
|
}
|
|
320
|
-
|
|
317
|
+
Xl(t) {
|
|
321
318
|
var e;
|
|
322
|
-
null === (e = this.C) || void 0 === e || e.Bt(s.gt.
|
|
319
|
+
null === (e = this.C) || void 0 === e || e.Bt(s.gt.Ll, t);
|
|
323
320
|
}
|
|
324
|
-
|
|
325
|
-
let i = this.
|
|
326
|
-
null == i && (i = {}), (i[t] = e), this.C.Bt(s.gt.
|
|
321
|
+
El(t, e) {
|
|
322
|
+
let i = this.Fl();
|
|
323
|
+
null == i && (i = {}), (i[t] = e), this.C.Bt(s.gt.Kl, i);
|
|
327
324
|
}
|
|
328
|
-
|
|
325
|
+
Il() {
|
|
329
326
|
var t;
|
|
330
|
-
return null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.
|
|
327
|
+
return null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.Ll);
|
|
331
328
|
}
|
|
332
|
-
|
|
329
|
+
Fl() {
|
|
333
330
|
var t;
|
|
334
|
-
return null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.
|
|
331
|
+
return null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.Kl);
|
|
335
332
|
}
|
|
336
|
-
|
|
333
|
+
Pl(t, e, i, s, r = "") {
|
|
337
334
|
let n;
|
|
338
335
|
if (r) {
|
|
339
|
-
const t = this.
|
|
336
|
+
const t = this.Fl();
|
|
340
337
|
n = null == t || isNaN(t[r]) ? e : t[r];
|
|
341
|
-
} else (n = this.
|
|
338
|
+
} else (n = this.Il()), (null == n || isNaN(n)) && (n = e);
|
|
342
339
|
const o = (t - s) / 1e3;
|
|
343
340
|
return (n = Math.min(n + o / i, e)), n;
|
|
344
341
|
}
|
|
345
|
-
|
|
342
|
+
Ul(t, e) {
|
|
346
343
|
return Math.max(0, (1 - t) * e * 1e3);
|
|
347
344
|
}
|
|
348
|
-
|
|
345
|
+
xl(t, e = "") {
|
|
349
346
|
var i, r, n, o, a;
|
|
350
|
-
const
|
|
351
|
-
if ((null == t && (t = !0), !t && !e)) return
|
|
352
|
-
let
|
|
347
|
+
const l = { Sl: !0, jl: -1, Bl: 0 };
|
|
348
|
+
if ((null == t && (t = !0), !t && !e)) return l;
|
|
349
|
+
let u,
|
|
353
350
|
c,
|
|
354
351
|
d = null;
|
|
355
|
-
if (t) d = null === (i = this.C) || void 0 === i ? void 0 : i.ft(s.gt.
|
|
352
|
+
if (t) d = null === (i = this.C) || void 0 === i ? void 0 : i.ft(s.gt.zl);
|
|
356
353
|
else {
|
|
357
|
-
const t = h.
|
|
358
|
-
if (null == t || null == t[e]) return
|
|
354
|
+
const t = h.Hl(this.C);
|
|
355
|
+
if (null == t || null == t[e]) return l;
|
|
359
356
|
d = t[e];
|
|
360
357
|
}
|
|
361
|
-
if (null == d || isNaN(d)) return
|
|
358
|
+
if (null == d || isNaN(d)) return l;
|
|
362
359
|
if (
|
|
363
360
|
(t
|
|
364
|
-
? ((
|
|
365
|
-
(null === (r = this.B) || void 0 === r ? void 0 : r.
|
|
366
|
-
(c = (null === (n = this.B) || void 0 === n ? void 0 : n.
|
|
367
|
-
: ((
|
|
368
|
-
(null === (o = this.B) || void 0 === o ? void 0 : o.
|
|
361
|
+
? ((u =
|
|
362
|
+
(null === (r = this.B) || void 0 === r ? void 0 : r.Ol()) || -1),
|
|
363
|
+
(c = (null === (n = this.B) || void 0 === n ? void 0 : n.Gl()) || -1))
|
|
364
|
+
: ((u =
|
|
365
|
+
(null === (o = this.B) || void 0 === o ? void 0 : o._l(e)) || -1),
|
|
369
366
|
(c =
|
|
370
|
-
(null === (a = this.B) || void 0 === a ? void 0 : a.
|
|
371
|
-
-1 ===
|
|
367
|
+
(null === (a = this.B) || void 0 === a ? void 0 : a.Wl(e)) || -1)),
|
|
368
|
+
-1 === u || -1 === c)
|
|
372
369
|
)
|
|
373
|
-
return
|
|
370
|
+
return l;
|
|
374
371
|
const f = new Date().valueOf();
|
|
375
|
-
let m = this.
|
|
372
|
+
let m = this.Pl(f, u, c, d, e);
|
|
376
373
|
return m < 1
|
|
377
|
-
? ((
|
|
374
|
+
? ((l.Sl = !1), (l.Bl = this.Ul(m, c)), l)
|
|
378
375
|
: ((m = Math.trunc(m) - 1),
|
|
379
|
-
(
|
|
380
|
-
t ? this.
|
|
381
|
-
|
|
376
|
+
(l.jl = m),
|
|
377
|
+
t ? this.Xl(m) : this.El(e, m),
|
|
378
|
+
l);
|
|
382
379
|
}
|
|
383
|
-
|
|
384
|
-
return this.
|
|
380
|
+
Cl() {
|
|
381
|
+
return this.xl(!0);
|
|
385
382
|
}
|
|
386
|
-
|
|
387
|
-
const e = this.
|
|
388
|
-
return !(e && !e.
|
|
383
|
+
Nl(t) {
|
|
384
|
+
const e = this.xl(!1, t);
|
|
385
|
+
return !(e && !e.Sl);
|
|
389
386
|
}
|
|
390
387
|
it() {
|
|
391
|
-
this.
|
|
388
|
+
this.Na.it();
|
|
392
389
|
}
|
|
393
390
|
Z() {
|
|
394
|
-
return this.
|
|
391
|
+
return this.Oa;
|
|
395
392
|
}
|
|
396
393
|
addSdkMetadata(t) {
|
|
397
|
-
for (const e of t) -1 === this.
|
|
394
|
+
for (const e of t) -1 === this.il.indexOf(e) && this.il.push(e);
|
|
398
395
|
}
|
|
399
396
|
}
|