@braze/web-sdk 6.3.1 → 6.4.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 +35 -3
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +23 -23
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +7 -7
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +22 -21
- package/src/Banner/display/banner-to-html.js +2 -2
- package/src/Banner/display/detect-banner-impressions.js +7 -7
- package/src/Banner/index.js +2 -0
- package/src/Banner/request-banners-refresh.js +6 -6
- package/src/Banner/ui/insert-banner.js +4 -4
- package/src/Card/card-manager-factory.js +5 -5
- package/src/Card/card-manager.js +4 -4
- package/src/Card/display/card-display.js +7 -7
- package/src/Card/log-card-dismissal.js +3 -3
- package/src/Card/log-content-card-click.js +3 -3
- package/src/Card/log-content-card-impressions.js +6 -6
- package/src/Card/models/card.js +7 -7
- package/src/Card/util/card-factory.js +6 -6
- package/src/ContentCards/content-cards-provider-factory.js +14 -10
- package/src/ContentCards/content-cards-provider.js +28 -28
- package/src/ContentCards/content-cards.js +4 -4
- 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 +3 -3
- package/src/ContentCards/ui/show-content-cards.js +8 -8
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +5 -5
- package/src/Core/disable-sdk.js +3 -3
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/get-user.js +1 -1
- package/src/Core/is-disabled.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 +11 -11
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +5 -5
- package/src/DUST/dust-provider-factory.js +20 -0
- package/src/DUST/dust-provider.js +288 -0
- package/src/DUST/index.js +3 -0
- package/src/DUST/subscribe-to-dust.js +24 -0
- package/src/DUST/types.js +1 -0
- package/src/FeatureFlags/feature-flags-provider-factory.js +9 -9
- package/src/FeatureFlags/feature-flags-provider.js +38 -38
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +3 -3
- package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
- package/src/FeatureFlags/refresh-feature-flags.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +5 -5
- package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
- package/src/InAppMessage/display/modal-utils.js +5 -5
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +80 -80
- 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 +1 -1
- package/src/InAppMessage/models/full-screen-message.js +12 -12
- package/src/InAppMessage/models/html-message.js +14 -14
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +119 -121
- package/src/InAppMessage/models/modal-message.js +12 -12
- package/src/InAppMessage/models/slide-up-message.js +21 -21
- 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/remove-all-visible-in-app-messages.js +18 -0
- package/src/InAppMessage/ui/show-in-app-message.js +24 -24
- 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/utils/push-utils.js +17 -17
- package/src/User/user-manager.js +12 -12
- package/src/User/user.js +48 -48
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +20 -20
- package/src/common/event-logger.js +4 -4
- package/src/common/properties-base.js +16 -16
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +29 -29
- package/src/managers/braze-instance.js +141 -133
- package/src/managers/device-manager.js +18 -18
- package/src/managers/network-manager.js +139 -139
- package/src/managers/server-config-manager.js +99 -82
- package/src/managers/session-manager.js +32 -32
- package/src/managers/storage-manager-factory.js +8 -8
- package/src/managers/storage-manager.js +76 -74
- package/src/managers/subscription-manager.js +10 -10
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +12 -12
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +38 -34
- package/src/request-controller.js +136 -134
- package/src/triggers/models/custom-event-data.js +4 -4
- package/src/triggers/models/custom-event-property-data.js +5 -5
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +30 -30
- 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 +36 -36
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +15 -15
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +25 -25
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +3 -3
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/component-utils.js +1 -1
- package/src/util/dom-utils.js +10 -10
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +22 -22
- package/src/util/user-agent-parser.js +14 -14
- package/src/util/validation-utils.js +9 -9
- package/src/util/window-utils.js +1 -1
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import t from "../common/base-provider.js";
|
|
2
|
+
import r from "../managers/braze-instance.js";
|
|
3
|
+
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
4
|
+
import u from "../managers/subscription-manager.js";
|
|
5
|
+
import a from "../util/net.js";
|
|
6
|
+
import h from "../util/request-header-utils.js";
|
|
7
|
+
import { logger as E } from "../../shared-lib/index.js";
|
|
8
|
+
export default class tr extends t {
|
|
9
|
+
constructor(i, t, s) {
|
|
10
|
+
super(),
|
|
11
|
+
(this.B = i),
|
|
12
|
+
(this.j = t),
|
|
13
|
+
(this.B = i),
|
|
14
|
+
(this.j = t),
|
|
15
|
+
(this.mite = null),
|
|
16
|
+
(this.yi = null),
|
|
17
|
+
(this.$i = s || null),
|
|
18
|
+
(this.Ri = null),
|
|
19
|
+
(this.D = null),
|
|
20
|
+
(this.Mi = 0),
|
|
21
|
+
(this.ji = 5),
|
|
22
|
+
(this.Fi = null),
|
|
23
|
+
(this.Ui = !0),
|
|
24
|
+
(this.xi = null),
|
|
25
|
+
(this.Pi = null),
|
|
26
|
+
(this.ki = null),
|
|
27
|
+
(this.Bi = !1),
|
|
28
|
+
(this.Ji = new Map()),
|
|
29
|
+
this.Oi();
|
|
30
|
+
}
|
|
31
|
+
Oi() {
|
|
32
|
+
if (this.j) {
|
|
33
|
+
const i = this.j.lt(s.ct.qi),
|
|
34
|
+
t = this.j.lt(s.ct.zi);
|
|
35
|
+
i && t
|
|
36
|
+
? ((this.mite = i),
|
|
37
|
+
(this.yi = t),
|
|
38
|
+
E.info("Restored DUST configuration from storage"))
|
|
39
|
+
: (i || t) &&
|
|
40
|
+
(E.warn("Incomplete DUST configuration in storage, clearing"),
|
|
41
|
+
this.j.Nt(s.ct.qi),
|
|
42
|
+
this.j.Nt(s.ct.zi));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
Hi() {
|
|
46
|
+
this.xi ||
|
|
47
|
+
this.Pi ||
|
|
48
|
+
((this.ki = () => {
|
|
49
|
+
(this.Bi = !0), (this.Ui = !1);
|
|
50
|
+
}),
|
|
51
|
+
window.addEventListener("beforeunload", this.ki),
|
|
52
|
+
(this.xi = () => {
|
|
53
|
+
(this.Bi = !0),
|
|
54
|
+
this.Ri &&
|
|
55
|
+
(E.info("Page unloading, closing real-time connection gracefully"),
|
|
56
|
+
(this.Ui = !1),
|
|
57
|
+
this.Li());
|
|
58
|
+
}),
|
|
59
|
+
window.addEventListener("pagehide", this.xi),
|
|
60
|
+
(this.Pi = (i) => {
|
|
61
|
+
i.persisted &&
|
|
62
|
+
this.Wi() &&
|
|
63
|
+
!this.Ri &&
|
|
64
|
+
(E.info("Page restored from bfcache, reconnecting"),
|
|
65
|
+
(this.Bi = !1),
|
|
66
|
+
(this.Ui = !0),
|
|
67
|
+
(this.Mi = 0),
|
|
68
|
+
this.Gi());
|
|
69
|
+
}),
|
|
70
|
+
window.addEventListener("pageshow", this.Pi));
|
|
71
|
+
}
|
|
72
|
+
jt() {
|
|
73
|
+
return this.D;
|
|
74
|
+
}
|
|
75
|
+
yt(i) {
|
|
76
|
+
this.D = i;
|
|
77
|
+
}
|
|
78
|
+
Ki(i, t) {
|
|
79
|
+
if ("function" != typeof t) return null;
|
|
80
|
+
let s = this.Ji.get(i);
|
|
81
|
+
return s || ((s = new u()), this.Ji.set(i, s), r.q(s)), s.wt(t);
|
|
82
|
+
}
|
|
83
|
+
Qi(i, t) {
|
|
84
|
+
const s = this.Ji.get(i);
|
|
85
|
+
s && s.removeSubscription(t);
|
|
86
|
+
}
|
|
87
|
+
Wi() {
|
|
88
|
+
return Boolean(this.mite && this.yi);
|
|
89
|
+
}
|
|
90
|
+
Vi(i, t) {
|
|
91
|
+
const e = () => {
|
|
92
|
+
"function" == typeof t && t();
|
|
93
|
+
},
|
|
94
|
+
n = this.B,
|
|
95
|
+
o = this.j;
|
|
96
|
+
if (!n || !o)
|
|
97
|
+
return (
|
|
98
|
+
E.error("NetworkManager or StorageManager not available"), void e()
|
|
99
|
+
);
|
|
100
|
+
const l = r.l();
|
|
101
|
+
if (l && !l.Xi())
|
|
102
|
+
return (
|
|
103
|
+
E.info("Real-time messaging is not enabled, skipping refresh"), void e()
|
|
104
|
+
);
|
|
105
|
+
this.Wi()
|
|
106
|
+
? E.info("Refreshing real-time messaging configuration")
|
|
107
|
+
: E.info("Fetching initial real-time messaging configuration");
|
|
108
|
+
const g = n.$({}, !0),
|
|
109
|
+
c = n.A(g, h.H.Yi, !1),
|
|
110
|
+
u = new Date().valueOf();
|
|
111
|
+
h.K(o, h.H.Yi, u),
|
|
112
|
+
a.O({
|
|
113
|
+
url: `${n.V()}/dust/config`,
|
|
114
|
+
headers: c,
|
|
115
|
+
data: g,
|
|
116
|
+
W: (t) => {
|
|
117
|
+
if (!n.Y(g, t, c))
|
|
118
|
+
return (
|
|
119
|
+
E.error(
|
|
120
|
+
"Failed to validate server response for real-time messaging configuration",
|
|
121
|
+
),
|
|
122
|
+
void e()
|
|
123
|
+
);
|
|
124
|
+
n.Z(),
|
|
125
|
+
t.mite && t.host
|
|
126
|
+
? ((this.mite = t.mite),
|
|
127
|
+
(this.yi = t.host),
|
|
128
|
+
E.info(
|
|
129
|
+
"Received real-time messaging configuration from server",
|
|
130
|
+
),
|
|
131
|
+
o.ft(s.ct.qi, t.mite),
|
|
132
|
+
o.ft(s.ct.zi, t.host),
|
|
133
|
+
this.Gi(),
|
|
134
|
+
"function" == typeof i && i())
|
|
135
|
+
: (t.mite ||
|
|
136
|
+
E.error("Missing messaging identifier in server response"),
|
|
137
|
+
t.host || E.error("Missing messaging host in server response"),
|
|
138
|
+
e());
|
|
139
|
+
},
|
|
140
|
+
error: (i) => {
|
|
141
|
+
n._(i, "retrieving DUST config"), e();
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
Gi() {
|
|
146
|
+
const i = r.l();
|
|
147
|
+
if (i && !i.Xi())
|
|
148
|
+
return void E.info(
|
|
149
|
+
"Real-time messaging is not enabled, skipping connection",
|
|
150
|
+
);
|
|
151
|
+
if (!this.Wi())
|
|
152
|
+
return void E.error(
|
|
153
|
+
"Cannot start real-time subscription without configuration",
|
|
154
|
+
);
|
|
155
|
+
this.Ri &&
|
|
156
|
+
(E.info(
|
|
157
|
+
"Real-time connection already exists, closing before starting new subscription",
|
|
158
|
+
),
|
|
159
|
+
this.Li());
|
|
160
|
+
const t = this.mite,
|
|
161
|
+
s = this.$i || this.yi;
|
|
162
|
+
if (!t || !s) return;
|
|
163
|
+
const e = `${
|
|
164
|
+
/^https?:\/\//i.test(s) ? s : `https://${s}`
|
|
165
|
+
}/sse?mite=${encodeURIComponent(t)}&attempts=${this.Mi}`;
|
|
166
|
+
this.$i && E.info(`Using custom real-time messaging host: ${this.$i}`);
|
|
167
|
+
try {
|
|
168
|
+
(this.Ri = new EventSource(e)),
|
|
169
|
+
(this.Ri.onopen = () => {
|
|
170
|
+
E.info("Real-time messaging connection established"),
|
|
171
|
+
(this.Mi = 0),
|
|
172
|
+
(this.Ui = !0);
|
|
173
|
+
}),
|
|
174
|
+
this.Ri.addEventListener("msg", (i) => {
|
|
175
|
+
this.Zi(i.data);
|
|
176
|
+
}),
|
|
177
|
+
(this.Ri.onerror = (i) => {
|
|
178
|
+
var t;
|
|
179
|
+
const s =
|
|
180
|
+
null === (t = this.Ri) || void 0 === t ? void 0 : t.readyState;
|
|
181
|
+
this.Bi ||
|
|
182
|
+
E.error(
|
|
183
|
+
`Real-time messaging connection error (readyState: ${s}, eventPhase: ${
|
|
184
|
+
null == i ? void 0 : i.eventPhase
|
|
185
|
+
})`,
|
|
186
|
+
),
|
|
187
|
+
this.Li(),
|
|
188
|
+
this.Ui && this.Mi < this.ji
|
|
189
|
+
? this._i()
|
|
190
|
+
: (this.Mi >= this.ji &&
|
|
191
|
+
E.error(
|
|
192
|
+
`Max retry attempts (${this.ji}) reached for real-time messaging, giving up for current session`,
|
|
193
|
+
),
|
|
194
|
+
(this.Ui = !1));
|
|
195
|
+
});
|
|
196
|
+
} catch (i) {
|
|
197
|
+
E.error(
|
|
198
|
+
`Failed to create real-time messaging connection: ${
|
|
199
|
+
i instanceof Error ? i.message : String(i)
|
|
200
|
+
}`,
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
_i() {
|
|
205
|
+
this.Mi++;
|
|
206
|
+
const i = Math.min(1e3 * Math.pow(2, this.Mi), 6e4);
|
|
207
|
+
E.info(
|
|
208
|
+
`Retrying real-time messaging connection in ${i}ms (attempt ${this.Mi}/${this.ji})`,
|
|
209
|
+
),
|
|
210
|
+
(this.Fi = window.setTimeout(() => {
|
|
211
|
+
(this.Fi = null), this.Gi();
|
|
212
|
+
}, i));
|
|
213
|
+
}
|
|
214
|
+
Li() {
|
|
215
|
+
null !== this.Fi && (window.clearTimeout(this.Fi), (this.Fi = null)),
|
|
216
|
+
this.Ri &&
|
|
217
|
+
(this.Ri.close(),
|
|
218
|
+
(this.Ri = null),
|
|
219
|
+
E.info("Real-time messaging connection closed"));
|
|
220
|
+
}
|
|
221
|
+
Zi(i) {
|
|
222
|
+
try {
|
|
223
|
+
const t = JSON.parse(i);
|
|
224
|
+
if (!t.type)
|
|
225
|
+
return void E.error(
|
|
226
|
+
`Received real-time message without type: ${JSON.stringify(t)}`,
|
|
227
|
+
);
|
|
228
|
+
E.info(`Received real-time message of type '${t.type}'`);
|
|
229
|
+
const s = this.Ji.get(t.type);
|
|
230
|
+
s && s.he() > 0
|
|
231
|
+
? s.L(t)
|
|
232
|
+
: E.info(`No subscribers for real-time message type '${t.type}'`);
|
|
233
|
+
} catch (i) {
|
|
234
|
+
E.error(
|
|
235
|
+
`Failed to parse real-time message: ${
|
|
236
|
+
i instanceof Error ? i.message : String(i)
|
|
237
|
+
}`,
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
changeUser(i = !1) {
|
|
242
|
+
this.Li(),
|
|
243
|
+
!i && this.j
|
|
244
|
+
? (this.Wi() &&
|
|
245
|
+
E.info(
|
|
246
|
+
"Clearing cached real-time messaging configuration for user change",
|
|
247
|
+
),
|
|
248
|
+
this.j.Nt(s.ct.qi),
|
|
249
|
+
this.j.Nt(s.ct.zi),
|
|
250
|
+
(this.mite = null),
|
|
251
|
+
(this.yi = null))
|
|
252
|
+
: i &&
|
|
253
|
+
this.Wi() &&
|
|
254
|
+
E.info(
|
|
255
|
+
"Preserving cached real-time messaging configuration for anonymous->identified user transition",
|
|
256
|
+
),
|
|
257
|
+
(this.Mi = 0),
|
|
258
|
+
(this.Ui = !0);
|
|
259
|
+
}
|
|
260
|
+
clearData(i = !1) {
|
|
261
|
+
(this.Ui = !1),
|
|
262
|
+
this.Li(),
|
|
263
|
+
i &&
|
|
264
|
+
this.j &&
|
|
265
|
+
(this.Wi() &&
|
|
266
|
+
E.info(
|
|
267
|
+
"Clearing cached real-time messaging configuration (wipeData)",
|
|
268
|
+
),
|
|
269
|
+
this.j.Nt(s.ct.qi),
|
|
270
|
+
this.j.Nt(s.ct.zi),
|
|
271
|
+
(this.mite = null),
|
|
272
|
+
(this.yi = null)),
|
|
273
|
+
(this.Mi = 0);
|
|
274
|
+
}
|
|
275
|
+
destroy() {
|
|
276
|
+
(this.Ui = !1),
|
|
277
|
+
this.Li(),
|
|
278
|
+
(this.mite = null),
|
|
279
|
+
(this.Mi = 0),
|
|
280
|
+
this.ki &&
|
|
281
|
+
(window.removeEventListener("beforeunload", this.ki), (this.ki = null)),
|
|
282
|
+
this.xi &&
|
|
283
|
+
(window.removeEventListener("pagehide", this.xi), (this.xi = null)),
|
|
284
|
+
this.Pi &&
|
|
285
|
+
(window.removeEventListener("pageshow", this.Pi), (this.Pi = null)),
|
|
286
|
+
this.D && (r.removeSubscription(this.D), (this.D = null));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import ir from "./dust-provider-factory.js";
|
|
3
|
+
export function subscribeToDust() {
|
|
4
|
+
const t = r.l(),
|
|
5
|
+
n = r.nn();
|
|
6
|
+
if (!t || !n) return null;
|
|
7
|
+
const o = ir.o(),
|
|
8
|
+
s = () => {
|
|
9
|
+
if (!o.jt()) {
|
|
10
|
+
o.Hi();
|
|
11
|
+
const r = n.rn(() => {
|
|
12
|
+
t.Xi() && o.Vi();
|
|
13
|
+
});
|
|
14
|
+
return r && o.yt(r), o.Wi() && o.Gi(), r;
|
|
15
|
+
}
|
|
16
|
+
return o.jt();
|
|
17
|
+
};
|
|
18
|
+
return t.Xi()
|
|
19
|
+
? s()
|
|
20
|
+
: (t.Tr(() => {
|
|
21
|
+
r.ao() && t.Xi() && (o.Vi(), s());
|
|
22
|
+
}),
|
|
23
|
+
null);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
3
|
-
const
|
|
2
|
+
import nr from "./feature-flags-provider.js";
|
|
3
|
+
const ar = {
|
|
4
4
|
i: !1,
|
|
5
5
|
provider: null,
|
|
6
6
|
o: () => (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
((
|
|
10
|
-
|
|
7
|
+
ar.t(),
|
|
8
|
+
ar.provider ||
|
|
9
|
+
((ar.provider = new nr(r.l(), r.m(), r.p(), r.u())), r.v(ar.provider)),
|
|
10
|
+
ar.provider
|
|
11
11
|
),
|
|
12
12
|
t: () => {
|
|
13
|
-
|
|
13
|
+
ar.i || (r.g(ar), (ar.i = !0));
|
|
14
14
|
},
|
|
15
15
|
destroy: () => {
|
|
16
|
-
(
|
|
16
|
+
(ar.provider = null), (ar.i = !1);
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
|
-
export default
|
|
19
|
+
export default ar;
|
|
@@ -10,44 +10,44 @@ import {
|
|
|
10
10
|
newFeatureFlagFromSerializedValue as ht,
|
|
11
11
|
} from "./feature-flag-factory.js";
|
|
12
12
|
import h from "../util/request-header-utils.js";
|
|
13
|
-
export default class
|
|
13
|
+
export default class nr extends t {
|
|
14
14
|
constructor(t, s, e, i) {
|
|
15
15
|
super(),
|
|
16
16
|
(this.h = t),
|
|
17
17
|
(this.B = s),
|
|
18
18
|
(this.j = e),
|
|
19
19
|
(this.C = i),
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
20
|
+
(this.je = []),
|
|
21
|
+
(this.ye = 0),
|
|
22
22
|
(this.h = t),
|
|
23
23
|
(this.B = s),
|
|
24
24
|
(this.j = e),
|
|
25
25
|
(this.C = i),
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
26
|
+
(this.Ce = null),
|
|
27
|
+
(this.Re = new u()),
|
|
28
28
|
(this.S = 10),
|
|
29
29
|
(this.T = null),
|
|
30
30
|
(this.I = null),
|
|
31
|
-
r.q(this.
|
|
31
|
+
r.q(this.Re);
|
|
32
32
|
}
|
|
33
33
|
N(t) {
|
|
34
34
|
var s;
|
|
35
35
|
if (
|
|
36
|
-
(null === (s = this.h) || void 0 === s ? void 0 : s.
|
|
36
|
+
(null === (s = this.h) || void 0 === s ? void 0 : s.Te()) &&
|
|
37
37
|
null != t &&
|
|
38
38
|
t.feature_flags
|
|
39
39
|
) {
|
|
40
|
-
this.
|
|
40
|
+
this.je = [];
|
|
41
41
|
for (const s of t.feature_flags) {
|
|
42
42
|
const t = at(s);
|
|
43
|
-
t && this.
|
|
43
|
+
t && this.je.push(t);
|
|
44
44
|
}
|
|
45
|
-
(this.
|
|
45
|
+
(this.ye = new Date().getTime()), this.De(), this.Re.L(this.je);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
Ie() {
|
|
49
49
|
let t = {};
|
|
50
|
-
this.j && (t = this.j.lt(s.ct.
|
|
50
|
+
this.j && (t = this.j.lt(s.ct.Se));
|
|
51
51
|
const e = {};
|
|
52
52
|
for (const s in t) {
|
|
53
53
|
const i = ht(t[s]);
|
|
@@ -55,27 +55,27 @@ export default class tr extends t {
|
|
|
55
55
|
}
|
|
56
56
|
return e;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
qe() {
|
|
59
59
|
var t;
|
|
60
60
|
return (
|
|
61
|
-
(null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.
|
|
61
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.Ne)) || {}
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
this.j && this.j.ft(s.ct.
|
|
64
|
+
ze(t) {
|
|
65
|
+
this.j && this.j.ft(s.ct.Ne, t);
|
|
66
66
|
}
|
|
67
67
|
St(t) {
|
|
68
|
-
return this.
|
|
68
|
+
return this.Re.wt(t);
|
|
69
69
|
}
|
|
70
70
|
refreshFeatureFlags(t, s, e = !1, i = !0) {
|
|
71
71
|
const r = () => {
|
|
72
|
-
"function" == typeof s && s(), this.
|
|
72
|
+
"function" == typeof s && s(), this.Re.L(this.je);
|
|
73
73
|
};
|
|
74
|
-
if (!this.
|
|
74
|
+
if (!this.Ue(e))
|
|
75
75
|
return (
|
|
76
|
-
!this.
|
|
76
|
+
!this.Ce &&
|
|
77
77
|
this.h &&
|
|
78
|
-
(this.
|
|
78
|
+
(this.Ce = this.h.$e(() => {
|
|
79
79
|
this.refreshFeatureFlags(t, s);
|
|
80
80
|
})),
|
|
81
81
|
void r()
|
|
@@ -84,7 +84,7 @@ export default class tr extends t {
|
|
|
84
84
|
if (!o) return void r();
|
|
85
85
|
i && this.X();
|
|
86
86
|
const n = o.$({}, !0),
|
|
87
|
-
u = o.A(n, h.H
|
|
87
|
+
u = o.A(n, h.H.ke);
|
|
88
88
|
let f = !1;
|
|
89
89
|
o.J(
|
|
90
90
|
n,
|
|
@@ -92,7 +92,7 @@ export default class tr extends t {
|
|
|
92
92
|
const o = this.B;
|
|
93
93
|
if (!o) return void r();
|
|
94
94
|
const c = new Date().valueOf();
|
|
95
|
-
h.K(this.j, h.H
|
|
95
|
+
h.K(this.j, h.H.ke, c),
|
|
96
96
|
-1 !== i && u.push(["X-Braze-Req-Tokens-Remaining", i.toString()]),
|
|
97
97
|
a.O({
|
|
98
98
|
url: `${o.V()}/feature_flags/sync`,
|
|
@@ -117,7 +117,7 @@ export default class tr extends t {
|
|
|
117
117
|
() => {
|
|
118
118
|
this.refreshFeatureFlags(t, s, e, !0);
|
|
119
119
|
},
|
|
120
|
-
h.H
|
|
120
|
+
h.H.ke,
|
|
121
121
|
(t) => this.it(t),
|
|
122
122
|
() => this.X(),
|
|
123
123
|
a,
|
|
@@ -125,7 +125,7 @@ export default class tr extends t {
|
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
127
|
},
|
|
128
|
-
h.H
|
|
128
|
+
h.H.ke,
|
|
129
129
|
s,
|
|
130
130
|
);
|
|
131
131
|
}
|
|
@@ -135,49 +135,49 @@ export default class tr extends t {
|
|
|
135
135
|
it(t) {
|
|
136
136
|
this.X(), (this.I = t);
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
Ue(t) {
|
|
139
139
|
if (!this.h) return !1;
|
|
140
140
|
if (!t) {
|
|
141
|
-
const t = this.h.
|
|
141
|
+
const t = this.h.Be();
|
|
142
142
|
if (null == t) return !1;
|
|
143
143
|
let s = !1;
|
|
144
144
|
if (!isNaN(t)) {
|
|
145
145
|
if (-1 === t) return E.info("Feature flag refreshes not allowed"), !1;
|
|
146
|
-
s = new Date().getTime() >= (this.
|
|
146
|
+
s = new Date().getTime() >= (this.ye || 0) + 1e3 * t;
|
|
147
147
|
}
|
|
148
148
|
if (!s)
|
|
149
149
|
return (
|
|
150
150
|
E.info(`Feature flag refreshes were rate limited to ${t} seconds`), !1
|
|
151
151
|
);
|
|
152
152
|
}
|
|
153
|
-
return this.h.
|
|
153
|
+
return this.h.Te();
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
Me() {
|
|
156
156
|
var t;
|
|
157
157
|
return (
|
|
158
|
-
(null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.
|
|
158
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.lt(s.ct.Xe)) || null
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
_e() {
|
|
162
162
|
var t, e;
|
|
163
163
|
null === (t = this.j) ||
|
|
164
164
|
void 0 === t ||
|
|
165
|
-
t.ft(s.ct.
|
|
165
|
+
t.ft(s.ct.Xe, null === (e = this.C) || void 0 === e ? void 0 : e.bt());
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
Ae() {
|
|
168
168
|
var t;
|
|
169
169
|
const s = null === (t = this.C) || void 0 === t ? void 0 : t.bt(),
|
|
170
|
-
e = this.
|
|
170
|
+
e = this.Me();
|
|
171
171
|
return null == e || s === e;
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
De() {
|
|
174
174
|
if (!this.j) return;
|
|
175
175
|
const t = {};
|
|
176
|
-
for (const s of this.
|
|
176
|
+
for (const s of this.je) {
|
|
177
177
|
const e = s.dt();
|
|
178
178
|
t[s.id] = e;
|
|
179
179
|
}
|
|
180
|
-
this.j.ft(s.ct.
|
|
180
|
+
this.j.ft(s.ct.Se, t), this.j.ft(s.ct.Ee, this.ye), this._e();
|
|
181
181
|
}
|
|
182
182
|
changeUser() {
|
|
183
183
|
this.X();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import ar from "./feature-flags-provider-factory.js";
|
|
3
3
|
export function getAllFeatureFlags() {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
5
|
const t = [],
|
|
6
6
|
e = r.l();
|
|
7
|
-
if (e && !e.
|
|
8
|
-
const n =
|
|
7
|
+
if (e && !e.Te()) return t;
|
|
8
|
+
const n = ar.o().Ie();
|
|
9
9
|
for (const r in n) t.push(n[r]);
|
|
10
10
|
return t;
|
|
11
11
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import ar from "./feature-flags-provider-factory.js";
|
|
3
3
|
export function getFeatureFlag(t) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
5
|
const e = r.l();
|
|
6
|
-
if (e && !e.
|
|
7
|
-
const n =
|
|
6
|
+
if (e && !e.Te()) return null;
|
|
7
|
+
const n = ar.o().Ie();
|
|
8
8
|
return n[t] ? n[t] : null;
|
|
9
9
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { logger as E, EventTypes as m } from "../../shared-lib/index.js";
|
|
2
2
|
import c from "../common/event-logger.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
|
-
import
|
|
4
|
+
import ar from "./feature-flags-provider-factory.js";
|
|
5
5
|
export function logFeatureFlagImpression(e) {
|
|
6
6
|
if (!r.rr()) return;
|
|
7
7
|
if (!e) return !1;
|
|
8
8
|
const t =
|
|
9
9
|
"Not logging a feature flag impression. The feature flag was not part of any matching experiment.",
|
|
10
|
-
o =
|
|
10
|
+
o = ar.o().Ie();
|
|
11
11
|
if (!o[e]) return E.info(t), !1;
|
|
12
12
|
const n = o[e].trackingString;
|
|
13
13
|
if (!n) return E.info(t), !1;
|
|
14
|
-
const i =
|
|
14
|
+
const i = ar.o().qe();
|
|
15
15
|
if (i[n])
|
|
16
16
|
return (
|
|
17
17
|
E.info(
|
|
@@ -19,7 +19,7 @@ export function logFeatureFlagImpression(e) {
|
|
|
19
19
|
),
|
|
20
20
|
!1
|
|
21
21
|
);
|
|
22
|
-
(i[n] = !0),
|
|
22
|
+
(i[n] = !0), ar.o().ze(i);
|
|
23
23
|
const s = { fid: e, fts: n };
|
|
24
|
-
return c.rt(m.
|
|
24
|
+
return c.rt(m.Ir, s).W;
|
|
25
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
if (r.rr()) return
|
|
2
|
+
import ar from "./feature-flags-provider-factory.js";
|
|
3
|
+
function fr(e, t, a = !1) {
|
|
4
|
+
if (r.rr()) return ar.o().refreshFeatureFlags(e, t, a);
|
|
5
5
|
}
|
|
6
6
|
export function refreshFeatureFlags(r, e) {
|
|
7
|
-
|
|
7
|
+
fr(r, e);
|
|
8
8
|
}
|
|
9
|
-
export default
|
|
9
|
+
export default fr;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import ar from "./feature-flags-provider-factory.js";
|
|
3
3
|
import { getAllFeatureFlags } from "./get-all-feature-flags.js";
|
|
4
4
|
export function subscribeToFeatureFlagsUpdates(t) {
|
|
5
5
|
if (!r.rr()) return;
|
|
6
|
-
const e =
|
|
7
|
-
if (e.
|
|
6
|
+
const e = ar.o();
|
|
7
|
+
if (e.Ae()) {
|
|
8
8
|
const r = getAllFeatureFlags();
|
|
9
9
|
r && "function" == typeof t && t(r);
|
|
10
10
|
}
|
|
@@ -8,6 +8,6 @@ export function deferInAppMessage(e) {
|
|
|
8
8
|
return e instanceof ControlMessage
|
|
9
9
|
? (E.info("Not deferring since this is a ControlMessage."), !1)
|
|
10
10
|
: e instanceof InAppMessage
|
|
11
|
-
? se.ea().
|
|
11
|
+
? se.ea().Ge(e)
|
|
12
12
|
: (E.info("Not an instance of InAppMessage, ignoring."), !1);
|
|
13
13
|
}
|
|
@@ -18,7 +18,7 @@ export default function ct(t, e, o, s, n) {
|
|
|
18
18
|
if (t.Oe()) {
|
|
19
19
|
const e = document.createElement("style");
|
|
20
20
|
(e.innerHTML = t.css || ""),
|
|
21
|
-
(e.id = t.
|
|
21
|
+
(e.id = t.He() || ""),
|
|
22
22
|
null != n && e.setAttribute("nonce", n),
|
|
23
23
|
l.appendChild(e);
|
|
24
24
|
}
|
|
@@ -42,7 +42,7 @@ export default function ct(t, e, o, s, n) {
|
|
|
42
42
|
},
|
|
43
43
|
);
|
|
44
44
|
if (
|
|
45
|
-
((s.appboyBridge = r), (s.brazeBridge = r), t.
|
|
45
|
+
((s.appboyBridge = r), (s.brazeBridge = r), t.Je !== InAppMessage.Le.Ke)
|
|
46
46
|
) {
|
|
47
47
|
const e = s.document.getElementsByTagName("a");
|
|
48
48
|
for (let s = 0; s < e.length; s++) e[s].onclick = lt(t, i, e[s], o);
|
|
@@ -51,7 +51,7 @@ export default function ct(t, e, o, s, n) {
|
|
|
51
51
|
}
|
|
52
52
|
const c = s.document.body;
|
|
53
53
|
if (null != c) {
|
|
54
|
-
t.
|
|
54
|
+
t.Pe() && (c.id = t.htmlId || "");
|
|
55
55
|
const e = document.createElement("hidden");
|
|
56
56
|
(e.onclick = r.closeMessage),
|
|
57
57
|
(e.className = "ab-programmatic-close-button"),
|
|
@@ -67,8 +67,8 @@ export default function ct(t, e, o, s, n) {
|
|
|
67
67
|
) {
|
|
68
68
|
const e = document.createElement("div");
|
|
69
69
|
return (
|
|
70
|
-
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(i), (t.
|
|
70
|
+
(e.className = "ab-ios-scroll-wrapper"), e.appendChild(i), (t.Qe = e), e
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
|
-
return (t.
|
|
73
|
+
return (t.Qe = i), i;
|
|
74
74
|
}
|