@braze/web-sdk 6.5.0 → 6.6.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 +8 -3
- package/package.json +1 -1
- package/shared-lib/event-types.js +11 -11
- package/shared-lib/indexed-db-adapter.js +4 -4
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +14 -13
- package/src/Core/disable-sdk.js +8 -7
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/is-disabled.js +1 -1
- package/src/DUST/dust-provider.js +100 -100
- package/src/DUST/dust-shared-worker-impl.js +12 -12
- package/src/DUST/dust-worker-bridge.js +11 -11
- package/src/DUST/subscribe-to-dust.js +5 -5
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +68 -68
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- 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 +7 -7
- package/src/InAppMessage/models/html-message.js +8 -8
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +42 -42
- package/src/InAppMessage/models/modal-message.js +8 -8
- package/src/InAppMessage/models/slide-up-message.js +6 -6
- 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/Push/push-manager-factory.js +2 -2
- package/src/Push/utils/push-utils.js +6 -6
- package/src/User/user-manager.js +2 -2
- package/src/User/user.js +9 -9
- package/src/common/content-cards-display.js +1 -1
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/braze-instance.js +99 -95
- package/src/managers/device-manager.js +2 -2
- package/src/managers/network-manager.js +116 -116
- package/src/managers/server-config-manager.js +33 -33
- package/src/managers/session-manager.js +1 -1
- package/src/managers/storage-manager-factory.js +8 -8
- package/src/managers/storage-manager.js +45 -48
- package/src/managers/subscription-manager.js +8 -8
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/push-token.js +6 -6
- package/src/models/server-config.js +29 -29
- package/src/request-controller.js +91 -91
- package/src/triggers/models/trigger-condition.js +25 -25
- package/src/triggers/models/trigger.js +7 -7
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +12 -12
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/braze-actions.js +2 -2
- package/src/util/browser-detector.js +1 -1
- package/src/util/net.js +2 -2
- package/src/util/request-header-utils.js +12 -12
- package/src/util/window-utils.js +1 -1
|
@@ -68,14 +68,14 @@ export default class tr extends t {
|
|
|
68
68
|
}
|
|
69
69
|
_i() {
|
|
70
70
|
this.Ki = new si({
|
|
71
|
-
|
|
72
|
-
this.
|
|
71
|
+
Se: (i) => {
|
|
72
|
+
this.ke(i);
|
|
73
73
|
},
|
|
74
|
-
|
|
75
|
-
this.
|
|
74
|
+
ye: () => {
|
|
75
|
+
this.Re();
|
|
76
76
|
},
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
Me: () => {},
|
|
78
|
+
De: (i) => {
|
|
79
79
|
E.error(`Real-time messaging SharedWorker error: ${i}`);
|
|
80
80
|
},
|
|
81
81
|
});
|
|
@@ -86,14 +86,14 @@ export default class tr extends t {
|
|
|
86
86
|
(this.Qi = "direct"),
|
|
87
87
|
(this.Ki = null));
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
Re() {
|
|
90
90
|
(this.ji = 0),
|
|
91
91
|
(this.Bi = null),
|
|
92
92
|
(this.zi = !0),
|
|
93
93
|
(this.Xi = !1),
|
|
94
94
|
(this.Yi = 0);
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
ke(i) {
|
|
97
97
|
if (!i.type)
|
|
98
98
|
return void E.warn(
|
|
99
99
|
`Received real-time message without type: ${JSON.stringify(i)}`,
|
|
@@ -101,7 +101,7 @@ export default class tr extends t {
|
|
|
101
101
|
const t = "sharedworker" === this.Qi ? "SharedWorker" : "Direct";
|
|
102
102
|
E.info(`Received real-time message of type '${i.type}' via ${t}`);
|
|
103
103
|
const s = this.Ji.get(i.type);
|
|
104
|
-
if (s && s.
|
|
104
|
+
if (s && s.We() > 0)
|
|
105
105
|
try {
|
|
106
106
|
s.L(i);
|
|
107
107
|
} catch (t) {
|
|
@@ -111,18 +111,18 @@ export default class tr extends t {
|
|
|
111
111
|
}
|
|
112
112
|
else E.info(`No subscribers for real-time message type '${i.type}'`);
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
Fe() {
|
|
115
115
|
return "sharedworker" === this.Qi;
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
Ue() {
|
|
118
118
|
return this.Qi;
|
|
119
119
|
}
|
|
120
120
|
Zi() {
|
|
121
121
|
if (this.B) {
|
|
122
|
-
const i = this.B.dt(s.ft.
|
|
123
|
-
t = this.B.dt(s.ft.
|
|
124
|
-
e = this.B.dt(s.ft.
|
|
125
|
-
n = this.B.dt(s.ft.
|
|
122
|
+
const i = this.B.dt(s.ft.Ne),
|
|
123
|
+
t = this.B.dt(s.ft.Te),
|
|
124
|
+
e = this.B.dt(s.ft.ze),
|
|
125
|
+
n = this.B.dt(s.ft.Ae);
|
|
126
126
|
i && t
|
|
127
127
|
? ((this.mite = i),
|
|
128
128
|
(this.ki = t),
|
|
@@ -133,36 +133,36 @@ export default class tr extends t {
|
|
|
133
133
|
(E.warn(
|
|
134
134
|
"Incomplete real-time messaging configuration in storage, clearing",
|
|
135
135
|
),
|
|
136
|
-
this.
|
|
136
|
+
this.Be());
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
Hr() {
|
|
140
140
|
this.Li ||
|
|
141
141
|
this.Oi ||
|
|
142
|
-
((this.Li = this.
|
|
143
|
-
if (!i.body || "number" != typeof i.body.
|
|
144
|
-
const t = Math.random() * i.body.
|
|
145
|
-
s = Math.round(i.body.
|
|
142
|
+
((this.Li = this.Ge("ddr", (i) => {
|
|
143
|
+
if (!i.body || "number" != typeof i.body.Pe) return;
|
|
144
|
+
const t = Math.random() * i.body.Pe * 0.3,
|
|
145
|
+
s = Math.round(i.body.Pe + t),
|
|
146
146
|
e = i.body.e ? ` (${i.body.e})` : "";
|
|
147
147
|
E.info(`Admin requested disconnect${e}, reconnecting in ${s}ms`),
|
|
148
|
-
this.
|
|
149
|
-
setTimeout(() => this.
|
|
148
|
+
this.qe(),
|
|
149
|
+
setTimeout(() => this.He(), s);
|
|
150
150
|
})),
|
|
151
|
-
(this.Oi = this.
|
|
152
|
-
if (!i.body || "number" != typeof i.body.
|
|
153
|
-
const t = i.body.
|
|
151
|
+
(this.Oi = this.Ge("ttl", (i) => {
|
|
152
|
+
if (!i.body || "number" != typeof i.body.Je) return;
|
|
153
|
+
const t = i.body.Je;
|
|
154
154
|
E.info(`Time to live set to ${t}ms, will reconnect when expired`),
|
|
155
155
|
"sharedworker" !== this.Qi &&
|
|
156
|
-
("string" == typeof i.body.
|
|
156
|
+
("string" == typeof i.body.Le && (this.Mi = i.body.Le),
|
|
157
157
|
null !== this.Ui && window.clearTimeout(this.Ui),
|
|
158
158
|
(this.Ui = window.setTimeout(() => {
|
|
159
159
|
(this.Ui = null),
|
|
160
160
|
E.info("Time to live expired, performing gapless reconnection"),
|
|
161
|
-
this.
|
|
161
|
+
this.Oe();
|
|
162
162
|
}, t)));
|
|
163
163
|
})));
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
Ie() {
|
|
166
166
|
this.Gi ||
|
|
167
167
|
this.Pi ||
|
|
168
168
|
((this.qi = () => {
|
|
@@ -173,23 +173,23 @@ export default class tr extends t {
|
|
|
173
173
|
var i;
|
|
174
174
|
this.Hi = !0;
|
|
175
175
|
(this.xi ||
|
|
176
|
-
(null === (i = this.Ki) || void 0 === i ? void 0 : i.
|
|
176
|
+
(null === (i = this.Ki) || void 0 === i ? void 0 : i.Ke())) &&
|
|
177
177
|
(E.info("Page unloading, closing real-time connection gracefully"),
|
|
178
178
|
(this.zi = !1),
|
|
179
|
-
this.
|
|
179
|
+
this.qe());
|
|
180
180
|
}),
|
|
181
181
|
window.addEventListener("pagehide", this.Gi),
|
|
182
182
|
(this.Pi = (i) => {
|
|
183
183
|
var t;
|
|
184
184
|
const s =
|
|
185
|
-
this.xi || (null === (t = this.Ki) || void 0 === t ? void 0 : t.
|
|
185
|
+
this.xi || (null === (t = this.Ki) || void 0 === t ? void 0 : t.Ke());
|
|
186
186
|
i.persisted &&
|
|
187
|
-
this.
|
|
187
|
+
this.Qe() &&
|
|
188
188
|
!s &&
|
|
189
189
|
(E.info("Page restored from bfcache, reconnecting"),
|
|
190
190
|
(this.Hi = !1),
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
191
|
+
this.Re(),
|
|
192
|
+
this.He());
|
|
193
193
|
}),
|
|
194
194
|
window.addEventListener("pageshow", this.Pi));
|
|
195
195
|
}
|
|
@@ -199,35 +199,35 @@ export default class tr extends t {
|
|
|
199
199
|
wt(i) {
|
|
200
200
|
this.D = i;
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
Ge(i, t) {
|
|
203
203
|
if ("function" != typeof t) return null;
|
|
204
204
|
let s = this.Ji.get(i);
|
|
205
205
|
return s || ((s = new m()), this.Ji.set(i, s), r.q(s)), s.Rt(t);
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
Ve(i, t) {
|
|
208
208
|
const s = this.Ji.get(i);
|
|
209
209
|
s && s.removeSubscription(t);
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
Qe() {
|
|
212
212
|
return Boolean(this.mite && this.ki);
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
Xe() {
|
|
215
215
|
if (!this.$i) return !1;
|
|
216
216
|
return Math.floor(new Date().valueOf() / 1e3) >= this.$i;
|
|
217
217
|
}
|
|
218
|
-
|
|
218
|
+
Be() {
|
|
219
219
|
(this.mite = null),
|
|
220
220
|
(this.ki = null),
|
|
221
221
|
(this.yi = null),
|
|
222
222
|
(this.$i = null),
|
|
223
223
|
(this.Mi = null),
|
|
224
224
|
this.B &&
|
|
225
|
-
(this.B.zt(s.ft.
|
|
226
|
-
this.B.zt(s.ft.Ne),
|
|
225
|
+
(this.B.zt(s.ft.Ne),
|
|
227
226
|
this.B.zt(s.ft.Te),
|
|
228
|
-
this.B.zt(s.ft.ze)
|
|
227
|
+
this.B.zt(s.ft.ze),
|
|
228
|
+
this.B.zt(s.ft.Ae));
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
Ye(i, t) {
|
|
231
231
|
const e = () => {
|
|
232
232
|
"function" == typeof t && t();
|
|
233
233
|
},
|
|
@@ -237,17 +237,17 @@ export default class tr extends t {
|
|
|
237
237
|
return (
|
|
238
238
|
E.error("NetworkManager or StorageManager not available"), void e()
|
|
239
239
|
);
|
|
240
|
-
if (!this.h || !this.h.
|
|
240
|
+
if (!this.h || !this.h.Ze())
|
|
241
241
|
return (
|
|
242
242
|
E.info("Real-time messaging is not enabled, skipping refresh"), void e()
|
|
243
243
|
);
|
|
244
|
-
this.
|
|
244
|
+
this.Qe()
|
|
245
245
|
? E.info("Refreshing real-time messaging configuration")
|
|
246
246
|
: E.info("Fetching initial real-time messaging configuration");
|
|
247
247
|
const o = n.$({}, !0),
|
|
248
|
-
a = n.A(o, h.H.
|
|
248
|
+
a = n.A(o, h.H._e, !1),
|
|
249
249
|
c = new Date().valueOf();
|
|
250
|
-
h.K(r, h.H.
|
|
250
|
+
h.K(r, h.H._e, c),
|
|
251
251
|
l.O({
|
|
252
252
|
url: `${n.V()}/dust/config`,
|
|
253
253
|
headers: a,
|
|
@@ -269,16 +269,16 @@ export default class tr extends t {
|
|
|
269
269
|
E.info(
|
|
270
270
|
"Received real-time messaging configuration from server",
|
|
271
271
|
),
|
|
272
|
-
r.bt(s.ft.
|
|
273
|
-
r.bt(s.ft.
|
|
274
|
-
t.auth ? r.bt(s.ft.
|
|
275
|
-
t.expiration ? r.bt(s.ft.
|
|
276
|
-
this.
|
|
272
|
+
r.bt(s.ft.Ne, t.mite),
|
|
273
|
+
r.bt(s.ft.Te, t.host),
|
|
274
|
+
t.auth ? r.bt(s.ft.ze, t.auth) : r.zt(s.ft.ze),
|
|
275
|
+
t.expiration ? r.bt(s.ft.Ae, t.expiration) : r.zt(s.ft.Ae),
|
|
276
|
+
this.He(),
|
|
277
277
|
"function" == typeof i && i())
|
|
278
278
|
: (E.info(
|
|
279
279
|
"Real-time messaging configuration not available - this SDK version may not be supported",
|
|
280
280
|
),
|
|
281
|
-
this.
|
|
281
|
+
this.Be(),
|
|
282
282
|
e());
|
|
283
283
|
},
|
|
284
284
|
error: (i) => {
|
|
@@ -286,20 +286,20 @@ export default class tr extends t {
|
|
|
286
286
|
},
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
if (!this.h || !this.h.
|
|
291
|
-
if (!this.
|
|
289
|
+
He() {
|
|
290
|
+
if (!this.h || !this.h.Ze()) return;
|
|
291
|
+
if (!this.Qe())
|
|
292
292
|
return void E.error(
|
|
293
293
|
"Cannot start real-time subscription without configuration",
|
|
294
294
|
);
|
|
295
|
-
if (this.
|
|
295
|
+
if (this.Xe())
|
|
296
296
|
return (
|
|
297
297
|
E.info(
|
|
298
298
|
"Real-time messaging auth token has expired, refreshing configuration",
|
|
299
299
|
),
|
|
300
|
-
void this.
|
|
300
|
+
void this.Ye(
|
|
301
301
|
() => {
|
|
302
|
-
this.
|
|
302
|
+
this.He();
|
|
303
303
|
},
|
|
304
304
|
() => {
|
|
305
305
|
E.error(
|
|
@@ -313,25 +313,25 @@ export default class tr extends t {
|
|
|
313
313
|
if (i && t)
|
|
314
314
|
switch (this.Qi) {
|
|
315
315
|
case "sharedworker":
|
|
316
|
-
this.
|
|
316
|
+
this.sn(i, t);
|
|
317
317
|
break;
|
|
318
318
|
case "direct":
|
|
319
319
|
this.xi &&
|
|
320
320
|
(E.info(
|
|
321
321
|
"Real-time connection already exists, closing before starting new subscription",
|
|
322
322
|
),
|
|
323
|
-
this.
|
|
324
|
-
this.
|
|
323
|
+
this.qe()),
|
|
324
|
+
this.en();
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
|
|
327
|
+
on() {
|
|
328
328
|
const i = this.mite,
|
|
329
329
|
t = this.Ri || this.ki;
|
|
330
330
|
return i && t
|
|
331
331
|
? ti(t, i, this.ji, this.yi || void 0, this.Mi || void 0)
|
|
332
332
|
: null;
|
|
333
333
|
}
|
|
334
|
-
|
|
334
|
+
sn(i, t) {
|
|
335
335
|
var s, e, n;
|
|
336
336
|
if ((this.Ki || this._i(), !this.Ki))
|
|
337
337
|
return (
|
|
@@ -339,7 +339,7 @@ export default class tr extends t {
|
|
|
339
339
|
"SharedWorker initialization failed, falling back to direct EventSource",
|
|
340
340
|
),
|
|
341
341
|
(this.Qi = "direct"),
|
|
342
|
-
void this.
|
|
342
|
+
void this.hn()
|
|
343
343
|
);
|
|
344
344
|
this.Ri && E.info(`Using custom real-time messaging host: ${this.Ri}`),
|
|
345
345
|
E.info("Starting real-time subscription via SharedWorker");
|
|
@@ -350,19 +350,19 @@ export default class tr extends t {
|
|
|
350
350
|
mite: i,
|
|
351
351
|
ki: t,
|
|
352
352
|
auth: this.yi || void 0,
|
|
353
|
-
|
|
353
|
+
an: { ln: r, cn: o, un: h },
|
|
354
354
|
});
|
|
355
355
|
}
|
|
356
|
-
|
|
356
|
+
hn() {
|
|
357
357
|
this.xi &&
|
|
358
358
|
(E.info(
|
|
359
359
|
"Real-time connection already exists, closing before starting new subscription",
|
|
360
360
|
),
|
|
361
|
-
this.
|
|
362
|
-
this.
|
|
361
|
+
this.dn()),
|
|
362
|
+
this.en();
|
|
363
363
|
}
|
|
364
|
-
|
|
365
|
-
const t = this.
|
|
364
|
+
en(i) {
|
|
365
|
+
const t = this.on();
|
|
366
366
|
if (t) {
|
|
367
367
|
this.Ri && E.info(`Using custom real-time messaging host: ${this.Ri}`);
|
|
368
368
|
try {
|
|
@@ -381,7 +381,7 @@ export default class tr extends t {
|
|
|
381
381
|
(this.Xi = !0);
|
|
382
382
|
}),
|
|
383
383
|
s.addEventListener("msg", (i) => {
|
|
384
|
-
this.
|
|
384
|
+
this.gn(i.data);
|
|
385
385
|
}),
|
|
386
386
|
(s.onerror = () => {
|
|
387
387
|
const t = s.readyState;
|
|
@@ -395,15 +395,15 @@ export default class tr extends t {
|
|
|
395
395
|
"Gapless reconnection failed, keeping old connection",
|
|
396
396
|
),
|
|
397
397
|
s.close(),
|
|
398
|
-
void (this.zi && this.ji < this.Wi && this.
|
|
399
|
-
: (this.
|
|
398
|
+
void (this.zi && this.ji < this.Wi && this.mn()))
|
|
399
|
+
: (this.dn(),
|
|
400
400
|
this.Xi && (this.Yi++, this.Yi > 1)
|
|
401
401
|
? (E.info(
|
|
402
402
|
"Real-time messaging connection lost twice after successful connect (likely multi-tab conflict), yielding to other tab",
|
|
403
403
|
),
|
|
404
404
|
void (this.zi = !1))
|
|
405
405
|
: void (this.zi && this.ji < this.Wi
|
|
406
|
-
? this.
|
|
406
|
+
? this.mn()
|
|
407
407
|
: (this.ji >= this.Wi &&
|
|
408
408
|
E.error(
|
|
409
409
|
`Max retry attempts (${this.Wi}) reached for real-time messaging, giving up for current session`,
|
|
@@ -420,7 +420,7 @@ export default class tr extends t {
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
|
|
423
|
+
mn() {
|
|
424
424
|
var i, t, s;
|
|
425
425
|
this.ji++;
|
|
426
426
|
const e = (null === (i = this.h) || void 0 === i ? void 0 : i.st()) || c,
|
|
@@ -434,34 +434,34 @@ export default class tr extends t {
|
|
|
434
434
|
`Retrying real-time messaging connection in ${h}ms (attempt ${this.ji}/${this.Wi})`,
|
|
435
435
|
),
|
|
436
436
|
(this.Fi = window.setTimeout(() => {
|
|
437
|
-
(this.Fi = null), this.
|
|
437
|
+
(this.Fi = null), this.He();
|
|
438
438
|
}, h));
|
|
439
439
|
}
|
|
440
|
-
|
|
441
|
-
if (this.
|
|
442
|
-
if (this.
|
|
440
|
+
Oe() {
|
|
441
|
+
if (this.Qe()) {
|
|
442
|
+
if (this.Xe())
|
|
443
443
|
return (
|
|
444
444
|
E.info(
|
|
445
445
|
"Auth token expired during gapless reconnection, falling back to regular reconnection",
|
|
446
446
|
),
|
|
447
|
-
this.
|
|
448
|
-
void this.
|
|
447
|
+
this.qe(),
|
|
448
|
+
void this.He()
|
|
449
449
|
);
|
|
450
450
|
null !== this.Ui && (window.clearTimeout(this.Ui), (this.Ui = null)),
|
|
451
|
-
this.
|
|
451
|
+
this.en(this.xi || void 0);
|
|
452
452
|
} else E.error("Cannot perform gapless reconnection without configuration");
|
|
453
453
|
}
|
|
454
|
-
|
|
454
|
+
qe() {
|
|
455
455
|
var i;
|
|
456
456
|
switch (this.Qi) {
|
|
457
457
|
case "sharedworker":
|
|
458
458
|
null === (i = this.Ki) || void 0 === i || i.disconnect();
|
|
459
459
|
break;
|
|
460
460
|
case "direct":
|
|
461
|
-
this.
|
|
461
|
+
this.dn();
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
|
|
464
|
+
dn() {
|
|
465
465
|
null !== this.Fi && (window.clearTimeout(this.Fi), (this.Fi = null)),
|
|
466
466
|
null !== this.Ui && (window.clearTimeout(this.Ui), (this.Ui = null)),
|
|
467
467
|
this.xi &&
|
|
@@ -469,10 +469,10 @@ export default class tr extends t {
|
|
|
469
469
|
(this.xi = null),
|
|
470
470
|
E.info("Real-time messaging connection closed"));
|
|
471
471
|
}
|
|
472
|
-
|
|
472
|
+
gn(i) {
|
|
473
473
|
try {
|
|
474
474
|
const t = JSON.parse(i);
|
|
475
|
-
this.
|
|
475
|
+
this.ke(t);
|
|
476
476
|
} catch (i) {
|
|
477
477
|
E.warn(
|
|
478
478
|
`Failed to parse real-time message: ${
|
|
@@ -482,33 +482,33 @@ export default class tr extends t {
|
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
changeUser(i = !1) {
|
|
485
|
-
this.
|
|
485
|
+
this.qe(),
|
|
486
486
|
i ||
|
|
487
|
-
(this.
|
|
487
|
+
(this.Qe() &&
|
|
488
488
|
E.info(
|
|
489
489
|
"Clearing cached real-time messaging configuration for user change",
|
|
490
490
|
),
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
491
|
+
this.Be()),
|
|
492
|
+
this.Re();
|
|
493
493
|
}
|
|
494
494
|
clearData(i = !1) {
|
|
495
495
|
(this.zi = !1),
|
|
496
|
-
this.
|
|
496
|
+
this.qe(),
|
|
497
497
|
i &&
|
|
498
|
-
(this.
|
|
498
|
+
(this.Qe() &&
|
|
499
499
|
E.info(
|
|
500
500
|
"Clearing cached real-time messaging configuration (wipeData)",
|
|
501
501
|
),
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
502
|
+
this.Be()),
|
|
503
|
+
this.Re();
|
|
504
504
|
}
|
|
505
505
|
destroy() {
|
|
506
506
|
(this.zi = !1),
|
|
507
|
-
this.
|
|
508
|
-
this.
|
|
507
|
+
this.qe(),
|
|
508
|
+
this.Be(),
|
|
509
509
|
this.Ki && (this.Ki.destroy(), (this.Ki = null)),
|
|
510
|
-
this.Li && (this.
|
|
511
|
-
this.Oi && (this.
|
|
510
|
+
this.Li && (this.Ve("ddr", this.Li), (this.Li = null)),
|
|
511
|
+
this.Oi && (this.Ve("ttl", this.Oi), (this.Oi = null)),
|
|
512
512
|
this.qi &&
|
|
513
513
|
(window.removeEventListener("beforeunload", this.qi), (this.qi = null)),
|
|
514
514
|
this.Gi &&
|
|
@@ -10,7 +10,7 @@ let ie = null,
|
|
|
10
10
|
ue = null,
|
|
11
11
|
me = null,
|
|
12
12
|
de = null;
|
|
13
|
-
const pe = {
|
|
13
|
+
const pe = { pn: null, ke: null };
|
|
14
14
|
function fe(e) {
|
|
15
15
|
re.forEach((n, o) => {
|
|
16
16
|
try {
|
|
@@ -47,7 +47,7 @@ function ge() {
|
|
|
47
47
|
function he() {
|
|
48
48
|
if (!te) return;
|
|
49
49
|
le++;
|
|
50
|
-
const {
|
|
50
|
+
const { ln: e, cn: n, un: o } = te.an;
|
|
51
51
|
let t = ie;
|
|
52
52
|
(null == t || t < e) && (t = e);
|
|
53
53
|
const l = Math.min(
|
|
@@ -60,7 +60,7 @@ function he() {
|
|
|
60
60
|
"[Braze Real-Time] Retrying in " + l + "ms (attempt " + le + "/5)",
|
|
61
61
|
),
|
|
62
62
|
(ce = setTimeout(function () {
|
|
63
|
-
(ce = null), pe.
|
|
63
|
+
(ce = null), pe.pn();
|
|
64
64
|
}, l));
|
|
65
65
|
}
|
|
66
66
|
function ze(e) {
|
|
@@ -94,7 +94,7 @@ function ze(e) {
|
|
|
94
94
|
fe({ type: "connected" });
|
|
95
95
|
}),
|
|
96
96
|
n.addEventListener("msg", function (e) {
|
|
97
|
-
pe.
|
|
97
|
+
pe.ke(e.data);
|
|
98
98
|
}),
|
|
99
99
|
(n.onerror = function () {
|
|
100
100
|
if (
|
|
@@ -127,13 +127,13 @@ function Be(e, n, o) {
|
|
|
127
127
|
switch (o.type) {
|
|
128
128
|
case "connect":
|
|
129
129
|
!te ||
|
|
130
|
-
(te.mite === o.
|
|
130
|
+
(te.mite === o.fn.mite && te.ki === o.fn.ki) ||
|
|
131
131
|
(console.log("[Braze Real-Time] Config changed, reconnecting"),
|
|
132
132
|
ge(),
|
|
133
133
|
(le = 0),
|
|
134
134
|
(ie = null),
|
|
135
135
|
(se = null)),
|
|
136
|
-
(te = o.
|
|
136
|
+
(te = o.fn),
|
|
137
137
|
Te(),
|
|
138
138
|
oe || ae ? oe && e.postMessage({ type: "connected" }) : ze();
|
|
139
139
|
break;
|
|
@@ -165,16 +165,16 @@ function Be(e, n, o) {
|
|
|
165
165
|
console.warn("[Braze Real-Time] Unknown message type:", o.type);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
(pe.
|
|
169
|
-
(pe.
|
|
168
|
+
(pe.pn = ze),
|
|
169
|
+
(pe.ke = function (e) {
|
|
170
170
|
try {
|
|
171
171
|
const t = JSON.parse(e);
|
|
172
172
|
if (!t.type)
|
|
173
173
|
return void console.warn("[Braze Real-Time] Message without type:", t);
|
|
174
174
|
if ("ttl" === t.type && t.body)
|
|
175
175
|
return (
|
|
176
|
-
(n = t.body.
|
|
177
|
-
(o = t.body.
|
|
176
|
+
(n = t.body.Je),
|
|
177
|
+
(o = t.body.Le),
|
|
178
178
|
void (
|
|
179
179
|
"number" == typeof n &&
|
|
180
180
|
("string" == typeof o && (se = o),
|
|
@@ -209,9 +209,9 @@ function Be(e, n, o) {
|
|
|
209
209
|
null !== de && clearTimeout(de),
|
|
210
210
|
ge(),
|
|
211
211
|
(de = setTimeout(function () {
|
|
212
|
-
(de = null), pe.
|
|
212
|
+
(de = null), pe.pn();
|
|
213
213
|
}, t));
|
|
214
|
-
})(t.body.
|
|
214
|
+
})(t.body.Pe, t.body.e);
|
|
215
215
|
console.log(
|
|
216
216
|
"[Braze Real-Time] Routing '" + t.type + "' message to leader",
|
|
217
217
|
),
|
|
@@ -10,10 +10,10 @@ export class DustWorkerBridge {
|
|
|
10
10
|
(this.isConnected = !1),
|
|
11
11
|
(this.Ir = null),
|
|
12
12
|
(this.Mr = null),
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
15
|
-
(this.
|
|
16
|
-
(this.
|
|
13
|
+
(this.Se = i.Se),
|
|
14
|
+
(this.ye = i.ye),
|
|
15
|
+
(this.Me = i.Me),
|
|
16
|
+
(this.De = i.De);
|
|
17
17
|
}
|
|
18
18
|
initialize() {
|
|
19
19
|
if (!isSharedWorkerSupported())
|
|
@@ -36,7 +36,7 @@ export class DustWorkerBridge {
|
|
|
36
36
|
E.error(
|
|
37
37
|
`Real-time messaging worker error: ${i.message || "unknown error"}`,
|
|
38
38
|
),
|
|
39
|
-
null === (e = this.
|
|
39
|
+
null === (e = this.De) ||
|
|
40
40
|
void 0 === e ||
|
|
41
41
|
e.call(this, "SharedWorker error");
|
|
42
42
|
}),
|
|
@@ -64,19 +64,19 @@ export class DustWorkerBridge {
|
|
|
64
64
|
case "connected":
|
|
65
65
|
E.info("Real-time messaging connection established via SharedWorker"),
|
|
66
66
|
(this.isConnected = !0),
|
|
67
|
-
null === (e = this.
|
|
67
|
+
null === (e = this.ye) || void 0 === e || e.call(this);
|
|
68
68
|
break;
|
|
69
69
|
case "disconnected":
|
|
70
70
|
E.info("Real-time messaging connection closed via SharedWorker"),
|
|
71
71
|
(this.isConnected = !1),
|
|
72
|
-
null === (t = this.
|
|
72
|
+
null === (t = this.Me) || void 0 === t || t.call(this);
|
|
73
73
|
break;
|
|
74
74
|
case "message":
|
|
75
|
-
this.
|
|
75
|
+
this.Se(i.data);
|
|
76
76
|
break;
|
|
77
77
|
case "error":
|
|
78
78
|
E.error(`Real-time messaging error: ${i.error}`),
|
|
79
|
-
null === (s = this.
|
|
79
|
+
null === (s = this.De) || void 0 === s || s.call(this, i.error);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
Ur() {
|
|
@@ -105,7 +105,7 @@ export class DustWorkerBridge {
|
|
|
105
105
|
}
|
|
106
106
|
connect(i) {
|
|
107
107
|
this.Wr
|
|
108
|
-
? (this._r({ type: "connect",
|
|
108
|
+
? (this._r({ type: "connect", fn: i }),
|
|
109
109
|
E.info("Connecting to real-time messaging"))
|
|
110
110
|
: E.error("Cannot connect: real-time messaging worker not initialized");
|
|
111
111
|
}
|
|
@@ -115,7 +115,7 @@ export class DustWorkerBridge {
|
|
|
115
115
|
(this.isConnected = !1),
|
|
116
116
|
E.info("Disconnecting from real-time messaging"));
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
Ke() {
|
|
119
119
|
return this.isConnected;
|
|
120
120
|
}
|
|
121
121
|
isInitialized() {
|
|
@@ -7,18 +7,18 @@ export function subscribeToDust() {
|
|
|
7
7
|
const o = nr.o(),
|
|
8
8
|
s = () => {
|
|
9
9
|
if (!o.St()) {
|
|
10
|
-
o.
|
|
10
|
+
o.Ie();
|
|
11
11
|
const r = n.rn(() => {
|
|
12
|
-
t.
|
|
12
|
+
t.Ze() && o.Ye();
|
|
13
13
|
});
|
|
14
|
-
return r && o.wt(r), o.
|
|
14
|
+
return r && o.wt(r), o.Qe() && o.He(), r;
|
|
15
15
|
}
|
|
16
16
|
return o.St();
|
|
17
17
|
};
|
|
18
18
|
return (
|
|
19
19
|
t.Tr(() => {
|
|
20
|
-
r.ao() && (t.
|
|
20
|
+
r.ao() && (t.Ze() ? (o.Ye(), s()) : (o.qe(), o.Qe() && o.Be()));
|
|
21
21
|
}),
|
|
22
|
-
t.
|
|
22
|
+
t.Ze() ? s() : null
|
|
23
23
|
);
|
|
24
24
|
}
|
|
@@ -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
|
-
? je.ra().
|
|
11
|
+
? je.ra().jn(e)
|
|
12
12
|
: (E.info("Not an instance of InAppMessage, ignoring."), !1);
|
|
13
13
|
}
|