@braze/web-sdk 5.3.2 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +20 -4
- package/package.json +1 -1
- package/shared-lib/event-types.js +12 -12
- package/shared-lib/indexed-db-adapter.js +14 -14
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +10 -9
- package/src/Card/card-manager.js +46 -42
- package/src/Card/display/card-display.js +59 -58
- package/src/Card/models/card.js +61 -55
- package/src/Card/models/classic-card.js +1 -1
- package/src/Card/models/control-card.js +1 -1
- package/src/Card/models/image-only.js +1 -1
- package/src/Card/util/card-factory.js +20 -20
- package/src/ContentCards/content-cards-provider.js +140 -140
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +4 -4
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/disable-sdk.js +2 -2
- package/src/Core/enable-sdk.js +2 -2
- package/src/Core/index.js +1 -0
- package/src/Core/is-initialized.js +4 -0
- package/src/Core/log-custom-event.js +14 -14
- package/src/Core/log-purchase.js +8 -8
- package/src/Core/open-session.js +4 -4
- package/src/Core/wipe-data.js +2 -2
- package/src/FeatureFlags/feature-flag-factory.js +5 -5
- package/src/FeatureFlags/feature-flag.js +1 -1
- package/src/FeatureFlags/feature-flags-provider.js +74 -74
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +12 -12
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +29 -29
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +64 -62
- package/src/InAppMessage/in-app-message-manager.js +63 -63
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +10 -10
- package/src/InAppMessage/models/html-message.js +13 -13
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +59 -59
- package/src/InAppMessage/models/modal-message.js +9 -9
- package/src/InAppMessage/models/slide-up-message.js +11 -11
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +42 -40
- package/src/Push/push-manager-factory.js +5 -4
- package/src/Push/push-manager.js +77 -89
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +8 -8
- package/src/User/user.js +29 -29
- package/src/common/base-provider.js +1 -1
- package/src/common/event-logger.js +11 -11
- package/src/common/feed-display.js +18 -17
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +15 -5
- package/src/managers/auth-manager.js +9 -9
- package/src/managers/braze-instance.js +89 -87
- package/src/managers/device-manager.js +17 -17
- package/src/managers/network-manager.js +130 -130
- package/src/managers/server-config-manager.js +24 -24
- package/src/managers/session-manager.js +12 -12
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +31 -31
- package/src/managers/subscription-manager.js +2 -2
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +4 -4
- package/src/models/device.js +2 -2
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +5 -5
- package/src/request-controller.js +130 -130
- package/src/triggers/models/filter.js +9 -9
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +27 -27
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +7 -7
- package/src/triggers/triggers-provider.js +29 -29
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +13 -12
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +17 -17
- package/src/util/user-agent-parser.js +3 -3
- package/src/util/window-utils.js +1 -1
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "../Card/util/card-factory.js";
|
|
11
11
|
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
12
12
|
import T from "../managers/subscription-manager.js";
|
|
13
|
-
import
|
|
13
|
+
import t from "../common/event-logger.js";
|
|
14
14
|
import D from "../util/request-header-utils.js";
|
|
15
15
|
import { randomInclusive as U } from "../util/math.js";
|
|
16
16
|
import { MAX_ERROR_RETRIES_CONTENT_CARDS as k } from "../common/constants.js";
|
|
@@ -22,59 +22,59 @@ import {
|
|
|
22
22
|
export default class v extends y {
|
|
23
23
|
constructor(t, s, i, h, n) {
|
|
24
24
|
super(),
|
|
25
|
-
(this.
|
|
25
|
+
(this.yt = t),
|
|
26
26
|
(this.u = s),
|
|
27
|
-
(this.
|
|
28
|
-
(this.
|
|
29
|
-
(this
|
|
30
|
-
(this.
|
|
27
|
+
(this.qt = i),
|
|
28
|
+
(this.Jt = h),
|
|
29
|
+
(this.$t = n),
|
|
30
|
+
(this.yt = t),
|
|
31
31
|
(this.u = s),
|
|
32
|
-
(this.
|
|
33
|
-
(this.
|
|
34
|
-
(this
|
|
35
|
-
(this.
|
|
36
|
-
e
|
|
37
|
-
(this.
|
|
38
|
-
(this.
|
|
32
|
+
(this.qt = i),
|
|
33
|
+
(this.Jt = h),
|
|
34
|
+
(this.$t = n),
|
|
35
|
+
(this.Bt = new T()),
|
|
36
|
+
e.Ht(this.Bt),
|
|
37
|
+
(this.Kt = 0),
|
|
38
|
+
(this.Qt = 0),
|
|
39
39
|
(this.cards = []),
|
|
40
|
-
this.
|
|
41
|
-
const o = A.
|
|
42
|
-
new A(o, r).
|
|
43
|
-
this.
|
|
40
|
+
this.Yt();
|
|
41
|
+
const o = A.ts.Zt;
|
|
42
|
+
new A(o, r).ss(o.hs.es, (t) => {
|
|
43
|
+
this.rs(t);
|
|
44
44
|
}),
|
|
45
|
-
(this.hs = null),
|
|
46
|
-
(this.rs = null),
|
|
47
45
|
(this.ns = null),
|
|
48
46
|
(this.os = null),
|
|
49
47
|
(this.ls = null),
|
|
50
|
-
(this.us =
|
|
51
|
-
(this.cs =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return this.hs;
|
|
55
|
-
}
|
|
56
|
-
ds(t) {
|
|
57
|
-
this.hs = t;
|
|
48
|
+
(this.us = null),
|
|
49
|
+
(this.cs = null),
|
|
50
|
+
(this.fs = 10),
|
|
51
|
+
(this.ds = 0);
|
|
58
52
|
}
|
|
59
53
|
ps() {
|
|
60
|
-
return this.
|
|
54
|
+
return this.ns;
|
|
61
55
|
}
|
|
62
56
|
vs(t) {
|
|
63
|
-
this.
|
|
57
|
+
this.ns = t;
|
|
58
|
+
}
|
|
59
|
+
ws() {
|
|
60
|
+
return this.os;
|
|
61
|
+
}
|
|
62
|
+
Cs(t) {
|
|
63
|
+
this.os = t;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
Yt() {
|
|
66
66
|
if (!this.u) return;
|
|
67
|
-
const t = this.u.j(o.C.
|
|
67
|
+
const t = this.u.j(o.C.bs) || [],
|
|
68
68
|
s = [];
|
|
69
69
|
for (let i = 0; i < t.length; i++) {
|
|
70
70
|
const e = S(t[i]);
|
|
71
71
|
null != e && s.push(e);
|
|
72
72
|
}
|
|
73
|
-
(this.cards = this.
|
|
74
|
-
(this.
|
|
75
|
-
(this.
|
|
73
|
+
(this.cards = this.gs(this.ys(s, !1))),
|
|
74
|
+
(this.Kt = this.u.j(o.C.js) || this.Kt),
|
|
75
|
+
(this.Qt = this.u.j(o.C.Rs) || this.Qt);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
Ns(t, s = !1, i = 0, e = 0) {
|
|
78
78
|
let h;
|
|
79
79
|
if (s) {
|
|
80
80
|
h = [];
|
|
@@ -95,7 +95,7 @@ export default class v extends y {
|
|
|
95
95
|
const t = N(e);
|
|
96
96
|
null != t && h.push(t);
|
|
97
97
|
} else {
|
|
98
|
-
if (!r.
|
|
98
|
+
if (!r.Lt(e))
|
|
99
99
|
for (let t = 0; t < h.length; t++)
|
|
100
100
|
if (e.id === h[t].id) {
|
|
101
101
|
h.splice(t, 1);
|
|
@@ -103,57 +103,57 @@ export default class v extends y {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
(this.cards = this.
|
|
107
|
-
this.
|
|
108
|
-
(this.
|
|
109
|
-
(this.
|
|
110
|
-
this.u && (this.u.
|
|
106
|
+
(this.cards = this.gs(this.ys(h, s))),
|
|
107
|
+
this.Ts(),
|
|
108
|
+
(this.Kt = i),
|
|
109
|
+
(this.Qt = e),
|
|
110
|
+
this.u && (this.u.I(o.C.js, this.Kt), this.u.I(o.C.Rs, this.Qt));
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
if (this.
|
|
114
|
-
this.u && this.u.
|
|
112
|
+
Ss(t) {
|
|
113
|
+
if (this.Ds() && null != t && t.cards) {
|
|
114
|
+
this.u && this.u.I(o.C.Us, e.ks());
|
|
115
115
|
const s = t.full_sync;
|
|
116
|
-
s || this.
|
|
117
|
-
this.
|
|
118
|
-
this.
|
|
116
|
+
s || this.Yt(),
|
|
117
|
+
this.Ns(t.cards, s, t.last_full_sync_at, t.last_card_updated_at),
|
|
118
|
+
this.Bt.Rt(this.As(!0));
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
this.u && this.u.
|
|
121
|
+
Fs(t) {
|
|
122
|
+
this.u && this.u.I(o.C.xs, t);
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
zs(s, e, h) {
|
|
125
125
|
const r = () => {
|
|
126
|
-
this.
|
|
126
|
+
this.qs(e, h, !0);
|
|
127
127
|
},
|
|
128
|
-
n =
|
|
128
|
+
n = s ? b(s) : null;
|
|
129
129
|
let l;
|
|
130
|
-
if ((this.
|
|
130
|
+
if ((this.Es(), !n || !n["retry-after"])) return void this.Fs(0);
|
|
131
131
|
const a = n["retry-after"];
|
|
132
132
|
if (isNaN(a) && !isNaN(Date.parse(a)))
|
|
133
133
|
(l = Date.parse(a) - new Date().getTime()), l < 0 && r();
|
|
134
134
|
else {
|
|
135
135
|
if (isNaN(parseFloat(a.toString()))) {
|
|
136
|
-
const
|
|
136
|
+
const s =
|
|
137
137
|
"Received unexpected value for retry-after header in /sync response";
|
|
138
|
-
return
|
|
138
|
+
return t.q(i.Ls, { e: s + ": " + a }), void this.Fs(0);
|
|
139
139
|
}
|
|
140
140
|
l = 1e3 * parseFloat(a.toString());
|
|
141
141
|
}
|
|
142
|
-
this.
|
|
142
|
+
this.ls = window.setTimeout(() => {
|
|
143
143
|
r();
|
|
144
144
|
}, l);
|
|
145
145
|
let u = 0;
|
|
146
|
-
this.u && (u = this.u.j(o.C.
|
|
146
|
+
this.u && (u = this.u.j(o.C.xs)),
|
|
147
147
|
(null == u || isNaN(parseInt(u.toString()))) && (u = 0),
|
|
148
|
-
this.
|
|
148
|
+
this.Fs(parseInt(u.toString()) + 1);
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
rs(t) {
|
|
151
151
|
var s;
|
|
152
|
-
if (!this.
|
|
153
|
-
this.
|
|
152
|
+
if (!this.Ds()) return;
|
|
153
|
+
this.Yt();
|
|
154
154
|
const i = this.cards.slice();
|
|
155
155
|
let e = null;
|
|
156
|
-
e = null === (s = this.
|
|
156
|
+
e = null === (s = this.yt) || void 0 === s ? void 0 : s.getUserId();
|
|
157
157
|
for (let s = 0; s < t.length; s++)
|
|
158
158
|
if (e === t[s].userId || (null == e && null == t[s].userId)) {
|
|
159
159
|
const e = t[s].card;
|
|
@@ -167,7 +167,7 @@ export default class v extends y {
|
|
|
167
167
|
const t = N(e);
|
|
168
168
|
null != t && i.push(t);
|
|
169
169
|
} else {
|
|
170
|
-
if (!h.
|
|
170
|
+
if (!h.Lt(e))
|
|
171
171
|
for (let t = 0; t < i.length; t++)
|
|
172
172
|
if (e.id === i[t].id) {
|
|
173
173
|
i.splice(t, 1);
|
|
@@ -175,9 +175,9 @@ export default class v extends y {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
(this.cards = this.
|
|
178
|
+
(this.cards = this.gs(this.ys(i, !1))), this.Ts(), this.Bt.Rt(this.As(!0));
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
ys(t, s) {
|
|
181
181
|
let i = {},
|
|
182
182
|
e = {},
|
|
183
183
|
h = {};
|
|
@@ -198,11 +198,11 @@ export default class v extends y {
|
|
|
198
198
|
return (
|
|
199
199
|
s &&
|
|
200
200
|
this.u &&
|
|
201
|
-
(this.u.
|
|
201
|
+
(this.u.I(o.C.v, r), this.u.I(o.C.H, n), this.u.I(o.C.A, l)),
|
|
202
202
|
t
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
|
-
|
|
205
|
+
gs(t) {
|
|
206
206
|
const s = [],
|
|
207
207
|
i = new Date();
|
|
208
208
|
let e = {};
|
|
@@ -210,7 +210,7 @@ export default class v extends y {
|
|
|
210
210
|
let h = !1;
|
|
211
211
|
for (let n = 0; n < t.length; n++) {
|
|
212
212
|
const o = t[n].url;
|
|
213
|
-
if (!this.
|
|
213
|
+
if (!this.Jt && o && R(o)) {
|
|
214
214
|
r.error(
|
|
215
215
|
`Card with url ${o} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
|
|
216
216
|
);
|
|
@@ -225,92 +225,92 @@ export default class v extends y {
|
|
|
225
225
|
s && (e[s] = !0), (h = !0);
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
return h && this.u && this.u.
|
|
228
|
+
return h && this.u && this.u.I(o.C.A, e), s;
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
Ts() {
|
|
231
231
|
var t;
|
|
232
232
|
const s = [];
|
|
233
233
|
for (let t = 0; t < this.cards.length; t++) s.push(this.cards[t].Y());
|
|
234
|
-
null === (t = this.u) || void 0 === t || t.
|
|
235
|
-
}
|
|
236
|
-
zs() {
|
|
237
|
-
this.ns && (clearTimeout(this.ns), (this.ns = null));
|
|
234
|
+
null === (t = this.u) || void 0 === t || t.I(o.C.bs, s);
|
|
238
235
|
}
|
|
239
236
|
Es() {
|
|
240
|
-
|
|
237
|
+
this.ls && (clearTimeout(this.ls), (this.ls = null));
|
|
241
238
|
}
|
|
242
|
-
|
|
243
|
-
this.
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
Is() {
|
|
240
|
+
null != this.us && (clearTimeout(this.us), (this.us = null));
|
|
241
|
+
}
|
|
242
|
+
Js(t = 1e3 * this.fs, s, i) {
|
|
243
|
+
this.Is(),
|
|
244
|
+
(this.us = window.setTimeout(() => {
|
|
245
|
+
this.qs(s, i, !0);
|
|
246
246
|
}, t)),
|
|
247
|
-
(this.
|
|
247
|
+
(this.cs = t);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
qs(t, s, i = !1, h = !0) {
|
|
250
250
|
var r;
|
|
251
|
-
const n = this
|
|
251
|
+
const n = this.$t,
|
|
252
252
|
l = this.u;
|
|
253
253
|
if (!n || !l) return void ("function" == typeof s && s());
|
|
254
|
-
if ((!i && (this.
|
|
254
|
+
if ((!i && (this.Es(), this.Fs(0)), !this.Ds()))
|
|
255
255
|
return void (
|
|
256
|
-
null === (r = this.
|
|
256
|
+
null === (r = this.qt) ||
|
|
257
257
|
void 0 === r ||
|
|
258
|
-
r.
|
|
259
|
-
this.
|
|
258
|
+
r.Ms(() => {
|
|
259
|
+
this.qs(t, s);
|
|
260
260
|
})
|
|
261
261
|
);
|
|
262
|
-
h && this.
|
|
263
|
-
const a = n
|
|
264
|
-
l.j(o.C.
|
|
265
|
-
(a.last_full_sync_at = this.
|
|
266
|
-
(a.last_card_updated_at = this.
|
|
267
|
-
const u = n
|
|
262
|
+
h && this.Is();
|
|
263
|
+
const a = n.$s({}, !0);
|
|
264
|
+
l.j(o.C.Us) !== e.ks() && this.Bs(),
|
|
265
|
+
(a.last_full_sync_at = this.Kt),
|
|
266
|
+
(a.last_card_updated_at = this.Qt);
|
|
267
|
+
const u = n.Ps(a, D._s.Xs, i);
|
|
268
268
|
let c = !1;
|
|
269
|
-
n.
|
|
269
|
+
n.Gs(
|
|
270
270
|
a,
|
|
271
271
|
(i = -1) => {
|
|
272
272
|
if (this.u) {
|
|
273
273
|
const t = new Date().valueOf();
|
|
274
|
-
D.
|
|
274
|
+
D.Hs(this.u, D._s.Xs, t);
|
|
275
275
|
}
|
|
276
276
|
-1 !== i && u.push(["X-Braze-Req-Tokens-Remaining", i.toString()]),
|
|
277
|
-
C.
|
|
278
|
-
url: `${n.
|
|
277
|
+
C.Ks({
|
|
278
|
+
url: `${n.Os()}/content_cards/sync`,
|
|
279
279
|
data: a,
|
|
280
280
|
headers: u,
|
|
281
281
|
L: (i, e) => {
|
|
282
|
-
if (!n.
|
|
282
|
+
if (!n.Qs(a, i, u))
|
|
283
283
|
return (c = !0), void ("function" == typeof s && s());
|
|
284
|
-
n.
|
|
285
|
-
this.
|
|
286
|
-
this.
|
|
284
|
+
n.Vs(),
|
|
285
|
+
this.zs(e, t, s),
|
|
286
|
+
this.Ss(i),
|
|
287
287
|
(c = !1),
|
|
288
|
-
D.
|
|
288
|
+
D.Ws(this.u, D._s.Xs, 1),
|
|
289
289
|
"function" == typeof t && t();
|
|
290
290
|
},
|
|
291
291
|
error: (t) => {
|
|
292
|
-
n.
|
|
292
|
+
n.Ys(t, "retrieving content cards"),
|
|
293
293
|
(c = !0),
|
|
294
294
|
"function" == typeof s && s();
|
|
295
295
|
},
|
|
296
|
-
|
|
297
|
-
if (c && h && !this.
|
|
298
|
-
D.
|
|
299
|
-
let i = this.
|
|
300
|
-
(null == i || i < 1e3 * this.
|
|
301
|
-
this.
|
|
302
|
-
(this.
|
|
296
|
+
Zs: () => {
|
|
297
|
+
if (c && h && !this.us && this.ds + 1 < k) {
|
|
298
|
+
D.ti(this.u, D._s.Xs);
|
|
299
|
+
let i = this.cs;
|
|
300
|
+
(null == i || i < 1e3 * this.fs) && (i = 1e3 * this.fs),
|
|
301
|
+
this.Js(Math.min(3e5, U(1e3 * this.fs, 3 * i)), t, s),
|
|
302
|
+
(this.ds = this.ds + 1);
|
|
303
303
|
}
|
|
304
304
|
},
|
|
305
305
|
});
|
|
306
306
|
},
|
|
307
|
-
D.
|
|
307
|
+
D._s.Xs,
|
|
308
308
|
s,
|
|
309
309
|
);
|
|
310
310
|
}
|
|
311
|
-
|
|
312
|
-
t || this.
|
|
313
|
-
const s = this.
|
|
311
|
+
As(t) {
|
|
312
|
+
t || this.Yt();
|
|
313
|
+
const s = this.gs(this.cards);
|
|
314
314
|
s.sort((t, s) =>
|
|
315
315
|
t.pinned && !s.pinned
|
|
316
316
|
? -1
|
|
@@ -322,52 +322,52 @@ export default class v extends y {
|
|
|
322
322
|
? 1
|
|
323
323
|
: 0,
|
|
324
324
|
);
|
|
325
|
-
let i = Math.max(this.
|
|
325
|
+
let i = Math.max(this.Qt || 0, this.Kt || 0);
|
|
326
326
|
return (
|
|
327
327
|
0 === i && (i = void 0),
|
|
328
|
-
this.u && this.u.j(o.C.
|
|
328
|
+
this.u && this.u.j(o.C.Rs) === this.Qt && void 0 === i && (i = this.Qt),
|
|
329
329
|
new ContentCards(s, l(i))
|
|
330
330
|
);
|
|
331
331
|
}
|
|
332
|
-
|
|
333
|
-
return this.
|
|
332
|
+
si(t) {
|
|
333
|
+
return this.Bt.Nt(t);
|
|
334
334
|
}
|
|
335
|
-
|
|
336
|
-
(this.
|
|
337
|
-
(this.
|
|
338
|
-
this.u && (this.u.
|
|
335
|
+
Bs() {
|
|
336
|
+
(this.Kt = 0),
|
|
337
|
+
(this.Qt = 0),
|
|
338
|
+
this.u && (this.u.ii(o.C.js), this.u.ii(o.C.Rs));
|
|
339
339
|
}
|
|
340
340
|
changeUser(t) {
|
|
341
341
|
t ||
|
|
342
342
|
((this.cards = []),
|
|
343
|
-
this.
|
|
343
|
+
this.Bt.Rt(new ContentCards(this.cards.slice(), null)),
|
|
344
344
|
this.u &&
|
|
345
|
-
(this.u.
|
|
346
|
-
this.u.
|
|
347
|
-
this.u.
|
|
348
|
-
this.u.
|
|
349
|
-
this.
|
|
345
|
+
(this.u.ii(o.C.bs),
|
|
346
|
+
this.u.ii(o.C.v),
|
|
347
|
+
this.u.ii(o.C.H),
|
|
348
|
+
this.u.ii(o.C.A))),
|
|
349
|
+
this.Bs();
|
|
350
350
|
}
|
|
351
351
|
clearData(t) {
|
|
352
|
-
(this.
|
|
353
|
-
(this.
|
|
352
|
+
(this.Kt = 0),
|
|
353
|
+
(this.Qt = 0),
|
|
354
354
|
(this.cards = []),
|
|
355
|
-
this.
|
|
355
|
+
this.Bt.Rt(new ContentCards(this.cards.slice(), null)),
|
|
356
356
|
t &&
|
|
357
357
|
this.u &&
|
|
358
|
-
(this.u.
|
|
359
|
-
this.u.
|
|
360
|
-
this.u.
|
|
361
|
-
this.u.
|
|
362
|
-
this.u.
|
|
363
|
-
this.u.
|
|
358
|
+
(this.u.ii(o.C.bs),
|
|
359
|
+
this.u.ii(o.C.v),
|
|
360
|
+
this.u.ii(o.C.H),
|
|
361
|
+
this.u.ii(o.C.A),
|
|
362
|
+
this.u.ii(o.C.js),
|
|
363
|
+
this.u.ii(o.C.Rs));
|
|
364
364
|
}
|
|
365
|
-
|
|
365
|
+
Ds() {
|
|
366
366
|
return (
|
|
367
|
-
!!this.
|
|
367
|
+
!!this.qt && (!!this.qt.ei() || (0 !== this.qt.hi() && this.ri(), !1))
|
|
368
368
|
);
|
|
369
369
|
}
|
|
370
|
-
|
|
371
|
-
this.
|
|
370
|
+
ri() {
|
|
371
|
+
this.Bt.Rt(new ContentCards([], new Date())), this.u && this.u.ii(o.C.bs);
|
|
372
372
|
}
|
|
373
373
|
}
|
|
@@ -3,14 +3,14 @@ import g from "./content-cards-provider-factory.js";
|
|
|
3
3
|
export function subscribeToContentCardsUpdates(r) {
|
|
4
4
|
if (!e.X()) return;
|
|
5
5
|
const t = g.rr(),
|
|
6
|
-
n = t.
|
|
7
|
-
if (!t.
|
|
6
|
+
n = t.si(r);
|
|
7
|
+
if (!t.ws()) {
|
|
8
8
|
const r = e.cr();
|
|
9
9
|
if (r) {
|
|
10
10
|
const n = r.mr(() => {
|
|
11
|
-
t.
|
|
11
|
+
t.qs();
|
|
12
12
|
});
|
|
13
|
-
n && t.
|
|
13
|
+
n && t.Cs(n);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
return n;
|
|
@@ -19,11 +19,11 @@ export function showContentCards(n, t) {
|
|
|
19
19
|
let o = !1;
|
|
20
20
|
null == n && ((n = document.body), (o = !0));
|
|
21
21
|
const i = e.nn(L.tn) || e.nn(L.en) || !1,
|
|
22
|
-
a = g.rr().
|
|
22
|
+
a = g.rr().As(!1);
|
|
23
23
|
"function" == typeof t && F(a, t(a.cards.slice()), a.lastUpdated, null, i);
|
|
24
24
|
const s = I(a, i, o),
|
|
25
25
|
f = g.rr(),
|
|
26
|
-
l = f.
|
|
26
|
+
l = f.ps();
|
|
27
27
|
(null == a.lastUpdated ||
|
|
28
28
|
new Date().valueOf() - a.lastUpdated.valueOf() > ContentCards.ur) &&
|
|
29
29
|
(null == l || new Date().valueOf() - l > ContentCards.ur) &&
|
|
@@ -31,7 +31,7 @@ export function showContentCards(n, t) {
|
|
|
31
31
|
`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`,
|
|
32
32
|
),
|
|
33
33
|
$(a, s),
|
|
34
|
-
f.
|
|
34
|
+
f.vs(new Date().valueOf()));
|
|
35
35
|
const c = new Date().valueOf(),
|
|
36
36
|
u = subscribeToContentCardsUpdates(function (n) {
|
|
37
37
|
const e = s.querySelectorAll(".ab-refresh-button")[0];
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -7,8 +7,8 @@ export function disableSDK() {
|
|
|
7
7
|
const s = new Q.ee(null, !0),
|
|
8
8
|
a = "This-cookie-will-expire-in-" + s.ne();
|
|
9
9
|
s.store(o.se, a);
|
|
10
|
-
const i = A.
|
|
11
|
-
new A(i, r).setItem(i.
|
|
10
|
+
const i = A.ts.Zt;
|
|
11
|
+
new A(i, r).setItem(i.hs.ae, i.ie, !0),
|
|
12
12
|
r.info("disableSDK was called"),
|
|
13
13
|
e.destroy(!1),
|
|
14
14
|
e.oe(!0);
|
package/src/Core/enable-sdk.js
CHANGED
|
@@ -3,8 +3,8 @@ import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
|
3
3
|
import Q, { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
4
4
|
export function enableSDK() {
|
|
5
5
|
new Q.ee(null, !0).remove(o.se);
|
|
6
|
-
const a = A.
|
|
7
|
-
new A(a, r).re(a.
|
|
6
|
+
const a = A.ts.Zt;
|
|
7
|
+
new A(a, r).re(a.hs.ae, a.ie),
|
|
8
8
|
r.info("enableSDK was called"),
|
|
9
9
|
e.destroy(!1),
|
|
10
10
|
e.oe(!1);
|
package/src/Core/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { getDeviceId } from "./get-device-id.js";
|
|
|
9
9
|
export { getUser } from "./get-user.js";
|
|
10
10
|
export { initialize } from "./initialize.js";
|
|
11
11
|
export { isDisabled } from "./is-disabled.js";
|
|
12
|
+
export { isInitialized } from "./is-initialized.js";
|
|
12
13
|
export { logCustomEvent } from "./log-custom-event.js";
|
|
13
14
|
export { logPurchase } from "./log-purchase.js";
|
|
14
15
|
export { openSession } from "./open-session.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import t from "../common/event-logger.js";
|
|
3
3
|
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
4
4
|
import tt from "../triggers/models/trigger-events.js";
|
|
5
5
|
import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
|
|
@@ -8,31 +8,31 @@ import {
|
|
|
8
8
|
validateCustomString as rt,
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
10
|
import { LOG_CUSTOM_EVENT_STRING as nt } from "../common/constants.js";
|
|
11
|
-
export function logCustomEvent(
|
|
11
|
+
export function logCustomEvent(o, n) {
|
|
12
12
|
if (!e.X()) return !1;
|
|
13
|
-
if (null ==
|
|
13
|
+
if (null == o || o.length <= 0)
|
|
14
14
|
return (
|
|
15
15
|
r.error(
|
|
16
|
-
`logCustomEvent requires a non-empty eventName, got "${
|
|
16
|
+
`logCustomEvent requires a non-empty eventName, got "${o}". Ignoring event.`,
|
|
17
17
|
),
|
|
18
18
|
!1
|
|
19
19
|
);
|
|
20
|
-
if (!rt(
|
|
21
|
-
const [
|
|
22
|
-
|
|
20
|
+
if (!rt(o, "log custom event", "the event name")) return !1;
|
|
21
|
+
const [s, m] = ot(
|
|
22
|
+
n,
|
|
23
23
|
nt,
|
|
24
24
|
"eventProperties",
|
|
25
|
-
`log custom event "${
|
|
25
|
+
`log custom event "${o}"`,
|
|
26
26
|
"event",
|
|
27
27
|
);
|
|
28
|
-
if (!
|
|
28
|
+
if (!s) return !1;
|
|
29
29
|
const g = e.ir();
|
|
30
|
-
if (g && g.me(
|
|
31
|
-
return r.info(`Custom Event "${
|
|
32
|
-
const f =
|
|
30
|
+
if (g && g.me(o))
|
|
31
|
+
return r.info(`Custom Event "${o}" is blocklisted, ignoring.`), !1;
|
|
32
|
+
const f = t.q(i.CustomEvent, { n: o, p: m });
|
|
33
33
|
if (f.L) {
|
|
34
|
-
r.info(`Logged custom event "${
|
|
35
|
-
for (const
|
|
34
|
+
r.info(`Logged custom event "${o}".`);
|
|
35
|
+
for (const t of f.ge) et.rr().fe(tt.ue, [o, n], t);
|
|
36
36
|
}
|
|
37
37
|
return f.L;
|
|
38
38
|
}
|
package/src/Core/log-purchase.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
validateCustomProperties as ot,
|
|
8
8
|
validateCustomString as rt,
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
|
-
import
|
|
11
|
-
export function logPurchase(o, n,
|
|
10
|
+
import t from "../common/event-logger.js";
|
|
11
|
+
export function logPurchase(o, n, s, D, u) {
|
|
12
12
|
if (!e.X()) return !1;
|
|
13
13
|
if (
|
|
14
|
-
(null ==
|
|
14
|
+
(null == s && (s = "USD"), null == D && (D = 1), null == o || o.length <= 0)
|
|
15
15
|
)
|
|
16
16
|
return (
|
|
17
17
|
r.error(
|
|
@@ -38,7 +38,7 @@ export function logPurchase(o, n, t, D, u) {
|
|
|
38
38
|
),
|
|
39
39
|
!1
|
|
40
40
|
);
|
|
41
|
-
|
|
41
|
+
s = null != s ? s.toUpperCase() : s;
|
|
42
42
|
if (
|
|
43
43
|
-1 ===
|
|
44
44
|
[
|
|
@@ -213,10 +213,10 @@ export function logPurchase(o, n, t, D, u) {
|
|
|
213
213
|
"ZMK",
|
|
214
214
|
"ZMW",
|
|
215
215
|
"ZWL",
|
|
216
|
-
].indexOf(
|
|
216
|
+
].indexOf(s)
|
|
217
217
|
)
|
|
218
218
|
return (
|
|
219
|
-
r.error(`logPurchase requires a valid currencyCode, got ${
|
|
219
|
+
r.error(`logPurchase requires a valid currencyCode, got ${s}, ignoring.`),
|
|
220
220
|
!1
|
|
221
221
|
);
|
|
222
222
|
const [P, R] = ot(
|
|
@@ -230,9 +230,9 @@ export function logPurchase(o, n, t, D, u) {
|
|
|
230
230
|
const c = e.ir();
|
|
231
231
|
if (c && c.Dr(o))
|
|
232
232
|
return r.info(`Purchase "${o}" is blocklisted, ignoring.`), !1;
|
|
233
|
-
const l =
|
|
233
|
+
const l = t.q(i.Pr, { pid: o, c: s, p: a, q: g, pr: R });
|
|
234
234
|
if (l.L) {
|
|
235
|
-
r.info(`Logged ${g} purchase${g > 1 ? "s" : ""} of "${o}" for ${
|
|
235
|
+
r.info(`Logged ${g} purchase${g > 1 ? "s" : ""} of "${o}" for ${s} ${a}.`);
|
|
236
236
|
for (const r of l.ge) et.rr().fe(tt.Rr, [o, u], r);
|
|
237
237
|
}
|
|
238
238
|
return l.L;
|