@braze/web-sdk 6.8.0 → 6.10.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 +113 -21
- package/package.json +1 -1
- package/shared-lib/event-types.js +20 -20
- package/shared-lib/indexed-db-adapter.js +64 -64
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +8 -8
- 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 +10 -10
- 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.js +102 -102
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
- package/src/ContentCards/ui/show-content-cards.js +5 -5
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +3 -3
- 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 +5 -5
- package/src/Core/log-purchase.js +9 -9
- package/src/Core/logout.js +22 -0
- package/src/Core/open-session.js +7 -7
- package/src/Core/set-logger.js +2 -2
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +6 -6
- package/src/DUST/dust-provider.js +249 -240
- package/src/DUST/dust-shared-worker-code.js +1 -1
- package/src/DUST/dust-shared-worker-impl.js +15 -14
- package/src/DUST/dust-worker-bridge.js +50 -35
- 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 +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +4 -4
- package/src/InAppMessage/display/in-app-message-to-html.js +16 -16
- package/src/InAppMessage/in-app-message-factory.js +36 -36
- package/src/InAppMessage/in-app-message-manager.js +78 -78
- package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +5 -5
- package/src/InAppMessage/log-in-app-message-impression.js +4 -4
- package/src/InAppMessage/models/control-message.js +4 -4
- package/src/InAppMessage/models/full-screen-message.js +4 -4
- package/src/InAppMessage/models/html-message.js +3 -3
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +12 -12
- package/src/InAppMessage/models/modal-message.js +4 -4
- package/src/InAppMessage/models/slide-up-message.js +4 -4
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +14 -14
- package/src/Push/push-manager-factory.js +2 -2
- package/src/Push/push-manager.js +38 -38
- package/src/Push/unregister-push-token-on-server.js +35 -0
- package/src/Push/unregister-push.js +2 -1
- package/src/Push/utils/push-utils.js +6 -6
- package/src/User/user-manager.js +14 -14
- package/src/User/user.js +25 -25
- package/src/common/base-provider.js +1 -1
- package/src/common/content-cards-display.js +7 -7
- package/src/common/event-logger.js +3 -3
- package/src/common/properties-base.js +3 -3
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +11 -11
- package/src/managers/braze-instance.js +56 -56
- package/src/managers/device-manager.js +10 -10
- package/src/managers/network-manager.js +103 -102
- package/src/managers/server-config-manager.js +112 -95
- package/src/managers/session-manager.js +20 -20
- package/src/managers/storage-manager-factory.js +9 -9
- package/src/managers/storage-manager.js +73 -73
- package/src/managers/subscription-manager.js +2 -2
- package/src/managers/utils.js +1 -1
- 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/identifier.js +2 -2
- package/src/models/push-token.js +6 -6
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +42 -24
- package/src/request-controller.js +126 -126
- 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 +1 -1
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +2 -2
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +36 -36
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +33 -33
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +68 -68
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/braze-actions.js +7 -7
- package/src/util/browser-detector.js +2 -2
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/code-utils.js +2 -2
- package/src/util/deprecation-utils.js +2 -2
- package/src/util/dom-utils.js +7 -7
- package/src/util/ecommerce-event-validation.js +52 -35
- package/src/util/html-display-utils.js +11 -11
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -35
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +2 -2
- package/src/util/validation-utils.js +12 -12
- package/src/util/window-utils.js +2 -2
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.10.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.10.0)";
|
|
34
|
+
null != b.Ud ? b.Ud(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
|
-
export default
|
|
38
|
+
export default b;
|
|
@@ -4,26 +4,26 @@ export default {
|
|
|
4
4
|
se: "cookieExpiryInDays",
|
|
5
5
|
Oh: "noCookies",
|
|
6
6
|
Th: "devicePropertyAllowlist",
|
|
7
|
-
|
|
7
|
+
ka: "disablePushTokenMaintenance",
|
|
8
8
|
Rh: "enableLogging",
|
|
9
9
|
Ph: "enableSdkAuthentication",
|
|
10
|
-
|
|
10
|
+
_a: "manageServiceWorkerExternally",
|
|
11
11
|
Dh: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
12
12
|
Lh: "sessionTimeoutInSeconds",
|
|
13
13
|
yh: "appVersion",
|
|
14
14
|
Mh: "appVersionNumber",
|
|
15
15
|
xa: "serviceWorkerLocation",
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Ma: "safariWebsitePushId",
|
|
17
|
+
Aa: "localization",
|
|
18
18
|
sr: "contentSecurityNonce",
|
|
19
19
|
nr: "allowUserSuppliedJavascript",
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
ja: "inAppMessageZIndex",
|
|
21
|
+
ba: "openInAppMessagesInNewTab",
|
|
22
22
|
oh: "requireExplicitInAppMessageDismissal",
|
|
23
23
|
Uh: "doNotLoadFontAwesome",
|
|
24
24
|
Wh: "deviceId",
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
ya: "serviceWorkerScope",
|
|
26
|
+
Ye: "dustHost",
|
|
27
27
|
Bh: "sdkFlavor",
|
|
28
28
|
tn: "openCardsInNewTab",
|
|
29
29
|
};
|
|
@@ -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
|
}
|
package/src/Banner/banner.js
CHANGED
|
@@ -1,33 +1,54 @@
|
|
|
1
|
-
import { PropertiesBase as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(this.
|
|
7
|
-
(this.
|
|
8
|
-
(this.
|
|
1
|
+
import { PropertiesBase as D } from "../common/properties-base.js";
|
|
2
|
+
import f from "../managers/subscription-manager.js";
|
|
3
|
+
export default class Banner extends D {
|
|
4
|
+
constructor(s, i, t, h = !1, r = !1, e = -1, n = {}, o = null) {
|
|
5
|
+
super(n),
|
|
6
|
+
(this.id = s),
|
|
7
|
+
(this.placementId = i),
|
|
8
|
+
(this.html = t),
|
|
9
|
+
(this.ss = h),
|
|
9
10
|
(this.isControl = r),
|
|
10
|
-
(this.
|
|
11
|
-
(this.G =
|
|
12
|
-
(this.id =
|
|
13
|
-
(this.placementId =
|
|
14
|
-
(this.html =
|
|
15
|
-
(this.
|
|
11
|
+
(this.ts = e),
|
|
12
|
+
(this.G = o),
|
|
13
|
+
(this.id = s),
|
|
14
|
+
(this.placementId = i),
|
|
15
|
+
(this.html = t),
|
|
16
|
+
(this.ss = h),
|
|
16
17
|
(this.isControl = r),
|
|
17
|
-
(this.
|
|
18
|
-
(this.
|
|
18
|
+
(this.ts = e),
|
|
19
|
+
(this.hs = !1),
|
|
20
|
+
(this.rs = !1),
|
|
21
|
+
(this.es = null);
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
subscribeToDismissedEvent(s) {
|
|
24
|
+
return this.ns().Ut(s);
|
|
25
|
+
}
|
|
26
|
+
removeSubscription(s) {
|
|
27
|
+
null != this.es && this.es.removeSubscription(s);
|
|
28
|
+
}
|
|
29
|
+
removeAllSubscriptions() {
|
|
30
|
+
null != this.es && this.es.removeAllSubscriptions();
|
|
31
|
+
}
|
|
32
|
+
os() {
|
|
21
33
|
return this.isControl;
|
|
22
34
|
}
|
|
35
|
+
ns() {
|
|
36
|
+
return null == this.es && (this.es = new f()), this.es;
|
|
37
|
+
}
|
|
38
|
+
Ft() {
|
|
39
|
+
return (
|
|
40
|
+
!this.rs &&
|
|
41
|
+
((this.rs = !0), this.ns().A(), this.removeAllSubscriptions(), !0)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
23
44
|
qt() {
|
|
24
45
|
return {
|
|
25
46
|
id: this.id,
|
|
26
47
|
pid: this.placementId,
|
|
27
48
|
html: this.html,
|
|
28
|
-
its: this.
|
|
49
|
+
its: this.ss,
|
|
29
50
|
ic: this.isControl,
|
|
30
|
-
eat: this.
|
|
51
|
+
eat: this.ts,
|
|
31
52
|
pr: this.properties,
|
|
32
53
|
sk: this.G,
|
|
33
54
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
attachHtmlToIframeWithNonce as
|
|
3
|
-
buildBrazeBridge as
|
|
2
|
+
attachHtmlToIframeWithNonce as N,
|
|
3
|
+
buildBrazeBridge as E,
|
|
4
4
|
} from "../../util/html-display-utils.js";
|
|
5
|
-
import
|
|
5
|
+
import b from "../../../shared-lib/logger.js";
|
|
6
6
|
import { logBannerClick } from "../log-banner-click.js";
|
|
7
|
-
import { logBannerDismissal as
|
|
8
|
-
import { destroyBannerHtml as
|
|
7
|
+
import { logBannerDismissal as j } from "../log-banner-dismissal.js";
|
|
8
|
+
import { destroyBannerHtml as _ } from "./destroy-banner-html.js";
|
|
9
9
|
export const BANNER_PLACEMENT_ID = "data-ab-banner-placement-id";
|
|
10
10
|
export const BANNER_HTML_CLASS = "ab-html-banner";
|
|
11
11
|
export const CONTROL_BANNER_HTML_CLASS = "ab-html-control-banner";
|
|
@@ -19,7 +19,7 @@ export function controlBannerToHtml(n) {
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
export function bannerToHtml(n, t) {
|
|
22
|
-
if (n.
|
|
22
|
+
if (n.os()) return controlBannerToHtml(n);
|
|
23
23
|
const o = document.createElement("iframe");
|
|
24
24
|
return (
|
|
25
25
|
(o.id = n.id),
|
|
@@ -27,24 +27,24 @@ export function bannerToHtml(n, t) {
|
|
|
27
27
|
(o.className = "ab-html-banner"),
|
|
28
28
|
o.setAttribute(BANNER_PLACEMENT_ID, n.placementId),
|
|
29
29
|
o.setAttribute("title", "Banner"),
|
|
30
|
-
|
|
30
|
+
N(o, n.html, t),
|
|
31
31
|
(o.onload = () => {
|
|
32
32
|
const t = o.contentWindow,
|
|
33
33
|
e = t.document.getElementsByTagName("title");
|
|
34
34
|
e && e.length > 0 && o.setAttribute("title", e[0].textContent || "");
|
|
35
|
-
const r = Object.assign(Object.assign({},
|
|
35
|
+
const r = Object.assign(Object.assign({}, E(o)), {
|
|
36
36
|
logClick: function () {
|
|
37
37
|
logBannerClick(n, ...arguments);
|
|
38
38
|
},
|
|
39
39
|
closeMessage: function () {
|
|
40
40
|
!(function (n) {
|
|
41
41
|
const t = document.getElementById(n.id);
|
|
42
|
-
t &&
|
|
42
|
+
t && _(t), j(n);
|
|
43
43
|
})(n);
|
|
44
44
|
},
|
|
45
45
|
setBannerHeight: (n) => {
|
|
46
46
|
isNaN(n) || !isFinite(n) || n < 0
|
|
47
|
-
?
|
|
47
|
+
? b.warn(`Invalid banner height: ${n}`)
|
|
48
48
|
: (o.style.height = `${n}px`);
|
|
49
49
|
},
|
|
50
50
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { removeSubscription } from "../../Core/remove-subscription.js";
|
|
2
|
-
import { BannerStrings as
|
|
2
|
+
import { BannerStrings as x } from "../constants.js";
|
|
3
3
|
export function destroyBannerHtml(o) {
|
|
4
|
-
const r = o.getAttribute(
|
|
4
|
+
const r = o.getAttribute(x.ea);
|
|
5
5
|
null != r && removeSubscription(r),
|
|
6
6
|
o && o.parentNode && o.parentNode.removeChild(o);
|
|
7
7
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { BannerStrings as
|
|
1
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
2
|
+
import { BannerStrings as x } from "./constants.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
5
|
-
import { getBannerIfNotExpired as
|
|
5
|
+
import { getBannerIfNotExpired as A } from "./get-banner.js";
|
|
6
6
|
export function getAllBanners() {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
const n = {},
|
|
9
9
|
o = r.l();
|
|
10
10
|
if (
|
|
11
|
-
(!1 === (null == o ? void 0 : o.
|
|
12
|
-
!(null == o ? void 0 : o.
|
|
11
|
+
(!1 === (null == o ? void 0 : o.Ot()) && b.error(x.aa),
|
|
12
|
+
!(null == o ? void 0 : o.Ot()))
|
|
13
13
|
)
|
|
14
14
|
return n;
|
|
15
15
|
const t = i.o().k();
|
|
16
|
-
for (const r in t) n[r] =
|
|
16
|
+
for (const r in t) n[r] = A(t, r);
|
|
17
17
|
return n;
|
|
18
18
|
}
|
package/src/Banner/get-banner.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { BannerStrings as
|
|
1
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
2
|
+
import { BannerStrings as x } from "./constants.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
5
5
|
export function getBannerIfNotExpired(n, r) {
|
|
6
6
|
const e = n[r];
|
|
7
7
|
if (!e) return null;
|
|
8
|
-
const t = e.
|
|
8
|
+
const t = e.ts,
|
|
9
9
|
o = new Date().valueOf();
|
|
10
10
|
return -1 !== t && 1e3 * t < o
|
|
11
|
-
? (
|
|
11
|
+
? (b.info(`Banner with ID: ${e.id} and placement ID: ${r} has expired.`),
|
|
12
12
|
null)
|
|
13
13
|
: e;
|
|
14
14
|
}
|
|
15
15
|
export function getBanner(n) {
|
|
16
16
|
var e;
|
|
17
17
|
if (!r.rr()) return;
|
|
18
|
-
!1 === (null === (e = r.l()) || void 0 === e ? void 0 : e.
|
|
19
|
-
|
|
18
|
+
!1 === (null === (e = r.l()) || void 0 === e ? void 0 : e.Ot()) &&
|
|
19
|
+
b.error(x.aa);
|
|
20
20
|
const t = i.o();
|
|
21
21
|
if (!t.P()) return null;
|
|
22
22
|
return getBannerIfNotExpired(t.k(), n);
|
package/src/Banner/index.js
CHANGED
|
@@ -6,3 +6,4 @@ export { getAllBanners } from "./get-all-banners.js";
|
|
|
6
6
|
export { subscribeToBannersUpdates } from "./subscribe-to-banners-updates.js";
|
|
7
7
|
export { logBannerImpressions } from "./log-banner-impressions.js";
|
|
8
8
|
export { logBannerClick } from "./log-banner-click.js";
|
|
9
|
+
export { dismissBanner } from "./dismiss-banner.js";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import Banner from "./banner.js";
|
|
3
|
-
import { logger as
|
|
3
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
5
|
-
import { keys as
|
|
5
|
+
import { keys as C } from "../util/code-utils.js";
|
|
6
6
|
export function logBannerClick(n, o) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (!(n instanceof Banner))
|
|
9
9
|
return (
|
|
10
|
-
|
|
10
|
+
b.error("Banner argument to logBannerClick must be an Banner object."), !1
|
|
11
11
|
);
|
|
12
12
|
const e = i.o(),
|
|
13
13
|
t = e.k();
|
|
14
|
-
return 0 ===
|
|
15
|
-
? (
|
|
14
|
+
return 0 === C(t).length
|
|
15
|
+
? (b.info("Not logging banner click. No banners exist."), !1)
|
|
16
16
|
: t[n.placementId]
|
|
17
|
-
? e.
|
|
18
|
-
: (
|
|
17
|
+
? e.Ct(n, o)
|
|
18
|
+
: (b.info(
|
|
19
19
|
`Not logging banner click for ID ${n.placementId}. The placement ID did not correspond to any banner.`,
|
|
20
20
|
),
|
|
21
21
|
!1);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import Banner from "./banner.js";
|
|
3
|
-
import { logger as
|
|
3
|
+
import { logger as b } from "../../shared-lib/index.js";
|
|
4
4
|
import i from "./banner-provider-factory.js";
|
|
5
|
-
import { keys as
|
|
5
|
+
import { keys as C } from "../util/code-utils.js";
|
|
6
6
|
export function logBannerDismissal(n) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (!(n instanceof Banner))
|
|
9
9
|
return (
|
|
10
|
-
|
|
10
|
+
b.error("Banner argument to logBannerDismissal must be a Banner object."),
|
|
11
11
|
!1
|
|
12
12
|
);
|
|
13
13
|
const o = i.o(),
|
|
14
14
|
e = o.k();
|
|
15
|
-
return 0 ===
|
|
16
|
-
? (
|
|
15
|
+
return 0 === C(e).length
|
|
16
|
+
? (b.info("Not logging banner dismissal. No banners exist."), !1)
|
|
17
17
|
: e[n.placementId]
|
|
18
|
-
? o.
|
|
19
|
-
: (
|
|
18
|
+
? o.wt(n)
|
|
19
|
+
: (b.info(
|
|
20
20
|
`Not logging banner dismissal for ID ${n.placementId}. The placement ID did not correspond to any banner.`,
|
|
21
21
|
),
|
|
22
22
|
!1);
|