@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
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export default class et {
|
|
2
2
|
constructor(t, e) {
|
|
3
3
|
(this.database = t),
|
|
4
|
-
(this.
|
|
4
|
+
(this.Ud = e),
|
|
5
5
|
(this.parent = "undefined" == typeof window ? self : window),
|
|
6
6
|
(this.database = t),
|
|
7
|
-
(this.
|
|
7
|
+
(this.Ud = e);
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
Od() {
|
|
10
10
|
if ("indexedDB" in this.parent) return this.parent.indexedDB;
|
|
11
11
|
}
|
|
12
12
|
isSupported() {
|
|
13
13
|
var t;
|
|
14
14
|
try {
|
|
15
|
-
if (null == this.
|
|
15
|
+
if (null == this.Od()) return !1;
|
|
16
16
|
{
|
|
17
17
|
const e =
|
|
18
|
-
null === (t = this.
|
|
18
|
+
null === (t = this.Od()) || void 0 === t
|
|
19
19
|
? void 0
|
|
20
20
|
: t.open("Braze IndexedDB Support Test");
|
|
21
21
|
if (
|
|
@@ -25,10 +25,10 @@ export default class et {
|
|
|
25
25
|
"undefined" != typeof window)
|
|
26
26
|
) {
|
|
27
27
|
const t = window,
|
|
28
|
-
e = t.chrome || t.browser || t.
|
|
28
|
+
e = t.chrome || t.browser || t.kd;
|
|
29
29
|
if (e && e.runtime && e.runtime.id)
|
|
30
30
|
return (
|
|
31
|
-
this.
|
|
31
|
+
this.Ud.info(
|
|
32
32
|
"Not using IndexedDB for storage because we are running inside an extension",
|
|
33
33
|
),
|
|
34
34
|
!1
|
|
@@ -38,37 +38,37 @@ export default class et {
|
|
|
38
38
|
}
|
|
39
39
|
} catch (t) {
|
|
40
40
|
return (
|
|
41
|
-
this.
|
|
41
|
+
this.Ud.info(
|
|
42
42
|
"Not using IndexedDB for storage due to following error: " + t,
|
|
43
43
|
),
|
|
44
44
|
!1
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
Kd(t, e) {
|
|
49
49
|
var n;
|
|
50
50
|
const o =
|
|
51
|
-
null === (n = this.
|
|
51
|
+
null === (n = this.Od()) || void 0 === n
|
|
52
52
|
? void 0
|
|
53
|
-
: n.open(this.database.
|
|
53
|
+
: n.open(this.database.Gd, this.database.VERSION);
|
|
54
54
|
if (null == o) return "function" == typeof e && e(), !1;
|
|
55
55
|
const i = this;
|
|
56
56
|
return (
|
|
57
57
|
(o.onupgradeneeded = (t) => {
|
|
58
58
|
var e;
|
|
59
|
-
i.
|
|
59
|
+
i.Ud.info(
|
|
60
60
|
"Upgrading indexedDB " +
|
|
61
|
-
i.database.
|
|
61
|
+
i.database.Gd +
|
|
62
62
|
" to v" +
|
|
63
63
|
i.database.VERSION +
|
|
64
64
|
"...",
|
|
65
65
|
);
|
|
66
66
|
const n = null === (e = t.target) || void 0 === e ? void 0 : e.result;
|
|
67
|
-
for (const t in i.database.
|
|
67
|
+
for (const t in i.database.Ws) {
|
|
68
68
|
const e = t;
|
|
69
|
-
i.database.
|
|
70
|
-
!n.objectStoreNames.contains(i.database.
|
|
71
|
-
n.createObjectStore(i.database.
|
|
69
|
+
i.database.Ws.hasOwnProperty(t) &&
|
|
70
|
+
!n.objectStoreNames.contains(i.database.Ws[e]) &&
|
|
71
|
+
n.createObjectStore(i.database.Ws[e]);
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
(o.onsuccess = (n) => {
|
|
@@ -77,7 +77,7 @@ export default class et {
|
|
|
77
77
|
(r.onversionchange = () => {
|
|
78
78
|
r.close(),
|
|
79
79
|
"function" == typeof e && e(),
|
|
80
|
-
i.
|
|
80
|
+
i.Ud.error(
|
|
81
81
|
"Needed to close the database unexpectedly because of an upgrade in another tab",
|
|
82
82
|
);
|
|
83
83
|
}),
|
|
@@ -87,9 +87,9 @@ export default class et {
|
|
|
87
87
|
var n;
|
|
88
88
|
const o = t;
|
|
89
89
|
return (
|
|
90
|
-
i.
|
|
90
|
+
i.Ud.info(
|
|
91
91
|
"Could not open indexedDB " +
|
|
92
|
-
i.database.
|
|
92
|
+
i.database.Gd +
|
|
93
93
|
" v" +
|
|
94
94
|
i.database.VERSION +
|
|
95
95
|
": " +
|
|
@@ -105,16 +105,16 @@ export default class et {
|
|
|
105
105
|
setItem(t, e, n, o, i) {
|
|
106
106
|
if (!this.isSupported()) return "function" == typeof i && i(), !1;
|
|
107
107
|
const r = this;
|
|
108
|
-
return this.
|
|
108
|
+
return this.Kd((d) => {
|
|
109
109
|
if (!d.objectStoreNames.contains(t))
|
|
110
110
|
return (
|
|
111
|
-
r.
|
|
111
|
+
r.Ud.error(
|
|
112
112
|
"Could not store object " +
|
|
113
113
|
e +
|
|
114
114
|
" in " +
|
|
115
115
|
t +
|
|
116
116
|
" on indexedDB " +
|
|
117
|
-
r.database.
|
|
117
|
+
r.database.Gd +
|
|
118
118
|
" - " +
|
|
119
119
|
t +
|
|
120
120
|
" is not a valid objectStore",
|
|
@@ -126,13 +126,13 @@ export default class et {
|
|
|
126
126
|
s.oncomplete = () => d.close();
|
|
127
127
|
const u = s.objectStore(t).put(n, e);
|
|
128
128
|
(u.onerror = () => {
|
|
129
|
-
r.
|
|
129
|
+
r.Ud.error(
|
|
130
130
|
"Could not store object " +
|
|
131
131
|
e +
|
|
132
132
|
" in " +
|
|
133
133
|
t +
|
|
134
134
|
" on indexedDB " +
|
|
135
|
-
r.database.
|
|
135
|
+
r.database.Gd,
|
|
136
136
|
),
|
|
137
137
|
"function" == typeof i && i();
|
|
138
138
|
}),
|
|
@@ -144,16 +144,16 @@ export default class et {
|
|
|
144
144
|
getItem(t, e, n) {
|
|
145
145
|
if (!this.isSupported()) return !1;
|
|
146
146
|
const o = this;
|
|
147
|
-
return this.
|
|
147
|
+
return this.Kd((i) => {
|
|
148
148
|
if (!i.objectStoreNames.contains(t))
|
|
149
149
|
return (
|
|
150
|
-
o.
|
|
150
|
+
o.Ud.error(
|
|
151
151
|
"Could not retrieve object " +
|
|
152
152
|
e +
|
|
153
153
|
" in " +
|
|
154
154
|
t +
|
|
155
155
|
" on indexedDB " +
|
|
156
|
-
o.database.
|
|
156
|
+
o.database.Gd +
|
|
157
157
|
" - " +
|
|
158
158
|
t +
|
|
159
159
|
" is not a valid objectStore",
|
|
@@ -164,13 +164,13 @@ export default class et {
|
|
|
164
164
|
r.oncomplete = () => i.close();
|
|
165
165
|
const d = r.objectStore(t).get(e);
|
|
166
166
|
(d.onerror = () => {
|
|
167
|
-
o.
|
|
167
|
+
o.Ud.error(
|
|
168
168
|
"Could not retrieve object " +
|
|
169
169
|
e +
|
|
170
170
|
" in " +
|
|
171
171
|
t +
|
|
172
172
|
" on indexedDB " +
|
|
173
|
-
o.database.
|
|
173
|
+
o.database.Gd,
|
|
174
174
|
);
|
|
175
175
|
}),
|
|
176
176
|
(d.onsuccess = (t) => {
|
|
@@ -183,14 +183,14 @@ export default class et {
|
|
|
183
183
|
kr(t, e, n) {
|
|
184
184
|
if (!this.isSupported()) return "function" == typeof n && n(), !1;
|
|
185
185
|
const o = this;
|
|
186
|
-
return this.
|
|
186
|
+
return this.Kd((i) => {
|
|
187
187
|
if (!i.objectStoreNames.contains(t))
|
|
188
188
|
return (
|
|
189
|
-
o.
|
|
189
|
+
o.Ud.error(
|
|
190
190
|
"Could not retrieve last record from " +
|
|
191
191
|
t +
|
|
192
192
|
" on indexedDB " +
|
|
193
|
-
o.database.
|
|
193
|
+
o.database.Gd +
|
|
194
194
|
" - " +
|
|
195
195
|
t +
|
|
196
196
|
" is not a valid objectStore",
|
|
@@ -202,8 +202,8 @@ export default class et {
|
|
|
202
202
|
r.oncomplete = () => i.close();
|
|
203
203
|
const d = r.objectStore(t).openCursor(null, "prev");
|
|
204
204
|
(d.onerror = () => {
|
|
205
|
-
o.
|
|
206
|
-
"Could not open cursor for " + t + " on indexedDB " + o.database.
|
|
205
|
+
o.Ud.error(
|
|
206
|
+
"Could not open cursor for " + t + " on indexedDB " + o.database.Gd,
|
|
207
207
|
),
|
|
208
208
|
"function" == typeof n && n();
|
|
209
209
|
}),
|
|
@@ -219,16 +219,16 @@ export default class et {
|
|
|
219
219
|
ge(t, e) {
|
|
220
220
|
if (!this.isSupported()) return !1;
|
|
221
221
|
const n = this;
|
|
222
|
-
return this.
|
|
222
|
+
return this.Kd((o) => {
|
|
223
223
|
if (!o.objectStoreNames.contains(t))
|
|
224
224
|
return (
|
|
225
|
-
n.
|
|
225
|
+
n.Ud.error(
|
|
226
226
|
"Could not delete record " +
|
|
227
227
|
e +
|
|
228
228
|
" from " +
|
|
229
229
|
t +
|
|
230
230
|
" on indexedDB " +
|
|
231
|
-
n.database.
|
|
231
|
+
n.database.Gd +
|
|
232
232
|
" - " +
|
|
233
233
|
t +
|
|
234
234
|
" is not a valid objectStore",
|
|
@@ -238,28 +238,28 @@ export default class et {
|
|
|
238
238
|
const i = o.transaction([t], "readwrite");
|
|
239
239
|
i.oncomplete = () => o.close();
|
|
240
240
|
i.objectStore(t).delete(e).onerror = () => {
|
|
241
|
-
n.
|
|
241
|
+
n.Ud.error(
|
|
242
242
|
"Could not delete record " +
|
|
243
243
|
e +
|
|
244
244
|
" from " +
|
|
245
245
|
t +
|
|
246
246
|
" on indexedDB " +
|
|
247
|
-
n.database.
|
|
247
|
+
n.database.Gd,
|
|
248
248
|
);
|
|
249
249
|
};
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
Qs(t, e) {
|
|
253
253
|
if (!this.isSupported()) return !1;
|
|
254
254
|
const n = this;
|
|
255
|
-
return this.
|
|
255
|
+
return this.Kd((o) => {
|
|
256
256
|
if (!o.objectStoreNames.contains(t))
|
|
257
257
|
return (
|
|
258
|
-
n.
|
|
258
|
+
n.Ud.error(
|
|
259
259
|
"Could not retrieve objects from " +
|
|
260
260
|
t +
|
|
261
261
|
" on indexedDB " +
|
|
262
|
-
n.database.
|
|
262
|
+
n.database.Gd +
|
|
263
263
|
" - " +
|
|
264
264
|
t +
|
|
265
265
|
" is not a valid objectStore",
|
|
@@ -273,18 +273,18 @@ export default class et {
|
|
|
273
273
|
s = [];
|
|
274
274
|
(d.onerror = () => {
|
|
275
275
|
s.length > 0
|
|
276
|
-
? (n.
|
|
276
|
+
? (n.Ud.info(
|
|
277
277
|
"Cursor closed midway through for " +
|
|
278
278
|
t +
|
|
279
279
|
" on indexedDB " +
|
|
280
|
-
n.database.
|
|
280
|
+
n.database.Gd,
|
|
281
281
|
),
|
|
282
282
|
e(s))
|
|
283
|
-
: n.
|
|
283
|
+
: n.Ud.error(
|
|
284
284
|
"Could not open cursor for " +
|
|
285
285
|
t +
|
|
286
286
|
" on indexedDB " +
|
|
287
|
-
n.database.
|
|
287
|
+
n.database.Gd,
|
|
288
288
|
);
|
|
289
289
|
}),
|
|
290
290
|
(d.onsuccess = (t) => {
|
|
@@ -304,47 +304,47 @@ export default class et {
|
|
|
304
304
|
clearData() {
|
|
305
305
|
if (!this.isSupported()) return !1;
|
|
306
306
|
const t = [];
|
|
307
|
-
for (const e in this.database.
|
|
307
|
+
for (const e in this.database.Ws) {
|
|
308
308
|
const n = e;
|
|
309
|
-
this.database.
|
|
310
|
-
this.database.
|
|
311
|
-
t.push(this.database.
|
|
309
|
+
this.database.Ws.hasOwnProperty(e) &&
|
|
310
|
+
this.database.Ws[n] !== this.database.Ws.pe &&
|
|
311
|
+
t.push(this.database.Ws[n]);
|
|
312
312
|
}
|
|
313
313
|
const e = this;
|
|
314
|
-
return this.
|
|
314
|
+
return this.Kd(function (n) {
|
|
315
315
|
const o = n.transaction(t, "readwrite");
|
|
316
316
|
o.oncomplete = () => n.close();
|
|
317
317
|
for (let n = 0; n < t.length; n++) {
|
|
318
318
|
const i = t[n];
|
|
319
319
|
o.objectStore(i).clear().onerror = function () {
|
|
320
|
-
e.
|
|
320
|
+
e.Ud.error(
|
|
321
321
|
"Could not clear " +
|
|
322
322
|
this.source.name +
|
|
323
323
|
" on indexedDB " +
|
|
324
|
-
e.database.
|
|
324
|
+
e.database.Gd,
|
|
325
325
|
);
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
328
|
o.onerror = function () {
|
|
329
|
-
e.
|
|
330
|
-
"Could not clear object stores on indexedDB " + e.database.
|
|
329
|
+
e.Ud.error(
|
|
330
|
+
"Could not clear object stores on indexedDB " + e.database.Gd,
|
|
331
331
|
);
|
|
332
332
|
};
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
et.
|
|
337
|
-
|
|
338
|
-
|
|
336
|
+
et._s = {
|
|
337
|
+
Xs: {
|
|
338
|
+
Gd: "AppboyServiceWorkerAsyncStorage",
|
|
339
339
|
VERSION: 6,
|
|
340
|
-
|
|
340
|
+
Ws: {
|
|
341
341
|
pn: "data",
|
|
342
|
-
|
|
342
|
+
yr: "pushClicks",
|
|
343
343
|
Fu: "pushSubscribed",
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
Hd: "fallbackDevice",
|
|
345
|
+
Vs: "cardUpdates",
|
|
346
346
|
pe: "optOut",
|
|
347
|
-
|
|
347
|
+
Br: "pendingData",
|
|
348
348
|
wh: "sdkAuthenticationSignature",
|
|
349
349
|
},
|
|
350
350
|
be: 1,
|
package/shared-lib/logger.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const
|
|
1
|
+
const b = {
|
|
2
2
|
init: function (n) {
|
|
3
|
-
(void 0 === n && void 0 !==
|
|
3
|
+
(void 0 === n && void 0 !== b.zg) || (b.zg = !!n), b.i || (b.i = !0);
|
|
4
4
|
},
|
|
5
5
|
destroy: function () {
|
|
6
|
-
(
|
|
6
|
+
(b.i = !1), (b.zg = void 0), (b.Ud = void 0);
|
|
7
7
|
},
|
|
8
8
|
setLogger: function (n) {
|
|
9
9
|
"function" == typeof n
|
|
10
|
-
? (
|
|
11
|
-
:
|
|
10
|
+
? (b.init(), (b.Ud = n))
|
|
11
|
+
: b.info("Ignoring setLogger call since logger is not a function");
|
|
12
12
|
},
|
|
13
13
|
toggleLogging: function () {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
? (console.log("Disabling Braze logging"), (
|
|
17
|
-
: (console.log("Enabled Braze logging"), (
|
|
14
|
+
b.init(),
|
|
15
|
+
b.zg
|
|
16
|
+
? (console.log("Disabling Braze logging"), (b.zg = !1))
|
|
17
|
+
: (console.log("Enabled Braze logging"), (b.zg = !0));
|
|
18
18
|
},
|
|
19
19
|
info: function (n) {
|
|
20
|
-
if (
|
|
20
|
+
if (b.zg) {
|
|
21
21
|
const o = "Braze: " + n;
|
|
22
|
-
null !=
|
|
22
|
+
null != b.Ud ? b.Ud(o) : console.log(o);
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
|
-
if (
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v6.
|
|
28
|
-
null !=
|
|
26
|
+
if (b.zg) {
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v6.9.0)";
|
|
28
|
+
null != b.Ud ? b.Ud(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
|
-
if (
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v6.
|
|
34
|
-
null !=
|
|
32
|
+
if (b.zg) {
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v6.9.0)";
|
|
34
|
+
null != b.Ud ? b.Ud(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
|
-
export default
|
|
38
|
+
export default b;
|
|
@@ -18,33 +18,34 @@ import r from "../managers/braze-instance.js";
|
|
|
18
18
|
import v from "../common/event-logger.js";
|
|
19
19
|
import { EventTypes as p } from "../../shared-lib/event-types.js";
|
|
20
20
|
import { isArray as g } from "../util/code-utils.js";
|
|
21
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
21
22
|
export default class e extends t {
|
|
22
23
|
constructor(t, s, i, e) {
|
|
23
24
|
super(),
|
|
24
25
|
(this.h = t),
|
|
25
26
|
(this.B = s),
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
27
|
+
(this.j = i),
|
|
28
|
+
(this.C = e),
|
|
28
29
|
(this.banners = {}),
|
|
29
30
|
(this.h = t),
|
|
30
31
|
(this.B = s),
|
|
31
|
-
(this.
|
|
32
|
-
(this.
|
|
32
|
+
(this.j = i),
|
|
33
|
+
(this.C = e),
|
|
33
34
|
(this.D = 10),
|
|
34
35
|
(this.N = null),
|
|
35
36
|
(this.F = null),
|
|
36
37
|
(this.R = new f()),
|
|
37
38
|
r.S(this.R),
|
|
38
39
|
(this.T = null),
|
|
39
|
-
(this.
|
|
40
|
+
(this.I = null);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
q(t) {
|
|
42
43
|
if (this.P() && (this._(t), null != t && t.banners)) {
|
|
43
44
|
const s = t.request_time,
|
|
44
45
|
i = "number" != typeof s || isNaN(s) ? null : s,
|
|
45
46
|
e = this.k(),
|
|
46
|
-
r = this
|
|
47
|
-
o = this
|
|
47
|
+
r = this.$(),
|
|
48
|
+
o = this.L();
|
|
48
49
|
this.banners = {};
|
|
49
50
|
const h = t.banners;
|
|
50
51
|
for (const t in h) {
|
|
@@ -101,7 +102,7 @@ export default class e extends t {
|
|
|
101
102
|
? void 0
|
|
102
103
|
: s.acknowledged;
|
|
103
104
|
if (!i || !g(i) || 0 === i.length) return;
|
|
104
|
-
const e = this
|
|
105
|
+
const e = this.$();
|
|
105
106
|
if (0 === e.length) return;
|
|
106
107
|
const n = {};
|
|
107
108
|
for (const t of i)
|
|
@@ -135,7 +136,7 @@ export default class e extends t {
|
|
|
135
136
|
const f = [];
|
|
136
137
|
for (const s of t) f.push({ id: s });
|
|
137
138
|
u.placements = f;
|
|
138
|
-
const v = this
|
|
139
|
+
const v = this.$().map((t) => ({
|
|
139
140
|
banner_id: t.banner_id,
|
|
140
141
|
dismissal_time: t.dismissal_time,
|
|
141
142
|
}));
|
|
@@ -148,7 +149,7 @@ export default class e extends t {
|
|
|
148
149
|
const n = this.B;
|
|
149
150
|
if (!n) return void r();
|
|
150
151
|
const o = new Date().valueOf();
|
|
151
|
-
h.nt(this.
|
|
152
|
+
h.nt(this.j, h.it.st, o),
|
|
152
153
|
-1 !== e && p.push(["X-Braze-Req-Tokens-Remaining", e.toString()]);
|
|
153
154
|
const f = u.time_ms;
|
|
154
155
|
null == f || "number" != typeof f || isNaN(f) || this.rt(t, f),
|
|
@@ -158,7 +159,7 @@ export default class e extends t {
|
|
|
158
159
|
data: u,
|
|
159
160
|
lt: (t) => {
|
|
160
161
|
if (!n.ut(u, t, p)) return (g = !0), void r();
|
|
161
|
-
n.ct(), this.
|
|
162
|
+
n.ct(), this.q(t), (g = !1), "function" == typeof s && s();
|
|
162
163
|
},
|
|
163
164
|
error: (t) => {
|
|
164
165
|
n.dt(t, "retrieving banners"), (g = !0), r();
|
|
@@ -166,7 +167,7 @@ export default class e extends t {
|
|
|
166
167
|
ft: (e, r) => {
|
|
167
168
|
var o, l, u;
|
|
168
169
|
let f;
|
|
169
|
-
if (((this.
|
|
170
|
+
if (((this.I = t), g)) {
|
|
170
171
|
const t =
|
|
171
172
|
(null === (o = this.h) || void 0 === o ? void 0 : o.vt()) ||
|
|
172
173
|
d,
|
|
@@ -196,18 +197,24 @@ export default class e extends t {
|
|
|
196
197
|
i,
|
|
197
198
|
);
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
-
return this.
|
|
200
|
+
jt() {
|
|
201
|
+
return this.I;
|
|
201
202
|
}
|
|
202
|
-
|
|
203
|
+
Ct(t, s) {
|
|
203
204
|
const i = { id: t.id };
|
|
204
205
|
s && (i.bid = s);
|
|
205
|
-
return v.
|
|
206
|
+
return v.Dt(p.Nt, i).lt;
|
|
206
207
|
}
|
|
207
|
-
|
|
208
|
+
wt(t) {
|
|
208
209
|
if (!t.G) return !1;
|
|
209
|
-
const s = this
|
|
210
|
-
if (s.some((s) => s.banner_id === t.id && s.stable_key === t.G))
|
|
210
|
+
const s = this.$();
|
|
211
|
+
if (s.some((s) => s.banner_id === t.id && s.stable_key === t.G))
|
|
212
|
+
return (
|
|
213
|
+
b.info(
|
|
214
|
+
`Not dismissing banner ID ${t.id}. The banner has already been dismissed.`,
|
|
215
|
+
),
|
|
216
|
+
!1
|
|
217
|
+
);
|
|
211
218
|
const i = { id: t.id },
|
|
212
219
|
e = this.k(),
|
|
213
220
|
n = e[t.placementId];
|
|
@@ -222,8 +229,9 @@ export default class e extends t {
|
|
|
222
229
|
dismissal_time: new Date().valueOf(),
|
|
223
230
|
stable_key: t.G,
|
|
224
231
|
}),
|
|
225
|
-
this.J(s)
|
|
226
|
-
|
|
232
|
+
this.J(s),
|
|
233
|
+
t.Ft();
|
|
234
|
+
return v.Dt(p.Rt, i).lt;
|
|
227
235
|
}
|
|
228
236
|
Y() {
|
|
229
237
|
null != this.F && (clearTimeout(this.F), (this.F = null));
|
|
@@ -233,7 +241,7 @@ export default class e extends t {
|
|
|
233
241
|
}
|
|
234
242
|
k() {
|
|
235
243
|
let t = {};
|
|
236
|
-
this.
|
|
244
|
+
this.j && (t = this.j.St(s.It.Tt));
|
|
237
245
|
const i = {};
|
|
238
246
|
for (const s in t) {
|
|
239
247
|
let e = null;
|
|
@@ -243,7 +251,7 @@ export default class e extends t {
|
|
|
243
251
|
}
|
|
244
252
|
W() {
|
|
245
253
|
var t;
|
|
246
|
-
if (!this.
|
|
254
|
+
if (!this.j) return;
|
|
247
255
|
const i = {};
|
|
248
256
|
for (const s in this.banners) {
|
|
249
257
|
const e =
|
|
@@ -251,86 +259,86 @@ export default class e extends t {
|
|
|
251
259
|
null;
|
|
252
260
|
i[s] = e;
|
|
253
261
|
}
|
|
254
|
-
this.
|
|
262
|
+
this.j.Pt(s.It.Tt, i), this._t();
|
|
255
263
|
}
|
|
256
|
-
|
|
264
|
+
_t() {
|
|
257
265
|
var t, i;
|
|
258
|
-
null === (t = this.
|
|
266
|
+
null === (t = this.j) ||
|
|
259
267
|
void 0 === t ||
|
|
260
|
-
t.
|
|
268
|
+
t.Pt(s.It.kt, null === (i = this.C) || void 0 === i ? void 0 : i.$t());
|
|
261
269
|
}
|
|
262
|
-
|
|
270
|
+
xt() {
|
|
263
271
|
var t;
|
|
264
272
|
return (
|
|
265
|
-
(null === (t = this.
|
|
273
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.St(s.It.kt)) || null
|
|
266
274
|
);
|
|
267
275
|
}
|
|
268
|
-
|
|
276
|
+
Et() {
|
|
269
277
|
return this.T;
|
|
270
278
|
}
|
|
271
|
-
|
|
279
|
+
Lt(t) {
|
|
272
280
|
this.T = t;
|
|
273
281
|
}
|
|
274
|
-
|
|
282
|
+
zt() {
|
|
275
283
|
var t;
|
|
276
|
-
const s = null === (t = this.
|
|
277
|
-
i = this.
|
|
284
|
+
const s = null === (t = this.C) || void 0 === t ? void 0 : t.$t(),
|
|
285
|
+
i = this.xt();
|
|
278
286
|
return null == i || s === i;
|
|
279
287
|
}
|
|
280
|
-
|
|
281
|
-
return this.R.
|
|
288
|
+
Kt(t) {
|
|
289
|
+
return this.R.Ut(t);
|
|
282
290
|
}
|
|
283
|
-
|
|
291
|
+
Wt() {
|
|
284
292
|
var t;
|
|
285
293
|
return (
|
|
286
|
-
(null === (t = this.
|
|
294
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.St(s.It.At)) || {}
|
|
287
295
|
);
|
|
288
296
|
}
|
|
289
|
-
|
|
290
|
-
this.
|
|
297
|
+
Mt(t) {
|
|
298
|
+
this.j && this.j.Pt(s.It.At, t);
|
|
291
299
|
}
|
|
292
|
-
|
|
300
|
+
$() {
|
|
293
301
|
var t;
|
|
294
302
|
return (
|
|
295
|
-
(null === (t = this.
|
|
303
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.St(s.It.Xt)) || []
|
|
296
304
|
);
|
|
297
305
|
}
|
|
298
306
|
J(t) {
|
|
299
307
|
var i;
|
|
300
|
-
if (!this.
|
|
301
|
-
const e = null === (i = this.h) || void 0 === i ? void 0 : i.
|
|
308
|
+
if (!this.j) return;
|
|
309
|
+
const e = null === (i = this.h) || void 0 === i ? void 0 : i.Gt(),
|
|
302
310
|
n = null != e ? e : u,
|
|
303
311
|
r = t.length <= n ? t : t.slice(-n);
|
|
304
|
-
this.
|
|
312
|
+
this.j.Pt(s.It.Xt, r);
|
|
305
313
|
}
|
|
306
|
-
|
|
314
|
+
L() {
|
|
307
315
|
var t;
|
|
308
316
|
return (
|
|
309
|
-
(null === (t = this.
|
|
317
|
+
(null === (t = this.j) || void 0 === t ? void 0 : t.St(s.It.Ht)) || {}
|
|
310
318
|
);
|
|
311
319
|
}
|
|
312
320
|
rt(t, i) {
|
|
313
|
-
if (!this.
|
|
314
|
-
const e = this
|
|
321
|
+
if (!this.j) return;
|
|
322
|
+
const e = this.L();
|
|
315
323
|
for (const s of t) e[s] = i;
|
|
316
|
-
this.
|
|
324
|
+
this.j.Pt(s.It.Ht, e);
|
|
317
325
|
}
|
|
318
326
|
changeUser() {
|
|
319
|
-
this.
|
|
327
|
+
this.Jt(), this.Y();
|
|
320
328
|
}
|
|
321
329
|
clearData() {
|
|
322
330
|
this.Y();
|
|
323
331
|
}
|
|
324
332
|
P() {
|
|
325
|
-
return !!this.h && (!!this.h.
|
|
333
|
+
return !!this.h && (!!this.h.Ot() || (0 !== this.h.Qt() && this.Jt(), !1));
|
|
326
334
|
}
|
|
327
|
-
|
|
335
|
+
Jt() {
|
|
328
336
|
(this.banners = {}),
|
|
329
|
-
this.
|
|
330
|
-
(this.
|
|
331
|
-
this.
|
|
332
|
-
this.
|
|
333
|
-
this.
|
|
337
|
+
this.j &&
|
|
338
|
+
(this.j.Vt(s.It.Tt),
|
|
339
|
+
this.j.Vt(s.It.At),
|
|
340
|
+
this.j.Vt(s.It.Xt),
|
|
341
|
+
this.j.Vt(s.It.Ht)),
|
|
334
342
|
this.R.A({});
|
|
335
343
|
}
|
|
336
344
|
}
|