@braze/web-sdk 6.7.1 → 6.9.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 +165 -38
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +2 -2
- package/shared-lib/event-types.js +16 -16
- package/shared-lib/indexed-db-adapter.js +65 -65
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +1 -1
- package/src/Banner/banner-provider.js +67 -59
- package/src/Banner/banner.js +40 -19
- package/src/Banner/dismiss-banner.js +4 -0
- package/src/Banner/display/banner-to-html.js +10 -10
- package/src/Banner/display/destroy-banner-html.js +2 -2
- package/src/Banner/get-all-banners.js +6 -6
- package/src/Banner/get-banner.js +6 -6
- package/src/Banner/index.js +1 -0
- package/src/Banner/log-banner-click.js +7 -7
- package/src/Banner/log-banner-dismissal.js +7 -7
- package/src/Banner/log-banner-impressions.js +27 -18
- package/src/Banner/request-banners-refresh.js +8 -8
- package/src/Banner/subscribe-to-banners-updates.js +5 -5
- package/src/Banner/ui/insert-banner.js +8 -8
- package/src/Card/card-manager.js +31 -31
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-content-card-click.js +2 -2
- package/src/Card/log-content-card-impressions.js +4 -4
- package/src/Card/models/captioned-image.js +15 -15
- package/src/Card/models/card.js +89 -89
- package/src/Card/models/classic-card.js +16 -16
- package/src/Card/models/control-card.js +7 -7
- package/src/Card/models/image-only.js +13 -13
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +13 -11
- package/src/ContentCards/content-cards-provider.js +105 -105
- 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 +10 -10
- package/src/ContentCards/ui/show-content-cards.js +7 -7
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +5 -5
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +4 -4
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/handle-braze-action.js +5 -5
- package/src/Core/index.js +1 -0
- package/src/Core/log-custom-event.js +5 -5
- package/src/Core/log-ecommerce-event.js +29 -0
- package/src/Core/log-purchase.js +23 -198
- package/src/Core/open-session.js +10 -10
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +1 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +6 -6
- package/src/DUST/dust-connection-core.js +1 -0
- package/src/DUST/dust-provider-factory.js +10 -10
- package/src/DUST/dust-provider.js +258 -226
- package/src/DUST/dust-shared-worker-code.js +1 -1
- package/src/DUST/dust-shared-worker-impl.js +97 -103
- package/src/DUST/dust-worker-bridge.js +55 -40
- package/src/DUST/subscribe-to-dust.js +7 -7
- package/src/FeatureFlags/feature-flag-factory.js +8 -8
- package/src/FeatureFlags/feature-flag.js +3 -3
- package/src/FeatureFlags/feature-flags-provider.js +21 -21
- package/src/FeatureFlags/log-feature-flag-impression.js +5 -5
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +1 -1
- package/src/InAppMessage/constants.js +3 -3
- package/src/InAppMessage/defer-in-app-message.js +3 -3
- package/src/InAppMessage/display/html-message-to-html.js +4 -4
- package/src/InAppMessage/display/in-app-message-to-html.js +32 -32
- package/src/InAppMessage/display/modal-utils.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +36 -36
- package/src/InAppMessage/in-app-message-manager.js +35 -35
- package/src/InAppMessage/log-in-app-message-button-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +9 -9
- package/src/InAppMessage/models/html-message.js +2 -2
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +34 -34
- package/src/InAppMessage/models/modal-message.js +7 -7
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +20 -20
- package/src/Push/push-manager.js +44 -44
- package/src/User/user-manager.js +19 -19
- package/src/User/user.js +17 -17
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +1 -0
- package/src/common/content-cards-display.js +6 -6
- package/src/common/event-logger.js +3 -3
- package/src/common/properties-base.js +3 -3
- package/src/l10n/l10n-manager.js +2 -2
- package/src/managers/auth-manager.js +11 -11
- package/src/managers/braze-instance.js +59 -59
- package/src/managers/device-manager.js +9 -9
- package/src/managers/network-manager.js +65 -63
- package/src/managers/server-config-manager.js +110 -93
- package/src/managers/session-manager.js +20 -20
- package/src/managers/storage-manager-factory.js +9 -9
- package/src/managers/storage-manager.js +137 -137
- package/src/managers/subscription-manager.js +2 -2
- package/src/managers/utils.js +1 -1
- package/src/models/braze-event.js +2 -2
- package/src/models/identifier.js +5 -5
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +46 -28
- package/src/request-controller.js +124 -124
- 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 +2 -2
- package/src/triggers/models/filter.js +1 -1
- package/src/triggers/models/in-app-message-click-data.js +5 -5
- 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 +5 -5
- package/src/triggers/models/trigger-condition.js +45 -45
- package/src/triggers/models/trigger-events.js +3 -3
- package/src/triggers/models/trigger.js +30 -30
- package/src/triggers/triggers-provider.js +63 -63
- package/src/types.js +5 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +6 -6
- package/src/util/browser-detector.js +13 -13
- package/src/util/client-hints-parser.js +5 -5
- package/src/util/code-utils.js +2 -2
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/dom-utils.js +8 -8
- package/src/util/ecommerce-event-validation.js +343 -0
- package/src/util/html-display-utils.js +11 -11
- package/src/util/iso-4217-currency-codes.js +176 -0
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +10 -10
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +15 -15
- package/src/util/validation-utils.js +14 -14
|
@@ -17,61 +17,61 @@ import {
|
|
|
17
17
|
REQUEST_BACKOFF_MIN_SLEEP_MS_DEFAULT as d,
|
|
18
18
|
REQUEST_BACKOFF_SCALE_FACTOR_DEFAULT as m,
|
|
19
19
|
} from "../common/constants.js";
|
|
20
|
-
import { logger as
|
|
20
|
+
import { logger as b, IndexedDBAdapter as et } from "../../shared-lib/index.js";
|
|
21
21
|
export default class rr extends t {
|
|
22
22
|
constructor(t, s, i, e, h) {
|
|
23
23
|
super(),
|
|
24
24
|
(this.Ss = t),
|
|
25
|
-
(this.
|
|
25
|
+
(this.j = s),
|
|
26
26
|
(this.h = i),
|
|
27
27
|
(this.Ts = e),
|
|
28
28
|
(this.B = h),
|
|
29
29
|
(this.Ss = t),
|
|
30
|
-
(this.
|
|
30
|
+
(this.j = s),
|
|
31
31
|
(this.h = i),
|
|
32
32
|
(this.Ts = e),
|
|
33
33
|
(this.B = h),
|
|
34
34
|
(this.Rs = new f()),
|
|
35
35
|
r.S(this.Rs),
|
|
36
36
|
(this.Us = 0),
|
|
37
|
-
(this
|
|
37
|
+
(this.$s = 0),
|
|
38
38
|
(this.cards = []),
|
|
39
|
-
this.
|
|
40
|
-
const n = et.
|
|
41
|
-
new et(n,
|
|
42
|
-
this.
|
|
39
|
+
this.Ps();
|
|
40
|
+
const n = et._s.Xs;
|
|
41
|
+
new et(n, b).Qs(n.Ws.Vs, (t) => {
|
|
42
|
+
this.Ys(t);
|
|
43
43
|
}),
|
|
44
|
-
(this.
|
|
44
|
+
(this.Zs = null),
|
|
45
45
|
(this.T = null),
|
|
46
|
-
(this.
|
|
47
|
-
(this.
|
|
48
|
-
(this.
|
|
46
|
+
(this.fi = null),
|
|
47
|
+
(this.di = null),
|
|
48
|
+
(this.pi = 10);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
return this.
|
|
50
|
+
vi() {
|
|
51
|
+
return this.Zs;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
this.
|
|
53
|
+
Ci(t) {
|
|
54
|
+
this.Zs = t;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
Et() {
|
|
57
57
|
return this.T;
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
Lt(t) {
|
|
60
60
|
this.T = t;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
if (!this.
|
|
64
|
-
const t = this.
|
|
62
|
+
Ps() {
|
|
63
|
+
if (!this.j) return;
|
|
64
|
+
const t = this.j.St(s.It.bi) || [],
|
|
65
65
|
i = [];
|
|
66
66
|
for (let s = 0; s < t.length; s++) {
|
|
67
67
|
const e = it(t[s]);
|
|
68
68
|
null != e && i.push(e);
|
|
69
69
|
}
|
|
70
|
-
(this.cards = this.
|
|
71
|
-
(this.Us = this.
|
|
72
|
-
(this
|
|
70
|
+
(this.cards = this.wi(this.gi(i, !1))),
|
|
71
|
+
(this.Us = this.j.St(s.It.ji) || this.Us),
|
|
72
|
+
(this.$s = this.j.St(s.It.yi) || this.$s);
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
Ri(t, i = !1, e = 0, h = 0) {
|
|
75
75
|
let r;
|
|
76
76
|
if (i) {
|
|
77
77
|
r = [];
|
|
@@ -92,7 +92,7 @@ export default class rr extends t {
|
|
|
92
92
|
const t = st(e);
|
|
93
93
|
null != t && r.push(t);
|
|
94
94
|
} else {
|
|
95
|
-
if (!h.
|
|
95
|
+
if (!h.ni(e))
|
|
96
96
|
for (let t = 0; t < r.length; t++)
|
|
97
97
|
if (e.id === r[t].id) {
|
|
98
98
|
r.splice(t, 1);
|
|
@@ -100,28 +100,28 @@ export default class rr extends t {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
(this.cards = this.
|
|
104
|
-
this.
|
|
103
|
+
(this.cards = this.wi(this.gi(r, i))),
|
|
104
|
+
this.Ui(),
|
|
105
105
|
(this.Us = e),
|
|
106
|
-
(this
|
|
107
|
-
this.
|
|
106
|
+
(this.$s = h),
|
|
107
|
+
this.j && (this.j.Pt(s.It.ji, this.Us), this.j.Pt(s.It.yi, this.$s));
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
if (this.
|
|
111
|
-
this.
|
|
109
|
+
q(t) {
|
|
110
|
+
if (this.ki() && null != t && t.cards) {
|
|
111
|
+
this.j && this.j.Pt(s.It.zi, r.qi());
|
|
112
112
|
const i = t.full_sync;
|
|
113
|
-
i || this.
|
|
114
|
-
this.
|
|
115
|
-
this.Rs.A(this.
|
|
113
|
+
i || this.Ps(),
|
|
114
|
+
this.Ri(t.cards, i, t.last_full_sync_at, t.last_card_updated_at),
|
|
115
|
+
this.Rs.A(this.xi(!0));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
this.
|
|
118
|
+
Fi(t) {
|
|
119
|
+
this.Li(), (this.fi = t);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
Ys(t) {
|
|
122
122
|
var s;
|
|
123
|
-
if (!this.
|
|
124
|
-
this.
|
|
123
|
+
if (!this.ki()) return;
|
|
124
|
+
this.Ps();
|
|
125
125
|
const i = this.cards.slice();
|
|
126
126
|
let e = null;
|
|
127
127
|
e = null === (s = this.Ss) || void 0 === s ? void 0 : s.getUserId();
|
|
@@ -138,7 +138,7 @@ export default class rr extends t {
|
|
|
138
138
|
const t = st(e);
|
|
139
139
|
null != t && i.push(t);
|
|
140
140
|
} else {
|
|
141
|
-
if (!h.
|
|
141
|
+
if (!h.ni(e))
|
|
142
142
|
for (let t = 0; t < i.length; t++)
|
|
143
143
|
if (e.id === i[t].id) {
|
|
144
144
|
i.splice(t, 1);
|
|
@@ -146,16 +146,16 @@ export default class rr extends t {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
(this.cards = this.
|
|
149
|
+
(this.cards = this.wi(this.gi(i, !1))), this.Ui(), this.Rs.A(this.xi(!0));
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
gi(t, i) {
|
|
152
152
|
let e = {},
|
|
153
153
|
h = {},
|
|
154
154
|
r = {};
|
|
155
|
-
this.
|
|
156
|
-
((e = this.
|
|
157
|
-
(h = this.
|
|
158
|
-
(r = this.
|
|
155
|
+
this.j &&
|
|
156
|
+
((e = this.j.St(s.It.Zt) || {}),
|
|
157
|
+
(h = this.j.St(s.It.ps) || {}),
|
|
158
|
+
(r = this.j.St(s.It.fs) || {}));
|
|
159
159
|
const n = {},
|
|
160
160
|
o = {},
|
|
161
161
|
l = {};
|
|
@@ -168,21 +168,21 @@ export default class rr extends t {
|
|
|
168
168
|
}
|
|
169
169
|
return (
|
|
170
170
|
i &&
|
|
171
|
-
this.
|
|
172
|
-
(this.
|
|
171
|
+
this.j &&
|
|
172
|
+
(this.j.Pt(s.It.Zt, n), this.j.Pt(s.It.ps, o), this.j.Pt(s.It.fs, l)),
|
|
173
173
|
t
|
|
174
174
|
);
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
wi(t) {
|
|
177
177
|
const i = [],
|
|
178
178
|
e = new Date();
|
|
179
179
|
let h = {};
|
|
180
|
-
this.
|
|
180
|
+
this.j && (h = this.j.St(s.It.fs) || {});
|
|
181
181
|
let r = !1;
|
|
182
182
|
for (let s = 0; s < t.length; s++) {
|
|
183
183
|
const n = t[s].url;
|
|
184
184
|
if (!this.Ts && n && tt(n)) {
|
|
185
|
-
|
|
185
|
+
b.error(
|
|
186
186
|
`Card with url ${n} will not be displayed because Javascript URLs are disabled. Use the "allowUserSuppliedJavascript" option for braze.initialize to enable this card.`,
|
|
187
187
|
);
|
|
188
188
|
continue;
|
|
@@ -196,42 +196,42 @@ export default class rr extends t {
|
|
|
196
196
|
i && (h[i] = !0), (r = !0);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
return r && this.
|
|
199
|
+
return r && this.j && this.j.Pt(s.It.fs, h), i;
|
|
200
200
|
}
|
|
201
|
-
|
|
201
|
+
Ui() {
|
|
202
202
|
var t;
|
|
203
203
|
const i = [];
|
|
204
204
|
for (let t = 0; t < this.cards.length; t++) i.push(this.cards[t].qt());
|
|
205
|
-
null === (t = this.
|
|
205
|
+
null === (t = this.j) || void 0 === t || t.Pt(s.It.bi, i);
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
this.
|
|
207
|
+
Li() {
|
|
208
|
+
this.fi && (clearTimeout(this.fi), (this.fi = null));
|
|
209
209
|
}
|
|
210
|
-
lr(t, i, e =
|
|
210
|
+
lr(t, i, e = "sdk") {
|
|
211
211
|
var n;
|
|
212
212
|
const o = this.B,
|
|
213
|
-
u = this.
|
|
213
|
+
u = this.j;
|
|
214
214
|
if (!o || !u) return void ("function" == typeof i && i());
|
|
215
|
-
if ((e && (h.
|
|
215
|
+
if (("client" === e && (h.Ji(u, h.it.Mi), this.Li()), !this.ki()))
|
|
216
216
|
return void (
|
|
217
217
|
null === (n = this.h) ||
|
|
218
218
|
void 0 === n ||
|
|
219
|
-
n
|
|
220
|
-
this.lr(t, i,
|
|
219
|
+
n.$i(() => {
|
|
220
|
+
this.lr(t, i, "client");
|
|
221
221
|
})
|
|
222
222
|
);
|
|
223
223
|
const f = o.Z({}, !0);
|
|
224
|
-
u.
|
|
224
|
+
u.St(s.It.zi) !== r.qi() && this.Bi(),
|
|
225
225
|
(f.last_full_sync_at = this.Us),
|
|
226
|
-
(f.last_card_updated_at = this
|
|
227
|
-
const p = o.tt(f, h.it.
|
|
226
|
+
(f.last_card_updated_at = this.$s);
|
|
227
|
+
const p = o.tt(f, h.it.Mi, e);
|
|
228
228
|
let v = !1;
|
|
229
229
|
o.et(
|
|
230
230
|
f,
|
|
231
231
|
(s = -1) => {
|
|
232
|
-
if (this.
|
|
232
|
+
if (this.j) {
|
|
233
233
|
const t = new Date().valueOf();
|
|
234
|
-
h.nt(this.
|
|
234
|
+
h.nt(this.j, h.it.Mi, t);
|
|
235
235
|
}
|
|
236
236
|
-1 !== s && p.push(["X-Braze-Req-Tokens-Remaining", s.toString()]),
|
|
237
237
|
l.ot({
|
|
@@ -241,7 +241,7 @@ export default class rr extends t {
|
|
|
241
241
|
lt: (s) => {
|
|
242
242
|
if (!o.ut(f, s, p))
|
|
243
243
|
return (v = !0), void ("function" == typeof i && i());
|
|
244
|
-
o.ct(), this.
|
|
244
|
+
o.ct(), this.q(s), (v = !1), "function" == typeof t && t();
|
|
245
245
|
},
|
|
246
246
|
error: (t) => {
|
|
247
247
|
o.dt(t, "retrieving content cards"),
|
|
@@ -261,29 +261,29 @@ export default class rr extends t {
|
|
|
261
261
|
i =
|
|
262
262
|
(null === (l = this.h) || void 0 === l ? void 0 : l.bt()) ||
|
|
263
263
|
c;
|
|
264
|
-
let e = this.
|
|
264
|
+
let e = this.di;
|
|
265
265
|
(null == e || e < t) && (e = t), (u = Math.min(i, a(t, e * s)));
|
|
266
266
|
}
|
|
267
267
|
o.yt(
|
|
268
268
|
e,
|
|
269
269
|
() => {
|
|
270
|
-
this.lr(t, i
|
|
270
|
+
this.lr(t, i);
|
|
271
271
|
},
|
|
272
|
-
h.it.
|
|
273
|
-
(t) => this.
|
|
274
|
-
() => this.
|
|
272
|
+
h.it.Mi,
|
|
273
|
+
(t) => this.Fi(t),
|
|
274
|
+
() => this.Li(),
|
|
275
275
|
u,
|
|
276
276
|
);
|
|
277
277
|
},
|
|
278
278
|
});
|
|
279
279
|
},
|
|
280
|
-
h.it.
|
|
280
|
+
h.it.Mi,
|
|
281
281
|
i,
|
|
282
282
|
);
|
|
283
283
|
}
|
|
284
|
-
|
|
285
|
-
t || this.
|
|
286
|
-
const i = this.
|
|
284
|
+
xi(t) {
|
|
285
|
+
t || this.Ps();
|
|
286
|
+
const i = this.wi(this.cards);
|
|
287
287
|
i.sort((t, s) =>
|
|
288
288
|
t.pinned && !s.pinned
|
|
289
289
|
? -1
|
|
@@ -295,52 +295,52 @@ export default class rr extends t {
|
|
|
295
295
|
? 1
|
|
296
296
|
: 0,
|
|
297
297
|
);
|
|
298
|
-
let e = Math.max(this
|
|
298
|
+
let e = Math.max(this.$s || 0, this.Us || 0);
|
|
299
299
|
return (
|
|
300
300
|
0 === e && (e = void 0),
|
|
301
|
-
this.
|
|
301
|
+
this.j && this.j.St(s.It.yi) === this.$s && void 0 === e && (e = this.$s),
|
|
302
302
|
new ContentCards(i, Y(e))
|
|
303
303
|
);
|
|
304
304
|
}
|
|
305
|
-
|
|
306
|
-
return this.Rs.
|
|
305
|
+
Kt(t) {
|
|
306
|
+
return this.Rs.Ut(t);
|
|
307
307
|
}
|
|
308
|
-
|
|
308
|
+
Bi() {
|
|
309
309
|
(this.Us = 0),
|
|
310
|
-
(this
|
|
311
|
-
this.
|
|
310
|
+
(this.$s = 0),
|
|
311
|
+
this.j && (this.j.Vt(s.It.ji), this.j.Vt(s.It.yi));
|
|
312
312
|
}
|
|
313
313
|
changeUser(t) {
|
|
314
314
|
t ||
|
|
315
315
|
((this.cards = []),
|
|
316
316
|
this.Rs.A(new ContentCards(this.cards.slice(), null)),
|
|
317
|
-
this.
|
|
318
|
-
(this.
|
|
319
|
-
this.
|
|
320
|
-
this.
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
323
|
-
this
|
|
317
|
+
this.j &&
|
|
318
|
+
(this.j.Vt(s.It.bi),
|
|
319
|
+
this.j.Vt(s.It.Zt),
|
|
320
|
+
this.j.Vt(s.It.ps),
|
|
321
|
+
this.j.Vt(s.It.fs))),
|
|
322
|
+
this.Li(),
|
|
323
|
+
this.Bi();
|
|
324
324
|
}
|
|
325
325
|
clearData(t) {
|
|
326
326
|
(this.Us = 0),
|
|
327
|
-
(this
|
|
327
|
+
(this.$s = 0),
|
|
328
328
|
(this.cards = []),
|
|
329
329
|
this.Rs.A(new ContentCards(this.cards.slice(), null)),
|
|
330
330
|
t &&
|
|
331
|
-
this.
|
|
332
|
-
(this.
|
|
333
|
-
this.
|
|
334
|
-
this.
|
|
335
|
-
this.
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
338
|
-
this.
|
|
331
|
+
this.j &&
|
|
332
|
+
(this.j.Vt(s.It.bi),
|
|
333
|
+
this.j.Vt(s.It.Zt),
|
|
334
|
+
this.j.Vt(s.It.ps),
|
|
335
|
+
this.j.Vt(s.It.fs),
|
|
336
|
+
this.j.Vt(s.It.ji),
|
|
337
|
+
this.j.Vt(s.It.yi)),
|
|
338
|
+
this.Li();
|
|
339
339
|
}
|
|
340
|
-
|
|
341
|
-
return !!this.h && (!!this.h.
|
|
340
|
+
ki() {
|
|
341
|
+
return !!this.h && (!!this.h.Pi() || (0 !== this.h.Qt() && this.Xi(), !1));
|
|
342
342
|
}
|
|
343
|
-
|
|
344
|
-
this.Rs.A(new ContentCards([], new Date())), this.
|
|
343
|
+
Xi() {
|
|
344
|
+
this.Rs.A(new ContentCards([], new Date())), this.j && this.j.Vt(s.It.bi);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ir from "./content-cards-provider-factory.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
3
|
export function getCachedContentCards() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return ir.o().xi(!1);
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import ir from "./content-cards-provider-factory.js";
|
|
3
3
|
export function requestContentCardsRefresh(e, t) {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return ir.o().lr(e, t, "client");
|
|
5
5
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
3
|
-
export function subscribeToContentCardsUpdates(
|
|
2
|
+
import ir from "./content-cards-provider-factory.js";
|
|
3
|
+
export function subscribeToContentCardsUpdates(t) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
|
-
const
|
|
6
|
-
n =
|
|
7
|
-
if (!
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
const r =
|
|
11
|
-
|
|
5
|
+
const o = ir.o(),
|
|
6
|
+
n = o.Kt(t);
|
|
7
|
+
if (!o.Et()) {
|
|
8
|
+
const t = r.nn();
|
|
9
|
+
if (t) {
|
|
10
|
+
const r = t.rn(() => {
|
|
11
|
+
o.lr(void 0, void 0, "client");
|
|
12
12
|
});
|
|
13
|
-
r &&
|
|
13
|
+
r && o.Lt(r);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
return n;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import r, { OPTIONS as U } from "../../managers/braze-instance.js";
|
|
2
2
|
import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
|
|
3
|
-
import
|
|
3
|
+
import ir from "../content-cards-provider-factory.js";
|
|
4
4
|
import { setCardHeight as tn } from "../../Card/display/card-display.js";
|
|
5
|
-
import { logger as
|
|
5
|
+
import { logger as b } from "../../../shared-lib/index.js";
|
|
6
6
|
import {
|
|
7
7
|
destroyContentCardsHtml as nn,
|
|
8
8
|
detectContentCardsImpressions as en,
|
|
@@ -19,19 +19,19 @@ export function showContentCards(n, t) {
|
|
|
19
19
|
let e = !1;
|
|
20
20
|
null == n && ((n = document.body), (e = !0));
|
|
21
21
|
const o = r.er(U.tn) || !1,
|
|
22
|
-
s =
|
|
22
|
+
s = ir.o().xi(!1);
|
|
23
23
|
"function" == typeof t && cn(s, t(s.cards.slice()), s.lastUpdated, null, o);
|
|
24
24
|
const a = on(s, o, e),
|
|
25
|
-
i =
|
|
26
|
-
c = i.
|
|
25
|
+
i = ir.o(),
|
|
26
|
+
c = i.vi();
|
|
27
27
|
(null == s.lastUpdated ||
|
|
28
28
|
new Date().valueOf() - s.lastUpdated.valueOf() > ContentCards.mr) &&
|
|
29
29
|
(null == c || new Date().valueOf() - c > ContentCards.mr) &&
|
|
30
|
-
(
|
|
30
|
+
(b.info(
|
|
31
31
|
`Cached content cards were older than max TTL of ${ContentCards.mr} ms, requesting an update from the server.`,
|
|
32
32
|
),
|
|
33
33
|
sn(s, a),
|
|
34
|
-
i.
|
|
34
|
+
i.Ci(new Date().valueOf()));
|
|
35
35
|
const f = new Date().valueOf(),
|
|
36
36
|
l = subscribeToContentCardsUpdates(function (n) {
|
|
37
37
|
const e = a.querySelectorAll(".ab-refresh-button")[0];
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
isArray as g,
|
|
5
5
|
validateValueIsFromEnum as ta,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
|
-
import { logger as
|
|
7
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
8
8
|
export function addSdkMetadata(a) {
|
|
9
9
|
if (!aa.rr()) return;
|
|
10
10
|
const t = aa.m();
|
|
11
11
|
if (t) {
|
|
12
12
|
if (!g(a))
|
|
13
13
|
return (
|
|
14
|
-
|
|
14
|
+
b.error("Cannot set SDK metadata because metadata is not an array."), !1
|
|
15
15
|
);
|
|
16
16
|
for (const t of a)
|
|
17
17
|
if (
|
package/src/Core/change-user.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { getByteLength as
|
|
3
|
-
import { logger as
|
|
2
|
+
import { getByteLength as er } from "../util/string-utils.js";
|
|
3
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
4
4
|
import { User } from "../User/index.js";
|
|
5
5
|
import { validateStandardString as tr } from "../util/validation-utils.js";
|
|
6
6
|
export function changeUser(e, i) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (null == e || 0 === e.length || e != e)
|
|
9
|
-
return void
|
|
10
|
-
if (
|
|
11
|
-
return void
|
|
9
|
+
return void b.error("changeUser requires a non-empty userId.");
|
|
10
|
+
if (er(e) > User.br)
|
|
11
|
+
return void b.error(
|
|
12
12
|
`Rejected user id "${e}" because it is longer than ${User.br} bytes.`,
|
|
13
13
|
);
|
|
14
14
|
if (null != i && !tr(i, "set signature for new user", "signature")) return;
|
package/src/Core/destroy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as
|
|
2
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
3
3
|
export function destroy() {
|
|
4
|
-
|
|
4
|
+
b.info("Destroying Braze instance"), r.destroy(!0);
|
|
5
5
|
}
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r, { OPTIONS as U } from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as
|
|
2
|
+
import { logger as b, IndexedDBAdapter as et } from "../../shared-lib/index.js";
|
|
3
3
|
import ne, { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
4
4
|
export function disableSDK() {
|
|
5
5
|
const e = r.nn();
|
|
@@ -8,9 +8,9 @@ export function disableSDK() {
|
|
|
8
8
|
a = new ne.le(null, !0, n),
|
|
9
9
|
i = "This-cookie-will-expire-in-" + a.me();
|
|
10
10
|
a.store(s.ce, i);
|
|
11
|
-
const o = et.
|
|
12
|
-
new et(o,
|
|
13
|
-
|
|
11
|
+
const o = et._s.Xs;
|
|
12
|
+
new et(o, b).setItem(o.Ws.pe, o.be, !0),
|
|
13
|
+
b.info("disableSDK was called"),
|
|
14
14
|
r.destroy(!1),
|
|
15
15
|
r.fe(!0);
|
|
16
16
|
}
|
package/src/Core/enable-sdk.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as
|
|
2
|
+
import { logger as b, IndexedDBAdapter as et } from "../../shared-lib/index.js";
|
|
3
3
|
import ne, { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
4
4
|
export function enableSDK() {
|
|
5
5
|
new ne.le(null, !0).remove(s.ce);
|
|
6
|
-
const e = et.
|
|
7
|
-
new et(e,
|
|
8
|
-
|
|
6
|
+
const e = et._s.Xs;
|
|
7
|
+
new et(e, b).ge(e.Ws.pe, e.be),
|
|
8
|
+
b.info("enableSDK was called"),
|
|
9
9
|
r.destroy(!1),
|
|
10
10
|
r.fe(!1);
|
|
11
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as
|
|
2
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
3
3
|
export function getDeviceId(e) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
5
|
const t = r.ue();
|
|
6
6
|
if (!t) return;
|
|
7
7
|
const i = t.ve().id;
|
|
8
8
|
if ("function" != typeof e) return i;
|
|
9
|
-
|
|
9
|
+
b.warn(
|
|
10
10
|
"The callback for getDeviceId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getDeviceId()`)",
|
|
11
11
|
),
|
|
12
12
|
e(i);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logger as
|
|
1
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
2
2
|
import { CoreStrings as R } from "../common/constants.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import {
|
|
@@ -20,7 +20,7 @@ export function _handleBrazeAction(o, e, s) {
|
|
|
20
20
|
if (!e) return;
|
|
21
21
|
const s = (o) => {
|
|
22
22
|
if (!io(o))
|
|
23
|
-
return void
|
|
23
|
+
return void b.error(
|
|
24
24
|
`Decoded Braze Action json is invalid: ${JSON.stringify(
|
|
25
25
|
o,
|
|
26
26
|
null,
|
|
@@ -44,7 +44,7 @@ export function _handleBrazeAction(o, e, s) {
|
|
|
44
44
|
r.ao()
|
|
45
45
|
? ((t = Array.prototype.slice.call(e)),
|
|
46
46
|
logCustomEvent(...t))
|
|
47
|
-
:
|
|
47
|
+
: b.error(R.ee);
|
|
48
48
|
},
|
|
49
49
|
);
|
|
50
50
|
break;
|
|
@@ -55,7 +55,7 @@ export function _handleBrazeAction(o, e, s) {
|
|
|
55
55
|
? "Safari" === ro.browser && ro.OS === so.co
|
|
56
56
|
? window.navigator.standalone && requestPushPermission()
|
|
57
57
|
: requestPushPermission()
|
|
58
|
-
:
|
|
58
|
+
: b.error(R.ee);
|
|
59
59
|
},
|
|
60
60
|
);
|
|
61
61
|
break;
|
|
@@ -75,7 +75,7 @@ export function _handleBrazeAction(o, e, s) {
|
|
|
75
75
|
(t = Array.prototype.slice.call(e)), no.openUri(...t);
|
|
76
76
|
break;
|
|
77
77
|
default:
|
|
78
|
-
|
|
78
|
+
b.info(`Ignoring unknown Braze Action: ${n}`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
};
|
package/src/Core/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { initialize } from "./initialize.js";
|
|
|
11
11
|
export { isDisabled } from "./is-disabled.js";
|
|
12
12
|
export { isInitialized } from "./is-initialized.js";
|
|
13
13
|
export { logCustomEvent } from "./log-custom-event.js";
|
|
14
|
+
export { logEcommerceEvent } from "./log-ecommerce-event.js";
|
|
14
15
|
export { logPurchase } from "./log-purchase.js";
|
|
15
16
|
export { openSession } from "./open-session.js";
|
|
16
17
|
export { removeAllSubscriptions } from "./remove-all-subscriptions.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import v from "../common/event-logger.js";
|
|
3
|
-
import { logger as
|
|
3
|
+
import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
|
|
4
4
|
import ot from "../triggers/models/trigger-events.js";
|
|
5
5
|
import { TriggersProviderFactory as rt } from "../triggers/triggers-provider-factory.js";
|
|
6
6
|
import {
|
|
@@ -12,7 +12,7 @@ export function logCustomEvent(t, e) {
|
|
|
12
12
|
if (!r.rr()) return !1;
|
|
13
13
|
if (null == t || t.length <= 0)
|
|
14
14
|
return (
|
|
15
|
-
|
|
15
|
+
b.error(
|
|
16
16
|
`logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`,
|
|
17
17
|
),
|
|
18
18
|
!1
|
|
@@ -28,10 +28,10 @@ export function logCustomEvent(t, e) {
|
|
|
28
28
|
if (!o) return !1;
|
|
29
29
|
const i = r.l();
|
|
30
30
|
if (i && i.$e(t))
|
|
31
|
-
return
|
|
32
|
-
const s = v.
|
|
31
|
+
return b.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1;
|
|
32
|
+
const s = v.Dt(p.CustomEvent, { n: t, p: n });
|
|
33
33
|
if (s.lt) {
|
|
34
|
-
|
|
34
|
+
b.info(`Logged custom event "${t}".`);
|
|
35
35
|
for (const o of s.Ce) rt.o().Ee(ot.he, [t, e], o);
|
|
36
36
|
}
|
|
37
37
|
return s.lt;
|