@braze/web-sdk 5.8.1 → 5.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 +14 -9
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +19 -19
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +3 -3
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +11 -11
- package/src/Banner/banner-provider.js +22 -19
- package/src/Banner/display/banner-to-html.js +32 -27
- package/src/Banner/get-all-banners.js +11 -5
- package/src/Banner/get-banner.js +6 -3
- package/src/Banner/log-banner-click.js +2 -2
- package/src/Banner/log-banner-impressions.js +4 -4
- package/src/Banner/request-banners-refresh.js +5 -2
- package/src/Banner/subscribe-to-banners-updates.js +2 -2
- package/src/Banner/ui/insert-banner.js +2 -2
- package/src/Card/card-manager.js +9 -9
- package/src/Card/display/card-display.js +5 -5
- package/src/Card/log-card-click.js +2 -2
- package/src/Card/log-card-dismissal.js +2 -2
- package/src/Card/log-card-impressions.js +2 -2
- package/src/Card/models/captioned-image.js +17 -17
- package/src/Card/models/card.js +58 -58
- package/src/Card/models/classic-card.js +17 -17
- package/src/Card/models/control-card.js +8 -8
- package/src/Card/models/image-only.js +15 -15
- package/src/Card/util/card-factory.js +24 -24
- package/src/ContentCards/content-cards-provider.js +77 -75
- 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 +3 -3
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/change-user.js +1 -1
- package/src/Core/disable-sdk.js +4 -4
- package/src/Core/enable-sdk.js +3 -3
- package/src/Core/handle-braze-action.js +2 -2
- package/src/Core/is-initialized.js +1 -1
- package/src/Core/open-session.js +4 -4
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/wipe-data.js +7 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +3 -3
- package/src/FeatureFlags/feature-flags-provider.js +17 -11
- 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 +1 -1
- package/src/Feed/feed-provider-factory.js +1 -1
- package/src/Feed/feed-provider.js +12 -12
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +8 -8
- package/src/InAppMessage/display/in-app-message-to-html.js +18 -18
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager.js +70 -70
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- 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 +1 -1
- package/src/InAppMessage/models/control-message.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +6 -6
- package/src/InAppMessage/models/html-message.js +7 -7
- package/src/InAppMessage/models/in-app-message-button.js +3 -3
- package/src/InAppMessage/models/in-app-message.js +36 -36
- package/src/InAppMessage/models/modal-message.js +6 -6
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- 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 +13 -13
- package/src/Push/push-manager.js +81 -81
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +10 -10
- package/src/User/user.js +15 -15
- package/src/common/constants.js +2 -0
- package/src/common/event-logger.js +2 -2
- package/src/common/feed-display.js +6 -6
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/auth-manager.js +30 -30
- package/src/managers/braze-instance.js +94 -93
- package/src/managers/device-manager.js +14 -14
- package/src/managers/network-manager.js +123 -117
- package/src/managers/server-config-manager.js +91 -79
- package/src/managers/session-manager.js +8 -8
- package/src/managers/storage-manager-factory.js +5 -5
- package/src/managers/storage-manager.js +48 -48
- package/src/managers/subscription-manager.js +4 -4
- package/src/models/backend-errors.js +4 -4
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +3 -3
- package/src/models/push-token.js +4 -4
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +18 -18
- package/src/request-controller.js +86 -85
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +2 -2
- package/src/triggers/models/filter-set.js +4 -4
- package/src/triggers/models/filter.js +6 -6
- 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 +1 -1
- package/src/triggers/models/trigger-condition.js +33 -33
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +12 -12
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +17 -17
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +5 -5
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/dom-utils.js +3 -3
- package/src/util/html-display-utils.js +14 -14
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +2 -2
- package/src/util/request-header-utils.js +13 -13
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/validation-utils.js +2 -2
- package/src/util/window-utils.js +2 -2
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v5.
|
|
2
|
+
* Type definitions for @braze/web-sdk v5.9.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2025 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -58,7 +58,8 @@ export class DeviceProperties {
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Abstract base for news feed and Content Cards cards. Use subclasses `ClassicCard`, `CaptionedImage`,
|
|
61
|
-
* `ImageOnly`, and `ControlCard`.
|
|
61
|
+
* `ImageOnly`, and `ControlCard`. For example, you can check `if (card instanceof ClassicCard)` to
|
|
62
|
+
* determine if the card is of the type `ClassicCard`.
|
|
62
63
|
*/
|
|
63
64
|
export class Card {
|
|
64
65
|
/**
|
|
@@ -517,7 +518,8 @@ type CropType =
|
|
|
517
518
|
|
|
518
519
|
/**
|
|
519
520
|
* Abstract base for in-app messages. Use subclasses `SlideUpMessage`,
|
|
520
|
-
* `ModalMessage`, `FullScreenMessage`, and `HtmlMessage`.
|
|
521
|
+
* `ModalMessage`, `FullScreenMessage`, and `HtmlMessage`. For example, you can check `if (message instanceof FullScreenMessage)` to
|
|
522
|
+
* determine if the message is of the type `FullScreenMessage`.
|
|
521
523
|
*/
|
|
522
524
|
export class InAppMessage {
|
|
523
525
|
static SlideFrom: {
|
|
@@ -1446,7 +1448,7 @@ export class User {
|
|
|
1446
1448
|
/**
|
|
1447
1449
|
* Sets the LINE user ID for the user.
|
|
1448
1450
|
*
|
|
1449
|
-
* @param lineId - Must be a non-empty string no greater than 33 characters in length.
|
|
1451
|
+
* @param lineId - Must be a non-empty string no greater than 33 characters in length.
|
|
1450
1452
|
* Accepts an explicit null value to null out attribute.
|
|
1451
1453
|
*
|
|
1452
1454
|
* @returns Whether the update was successfully enqueued.
|
|
@@ -2162,7 +2164,7 @@ export function openSession(): void;
|
|
|
2162
2164
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2163
2165
|
*
|
|
2164
2166
|
* ```
|
|
2165
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2167
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.9/service-worker.js');
|
|
2166
2168
|
* ```
|
|
2167
2169
|
*
|
|
2168
2170
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2402,8 +2404,8 @@ export function handleBrazeAction(
|
|
|
2402
2404
|
* Gets a feature flag by its ID.
|
|
2403
2405
|
*
|
|
2404
2406
|
* @param id - The ID of the feature flag.
|
|
2405
|
-
* @returns - An object of type `FeatureFlag`, if feature flag with given ID
|
|
2406
|
-
*
|
|
2407
|
+
* @returns - An object of type `FeatureFlag`, if feature flag with given ID is enabled or explicitly disabled via experiment or canvas.
|
|
2408
|
+
* The method returns `null` if feature flag is not rolled out to the user or does not exist, or returns `undefined` if the SDK has not been initialized.
|
|
2407
2409
|
*/
|
|
2408
2410
|
export function getFeatureFlag(id: string): FeatureFlag | null | undefined;
|
|
2409
2411
|
|
|
@@ -2475,7 +2477,10 @@ export function getBanner(placementId: string): Banner | null | undefined;
|
|
|
2475
2477
|
* @param banner - The `Banner` to insert onto the page.
|
|
2476
2478
|
* @param parentNode - The HTML element to render the banner into.
|
|
2477
2479
|
*/
|
|
2478
|
-
export function insertBanner(
|
|
2480
|
+
export function insertBanner(
|
|
2481
|
+
banner: Banner | null | undefined,
|
|
2482
|
+
parentNode: HTMLElement,
|
|
2483
|
+
): void;
|
|
2479
2484
|
|
|
2480
2485
|
/**
|
|
2481
2486
|
* Logs that the user clicked the given banner. This should generally be called through the Braze JavaScript bridge
|
|
@@ -2630,7 +2635,7 @@ export type InitializationOptions = {
|
|
|
2630
2635
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2631
2636
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2632
2637
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2633
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2638
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.9/service-worker.js');` or by including the content
|
|
2634
2639
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2635
2640
|
*/
|
|
2636
2641
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
const d = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
4
|
+
bc: "pc",
|
|
5
5
|
Ac: "ca",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Su: "i",
|
|
7
|
+
qu: "ie",
|
|
8
|
+
ts: "cci",
|
|
9
|
+
rs: "ccic",
|
|
10
10
|
Mt: "ccc",
|
|
11
11
|
Wt: "ccd",
|
|
12
|
-
|
|
12
|
+
Fl: "ss",
|
|
13
13
|
Dl: "se",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Ki: "si",
|
|
15
|
+
Li: "sc",
|
|
16
|
+
Qi: "sbc",
|
|
17
17
|
Mc: "sfe",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
Do: "iec",
|
|
19
|
+
vc: "lr",
|
|
20
|
+
fc: "uae",
|
|
21
|
+
ss: "ci",
|
|
22
22
|
Ot: "cc",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
yc: "lcaa",
|
|
24
|
+
kc: "lcar",
|
|
25
|
+
Hn: "inc",
|
|
26
|
+
On: "add",
|
|
27
|
+
Gn: "rem",
|
|
28
28
|
$n: "set",
|
|
29
29
|
Bn: "ncam",
|
|
30
|
-
|
|
30
|
+
jc: "sgu",
|
|
31
31
|
yr: "ffi",
|
|
32
32
|
ro: "bi",
|
|
33
33
|
ct: "bc",
|
package/shared-lib/guid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class st {
|
|
2
2
|
constructor(t, e) {
|
|
3
3
|
(this.database = t),
|
|
4
4
|
(this.vd = e),
|
|
@@ -333,7 +333,7 @@ export default class tt {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
336
|
+
st.Ls = {
|
|
337
337
|
Fs: {
|
|
338
338
|
Sd: "AppboyServiceWorkerAsyncStorage",
|
|
339
339
|
VERSION: 6,
|
|
@@ -345,7 +345,7 @@ tt.Ls = {
|
|
|
345
345
|
Js: "cardUpdates",
|
|
346
346
|
pe: "optOut",
|
|
347
347
|
kr: "pendingData",
|
|
348
|
-
|
|
348
|
+
yh: "sdkAuthenticationSignature",
|
|
349
349
|
},
|
|
350
350
|
be: 1,
|
|
351
351
|
},
|
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const N = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
26
|
if (N.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v5.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v5.9.0)";
|
|
28
28
|
null != N.vd ? N.vd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
32
|
if (N.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v5.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v5.9.0)";
|
|
34
34
|
null != N.vd ? N.vd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -4,25 +4,25 @@ export default {
|
|
|
4
4
|
Wh: "noCookies",
|
|
5
5
|
Vh: "devicePropertyAllowlist",
|
|
6
6
|
Da: "disablePushTokenMaintenance",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
$h: "enableLogging",
|
|
8
|
+
Yh: "enableSdkAuthentication",
|
|
9
9
|
Ca: "manageServiceWorkerExternally",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Xh: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
Zh: "sessionTimeoutInSeconds",
|
|
12
|
+
Qh: "appVersion",
|
|
13
|
+
Ea: "appVersionNumber",
|
|
14
14
|
_a: "serviceWorkerLocation",
|
|
15
15
|
Ba: "safariWebsitePushId",
|
|
16
|
-
|
|
16
|
+
Zn: "localization",
|
|
17
17
|
er: "contentSecurityNonce",
|
|
18
18
|
re: "allowUserSuppliedJavascript",
|
|
19
|
-
|
|
19
|
+
Go: "inAppMessageZIndex",
|
|
20
20
|
Ko: "openInAppMessagesInNewTab",
|
|
21
21
|
en: "openNewsFeedCardsInNewTab",
|
|
22
22
|
mh: "requireExplicitInAppMessageDismissal",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Ia: "doNotLoadFontAwesome",
|
|
24
|
+
Na: "deviceId",
|
|
25
25
|
Aa: "serviceWorkerScope",
|
|
26
|
-
|
|
26
|
+
Oa: "sdkFlavor",
|
|
27
27
|
tn: "openCardsInNewTab",
|
|
28
28
|
};
|
|
@@ -26,10 +26,10 @@ export default class e extends t {
|
|
|
26
26
|
(this.R = 10),
|
|
27
27
|
(this.I = null),
|
|
28
28
|
(this.q = null),
|
|
29
|
-
(this.
|
|
30
|
-
r.
|
|
31
|
-
(this.
|
|
32
|
-
(this.
|
|
29
|
+
(this.D = new u()),
|
|
30
|
+
r.F(this.D),
|
|
31
|
+
(this.N = null),
|
|
32
|
+
(this.k = null);
|
|
33
33
|
}
|
|
34
34
|
U(t) {
|
|
35
35
|
if (this.L() && null != t && t.banners) {
|
|
@@ -41,7 +41,7 @@ export default class e extends t {
|
|
|
41
41
|
null != i && null != i.banner && (e = n(i.banner)),
|
|
42
42
|
e && (this.banners[t] = e);
|
|
43
43
|
}
|
|
44
|
-
this.M(), this.
|
|
44
|
+
this.M(), this.D.X(this.banners);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
$(t, s, i, e = !0) {
|
|
@@ -87,7 +87,7 @@ export default class e extends t {
|
|
|
87
87
|
},
|
|
88
88
|
nt: (e, r) => {
|
|
89
89
|
let o;
|
|
90
|
-
if (((this.
|
|
90
|
+
if (((this.k = t), m)) {
|
|
91
91
|
let t = this.I;
|
|
92
92
|
(null == t || t < 1e3 * this.R) && (t = 1e3 * this.R),
|
|
93
93
|
(o = Math.min(3e5, a(1e3 * this.R, 3 * t)));
|
|
@@ -110,7 +110,7 @@ export default class e extends t {
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
ht() {
|
|
113
|
-
return this.
|
|
113
|
+
return this.k;
|
|
114
114
|
}
|
|
115
115
|
lt(t, s) {
|
|
116
116
|
const i = { id: t.id };
|
|
@@ -158,10 +158,10 @@ export default class e extends t {
|
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
160
|
Ct() {
|
|
161
|
-
return this.
|
|
161
|
+
return this.N;
|
|
162
162
|
}
|
|
163
163
|
Tt(t) {
|
|
164
|
-
this.
|
|
164
|
+
this.N = t;
|
|
165
165
|
}
|
|
166
166
|
Rt() {
|
|
167
167
|
var t;
|
|
@@ -176,26 +176,29 @@ export default class e extends t {
|
|
|
176
176
|
return null == i || s === i;
|
|
177
177
|
}
|
|
178
178
|
qt(t) {
|
|
179
|
-
return this.
|
|
179
|
+
return this.D.Dt(t);
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
Ft() {
|
|
182
182
|
var t;
|
|
183
183
|
return (
|
|
184
|
-
(null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.
|
|
184
|
+
(null === (t = this.C) || void 0 === t ? void 0 : t.ft(s.gt.Nt)) || {}
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
this.C && this.C.Bt(s.gt.
|
|
187
|
+
kt(t) {
|
|
188
|
+
this.C && this.C.Bt(s.gt.Nt, t);
|
|
189
189
|
}
|
|
190
190
|
changeUser() {
|
|
191
|
-
this.
|
|
191
|
+
this.xt(), this.G();
|
|
192
|
+
}
|
|
193
|
+
clearData() {
|
|
194
|
+
this.G();
|
|
192
195
|
}
|
|
193
196
|
L() {
|
|
194
|
-
return !!this.B && (!!this.B.
|
|
197
|
+
return !!this.B && (!!this.B.zt() || (0 !== this.B.Et() && this.xt(), !1));
|
|
195
198
|
}
|
|
196
|
-
|
|
199
|
+
xt() {
|
|
197
200
|
(this.banners = {}),
|
|
198
|
-
this.C && (this.C.Ut(s.gt.vt), this.C.Ut(s.gt.
|
|
199
|
-
this.
|
|
201
|
+
this.C && (this.C.Ut(s.gt.vt), this.C.Ut(s.gt.Nt)),
|
|
202
|
+
this.D.X({});
|
|
200
203
|
}
|
|
201
204
|
}
|
|
@@ -9,49 +9,54 @@ import { logBannerClick } from "../log-banner-click.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";
|
|
12
|
-
export function controlBannerToHtml(
|
|
13
|
-
const
|
|
12
|
+
export function controlBannerToHtml(n) {
|
|
13
|
+
const t = document.createElement("div");
|
|
14
14
|
return (
|
|
15
|
-
(
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
(t.id = n.id),
|
|
16
|
+
(t.className = "ab-html-control-banner"),
|
|
17
|
+
t.setAttribute(BANNER_PLACEMENT_ID, n.placementId),
|
|
18
|
+
t
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
export function bannerToHtml(
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
21
|
+
export function bannerToHtml(n, t) {
|
|
22
|
+
if (n.Jt()) return controlBannerToHtml(n);
|
|
23
|
+
const e = document.createElement("iframe");
|
|
24
24
|
return (
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
m(
|
|
31
|
-
(
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
(e.id = n.id),
|
|
26
|
+
t && e.setAttribute("nonce", t),
|
|
27
|
+
(e.className = "ab-html-banner"),
|
|
28
|
+
e.setAttribute(BANNER_PLACEMENT_ID, n.placementId),
|
|
29
|
+
e.setAttribute("title", "Banner"),
|
|
30
|
+
m(e, n.html, t),
|
|
31
|
+
(e.onload = () => {
|
|
32
|
+
const t = e.contentWindow,
|
|
33
|
+
o = t.document.getElementsByTagName("title");
|
|
34
|
+
o && o.length > 0 && e.setAttribute("title", o[0].textContent || "");
|
|
35
35
|
const a = Object.assign(
|
|
36
36
|
Object.assign(
|
|
37
37
|
{},
|
|
38
|
-
b(
|
|
39
|
-
import("../../Feed/ui/show-feed.js").then((
|
|
40
|
-
r.
|
|
38
|
+
b(e, () => {
|
|
39
|
+
import("../../Feed/ui/show-feed.js").then((n) => {
|
|
40
|
+
r.nn() ? n.showFeed() : N.error(p);
|
|
41
41
|
});
|
|
42
42
|
}),
|
|
43
43
|
),
|
|
44
44
|
{
|
|
45
45
|
logClick: function () {
|
|
46
|
-
logBannerClick(
|
|
46
|
+
logBannerClick(n, ...arguments);
|
|
47
47
|
},
|
|
48
48
|
closeMessage: function () {},
|
|
49
|
+
setBannerHeight: (n) => {
|
|
50
|
+
isNaN(n) || !isFinite(n) || n < 0
|
|
51
|
+
? N.warn(`Invalid banner height: ${n}`)
|
|
52
|
+
: (e.style.height = `${n}px`);
|
|
53
|
+
},
|
|
49
54
|
},
|
|
50
55
|
);
|
|
51
|
-
(
|
|
52
|
-
(
|
|
53
|
-
|
|
56
|
+
(t.brazeBridge = a),
|
|
57
|
+
(t.appboyBridge = a),
|
|
58
|
+
t.dispatchEvent(new CustomEvent("ab.BridgeReady"));
|
|
54
59
|
}),
|
|
55
|
-
|
|
60
|
+
e
|
|
56
61
|
);
|
|
57
62
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
2
|
+
import { BANNERS_DISABLED_MESSAGE as v } from "../common/constants.js";
|
|
1
3
|
import r from "../managers/braze-instance.js";
|
|
2
4
|
import i from "./banner-provider-factory.js";
|
|
3
|
-
import { getBannerIfNotExpired as
|
|
5
|
+
import { getBannerIfNotExpired as y } from "./get-banner.js";
|
|
4
6
|
export function getAllBanners() {
|
|
5
7
|
if (!r.rr()) return;
|
|
6
8
|
const n = {},
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
o = r.v();
|
|
10
|
+
if (
|
|
11
|
+
(!1 === (null == o ? void 0 : o.zt()) && N.error(v),
|
|
12
|
+
!(null == o ? void 0 : o.zt()))
|
|
13
|
+
)
|
|
14
|
+
return n;
|
|
15
|
+
const t = i.m().dt();
|
|
16
|
+
for (const r in t) n[r] = y(t, r);
|
|
11
17
|
return n;
|
|
12
18
|
}
|
package/src/Banner/get-banner.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger as N } from "../../shared-lib/index.js";
|
|
2
|
+
import { BANNERS_DISABLED_MESSAGE as v } from "../common/constants.js";
|
|
2
3
|
import r from "../managers/braze-instance.js";
|
|
3
4
|
import i from "./banner-provider-factory.js";
|
|
4
5
|
export function getBannerIfNotExpired(n, r) {
|
|
@@ -12,8 +13,10 @@ export function getBannerIfNotExpired(n, r) {
|
|
|
12
13
|
: e;
|
|
13
14
|
}
|
|
14
15
|
export function getBanner(n) {
|
|
16
|
+
var e;
|
|
15
17
|
if (!r.rr()) return;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
!1 === (null === (e = r.v()) || void 0 === e ? void 0 : e.zt()) && N.error(v);
|
|
19
|
+
const t = i.m();
|
|
20
|
+
if (!t.L()) return null;
|
|
21
|
+
return getBannerIfNotExpired(t.dt(), n);
|
|
19
22
|
}
|
|
@@ -2,7 +2,7 @@ import r from "../managers/braze-instance.js";
|
|
|
2
2
|
import Banner from "./banner.js";
|
|
3
3
|
import { logger as N } 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))
|
|
@@ -11,7 +11,7 @@ export function logBannerClick(n, o) {
|
|
|
11
11
|
);
|
|
12
12
|
const e = i.m(),
|
|
13
13
|
t = e.dt();
|
|
14
|
-
return 0 ===
|
|
14
|
+
return 0 === C(t).length
|
|
15
15
|
? (N.info("Not logging banner click. No banners exist."), !1)
|
|
16
16
|
: t[n.placementId]
|
|
17
17
|
? e.lt(n, o)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
|
|
2
2
|
import c from "../common/event-logger.js";
|
|
3
3
|
import r from "../managers/braze-instance.js";
|
|
4
|
-
import { keys as
|
|
4
|
+
import { keys as C } from "../util/code-utils.js";
|
|
5
5
|
import i from "./banner-provider-factory.js";
|
|
6
6
|
export function logBannerImpressions(o) {
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (!o || o.length <= 0) return !1;
|
|
9
9
|
const n = i.m(),
|
|
10
10
|
s = n.dt();
|
|
11
|
-
if (0 ===
|
|
11
|
+
if (0 === C(s).length)
|
|
12
12
|
return N.info("Not logging banners impression. No banners exist."), !1;
|
|
13
|
-
const e = n.
|
|
13
|
+
const e = n.Ft(),
|
|
14
14
|
t = [];
|
|
15
15
|
for (const r of o) {
|
|
16
16
|
const o = s[r];
|
|
@@ -25,7 +25,7 @@ export function logBannerImpressions(o) {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
if (0 === t.length) return !1;
|
|
28
|
-
n.
|
|
28
|
+
n.kt(e);
|
|
29
29
|
const a = { ids: t };
|
|
30
30
|
return c.ut(d.ro, a).tt;
|
|
31
31
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { logger as N } from "../../shared-lib/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BANNERS_DISABLED_MESSAGE as v,
|
|
4
|
+
BRAZE_MUST_BE_INITIALIZED_ERROR as p,
|
|
5
|
+
} from "../common/constants.js";
|
|
3
6
|
import r, { OPTIONS as w } from "../managers/braze-instance.js";
|
|
4
7
|
import { isArray as z } from "../util/code-utils.js";
|
|
5
8
|
import { isValidBannerPlacementId as D } from "../util/validation-utils.js";
|
|
@@ -19,7 +22,7 @@ export function requestBannersRefresh(e, n, t) {
|
|
|
19
22
|
return void N.warn(
|
|
20
23
|
"Banners can be refreshed only once per session per user.",
|
|
21
24
|
);
|
|
22
|
-
if (!s
|
|
25
|
+
if ((!1 === s.zt() && N.error(v), !o.L()))
|
|
23
26
|
return void s.A(() => {
|
|
24
27
|
requestBannersRefresh(e, n, t);
|
|
25
28
|
});
|
|
@@ -12,9 +12,9 @@ export function subscribeToBannersUpdates(n) {
|
|
|
12
12
|
const s = t.qt(n);
|
|
13
13
|
if (!t.Ct()) {
|
|
14
14
|
const n =
|
|
15
|
-
null === (o = r.
|
|
15
|
+
null === (o = r.rn()) || void 0 === o
|
|
16
16
|
? void 0
|
|
17
|
-
: o.
|
|
17
|
+
: o.on(() => {
|
|
18
18
|
const n = t.ht();
|
|
19
19
|
n && n.length > 0 && t.$(n);
|
|
20
20
|
});
|
|
@@ -5,7 +5,7 @@ import { setupBannerUI as U } from "../../ui/js/banner-css.js";
|
|
|
5
5
|
import { addPassiveEventListener as J } from "../../util/dom-utils.js";
|
|
6
6
|
import { bannerToHtml as S } from "../display/banner-to-html.js";
|
|
7
7
|
import { destroyBannerHtml as A } from "../display/destroy-banner-html.js";
|
|
8
|
-
import { detectBannerImpressions as
|
|
8
|
+
import { detectBannerImpressions as E } from "../display/detect-banner-impressions.js";
|
|
9
9
|
import { subscribeToBannersUpdates } from "../subscribe-to-banners-updates.js";
|
|
10
10
|
export function insertBanner(o, e) {
|
|
11
11
|
if (!r.rr()) return;
|
|
@@ -22,5 +22,5 @@ export function insertBanner(o, e) {
|
|
|
22
22
|
const i = s[o.placementId];
|
|
23
23
|
i ? e.replaceChildren(S(i, r.ee(w.er))) : A(n);
|
|
24
24
|
});
|
|
25
|
-
s && n.setAttribute(f, s), e.replaceChildren(n), J(window, "scroll",
|
|
25
|
+
s && n.setAttribute(f, s), e.replaceChildren(n), J(window, "scroll", E), E();
|
|
26
26
|
}
|
package/src/Card/card-manager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ControlCard } from "./models/index.js";
|
|
2
2
|
import c from "../common/event-logger.js";
|
|
3
|
-
import
|
|
3
|
+
import F from "../models/request-result.js";
|
|
4
4
|
import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
|
|
5
5
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
6
6
|
export default class M {
|
|
@@ -8,7 +8,7 @@ export default class M {
|
|
|
8
8
|
(this.C = t), (this.C = t);
|
|
9
9
|
}
|
|
10
10
|
logClick(t, n) {
|
|
11
|
-
const r = new
|
|
11
|
+
const r = new F();
|
|
12
12
|
if ((t.$t(), null == t.url || "" === t.url))
|
|
13
13
|
return (
|
|
14
14
|
N.info(`Card ${t.id} has no url. Not logging click to Braze servers.`),
|
|
@@ -24,7 +24,7 @@ export default class M {
|
|
|
24
24
|
return c.ut(o, i);
|
|
25
25
|
}
|
|
26
26
|
Pt(t) {
|
|
27
|
-
const n = new
|
|
27
|
+
const n = new F();
|
|
28
28
|
if (!t.Qt())
|
|
29
29
|
return (
|
|
30
30
|
N.info(
|
|
@@ -40,13 +40,13 @@ export default class M {
|
|
|
40
40
|
return null == r ? n : c.ut(d.Wt, r);
|
|
41
41
|
}
|
|
42
42
|
Xt(t, n) {
|
|
43
|
-
const r = new
|
|
43
|
+
const r = new F(!0),
|
|
44
44
|
i = [],
|
|
45
45
|
o = [];
|
|
46
46
|
let e = {};
|
|
47
47
|
this.C && (e = n ? this.C.ft(s.gt.Yt) || {} : this.C.ft(s.gt.Zt) || {});
|
|
48
48
|
for (const s of t) {
|
|
49
|
-
s.
|
|
49
|
+
s._t()
|
|
50
50
|
? (s instanceof ControlCard ? o.push(s) : i.push(s),
|
|
51
51
|
s.id && (e[s.id] = !0))
|
|
52
52
|
: N.info(
|
|
@@ -59,13 +59,13 @@ export default class M {
|
|
|
59
59
|
if (
|
|
60
60
|
(this.C && (n ? this.C.Bt(s.gt.Yt, e) : this.C.Bt(s.gt.Zt, e)), null != l)
|
|
61
61
|
) {
|
|
62
|
-
const t = n ? d.
|
|
62
|
+
const t = n ? d.ts : d.ss,
|
|
63
63
|
s = c.ut(t, l);
|
|
64
|
-
r.
|
|
64
|
+
r.ns(s);
|
|
65
65
|
}
|
|
66
66
|
if (null != a && n) {
|
|
67
|
-
const t = c.ut(d.
|
|
68
|
-
r.
|
|
67
|
+
const t = c.ut(d.rs, a);
|
|
68
|
+
r.ns(t);
|
|
69
69
|
}
|
|
70
70
|
return r;
|
|
71
71
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createCloseButton as T } from "../../util/component-utils.js";
|
|
2
2
|
import { detectSwipe as H, DIRECTIONS as R } from "../../util/dom-utils.js";
|
|
3
|
-
import { _handleBrazeAction as
|
|
3
|
+
import { _handleBrazeAction as G } from "../../Core/handle-braze-action.js";
|
|
4
4
|
import { logCardDismissal } from "../index.js";
|
|
5
|
-
import { Guid as
|
|
5
|
+
import { Guid as K } from "../../../shared-lib/index.js";
|
|
6
6
|
export function markCardAsRead(t) {
|
|
7
7
|
if (null != t) {
|
|
8
8
|
const e = t.querySelectorAll(".ab-unread-indicator")[0];
|
|
@@ -38,7 +38,7 @@ export function cardToHtml(t, logCardClick, e, o = "ltr") {
|
|
|
38
38
|
let i = "",
|
|
39
39
|
n = !1;
|
|
40
40
|
t.url && "" !== t.url && ((i = t.url), (n = !0));
|
|
41
|
-
const d = (o) => (markCardAsRead(a), n && (logCardClick(t),
|
|
41
|
+
const d = (o) => (markCardAsRead(a), n && (logCardClick(t), G(i, e, o)), !1);
|
|
42
42
|
if (t.pinned) {
|
|
43
43
|
const t = document.createElement("div");
|
|
44
44
|
t.className = "ab-pinned-indicator";
|
|
@@ -84,7 +84,7 @@ export function cardToHtml(t, logCardClick, e, o = "ltr") {
|
|
|
84
84
|
const t = document.createElement("h1");
|
|
85
85
|
if (
|
|
86
86
|
((t.className = "ab-title"),
|
|
87
|
-
(t.id =
|
|
87
|
+
(t.id = K.ce()),
|
|
88
88
|
a.setAttribute("aria-labelledby", t.id),
|
|
89
89
|
n)
|
|
90
90
|
) {
|
|
@@ -99,7 +99,7 @@ export function cardToHtml(t, logCardClick, e, o = "ltr") {
|
|
|
99
99
|
const m = document.createElement("div");
|
|
100
100
|
if (
|
|
101
101
|
((m.className = s ? "ab-description" : "ab-description ab-no-title"),
|
|
102
|
-
(m.id =
|
|
102
|
+
(m.id = K.ce()),
|
|
103
103
|
a.setAttribute("aria-describedby", m.id),
|
|
104
104
|
t.description && m.appendChild(document.createTextNode(t.description)),
|
|
105
105
|
n)
|