@braze/web-sdk 5.6.1 → 5.8.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/README.md +1 -1
- package/index.d.ts +15 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +23 -23
- package/shared-lib/indexed-db-adapter.js +20 -20
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +17 -17
- package/src/Banner/banner-provider.js +53 -50
- package/src/Banner/banner.js +1 -1
- package/src/Banner/get-all-banners.js +3 -4
- package/src/Banner/get-banner.js +11 -11
- package/src/Banner/log-banner-click.js +1 -1
- package/src/Banner/log-banner-impressions.js +4 -4
- package/src/Banner/request-banners-refresh.js +21 -13
- package/src/Banner/subscribe-to-banners-updates.js +14 -13
- package/src/Banner/ui/insert-banner.js +11 -9
- package/src/Card/card-manager.js +10 -10
- package/src/Card/log-card-impressions.js +2 -2
- package/src/Card/models/captioned-image.js +1 -1
- package/src/Card/models/card.js +3 -3
- package/src/Card/models/classic-card.js +1 -1
- package/src/Card/models/control-card.js +1 -1
- package/src/Card/models/image-only.js +1 -1
- package/src/ContentCards/content-cards-provider-factory.js +1 -1
- package/src/ContentCards/content-cards-provider.js +139 -180
- package/src/ContentCards/content-cards.js +3 -3
- 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 +10 -10
- package/src/ContentCards/ui/show-content-cards.js +8 -8
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +3 -3
- package/src/Core/disable-sdk.js +7 -7
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/get-user.js +1 -1
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +3 -3
- package/src/Core/log-purchase.js +1 -1
- package/src/Core/open-session.js +9 -9
- package/src/Core/wipe-data.js +5 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +18 -18
- package/src/FeatureFlags/feature-flags-provider.js +81 -78
- package/src/FeatureFlags/get-all-feature-flags.js +6 -7
- package/src/FeatureFlags/get-feature-flag.js +5 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +34 -34
- package/src/Feed/feed.js +2 -2
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +5 -5
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
- package/src/InAppMessage/display/modal-utils.js +6 -6
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +115 -91
- 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 +4 -4
- package/src/InAppMessage/log-in-app-message-impression.js +2 -2
- package/src/InAppMessage/models/control-message.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +5 -5
- package/src/InAppMessage/models/html-message.js +10 -10
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +42 -42
- package/src/InAppMessage/models/modal-message.js +5 -5
- 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 +24 -24
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager-factory.js +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/utils/push-utils.js +12 -12
- package/src/User/user-manager.js +12 -12
- package/src/User/user.js +48 -36
- package/src/common/base-feed.js +3 -3
- package/src/common/constants.js +1 -1
- package/src/common/event-logger.js +4 -4
- package/src/common/feed-display.js +14 -14
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +10 -10
- package/src/managers/braze-instance.js +128 -128
- package/src/managers/device-manager.js +18 -18
- package/src/managers/network-manager.js +184 -147
- package/src/managers/server-config-manager.js +63 -63
- package/src/managers/session-manager.js +27 -27
- package/src/managers/storage-manager-factory.js +10 -10
- package/src/managers/storage-manager.js +146 -146
- package/src/managers/subscription-manager.js +8 -8
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +4 -4
- package/src/models/braze-event.js +8 -8
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +8 -8
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +163 -151
- package/src/triggers/models/custom-event-data.js +5 -5
- package/src/triggers/models/custom-event-property-data.js +6 -6
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +16 -16
- package/src/triggers/models/in-app-message-click-data.js +2 -2
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +37 -37
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +11 -11
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +39 -39
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +6 -6
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/dom-utils.js +6 -6
- package/src/util/html-display-utils.js +1 -0
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +22 -23
- package/src/util/request-header-utils.js +25 -22
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/validation-utils.js +17 -17
- package/src/util/window-utils.js +2 -2
package/README.md
CHANGED
|
@@ -8,5 +8,5 @@ Note: The Braze Web SDK is meant to be used client-side in a web application and
|
|
|
8
8
|
|
|
9
9
|
See the [Public Github Repo](https://github.com/braze-inc/braze-web-sdk#readme) for getting started instructions or [our documentation pages](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/initial_sdk_setup/) for use-case based documentation.
|
|
10
10
|
|
|
11
|
-
(c) Braze, Inc.
|
|
11
|
+
(c) Braze, Inc. 2025 - http://braze.com
|
|
12
12
|
License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v5.
|
|
2
|
+
* Type definitions for @braze/web-sdk v5.8.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
|
-
* (c) Braze, Inc.
|
|
4
|
+
* (c) Braze, Inc. 2025 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -1442,6 +1442,16 @@ export class User {
|
|
|
1442
1442
|
setPushNotificationSubscriptionType(
|
|
1443
1443
|
notificationSubscriptionType: NotificationSubscriptionTypes,
|
|
1444
1444
|
): boolean;
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Sets the LINE user ID for the user.
|
|
1448
|
+
*
|
|
1449
|
+
* @param lineId - Must be a non-empty string no greater than 33 characters in length.
|
|
1450
|
+
* Accepts an explicit null value to null out attribute.
|
|
1451
|
+
*
|
|
1452
|
+
* @returns Whether the update was successfully enqueued.
|
|
1453
|
+
*/
|
|
1454
|
+
setLineId(lineId: string | null): boolean;
|
|
1445
1455
|
}
|
|
1446
1456
|
|
|
1447
1457
|
export class InAppMessageButton {
|
|
@@ -2152,7 +2162,7 @@ export function openSession(): void;
|
|
|
2152
2162
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2153
2163
|
*
|
|
2154
2164
|
* ```
|
|
2155
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2165
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.8/service-worker.js');
|
|
2156
2166
|
* ```
|
|
2157
2167
|
*
|
|
2158
2168
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2465,7 +2475,7 @@ export function getBanner(placementId: string): Banner | null | undefined;
|
|
|
2465
2475
|
* @param banner - The `Banner` to insert onto the page.
|
|
2466
2476
|
* @param parentNode - The HTML element to render the banner into.
|
|
2467
2477
|
*/
|
|
2468
|
-
export function insertBanner(banner: Banner, parentNode: HTMLElement): void;
|
|
2478
|
+
export function insertBanner(banner: Banner | null | undefined, parentNode: HTMLElement): void;
|
|
2469
2479
|
|
|
2470
2480
|
/**
|
|
2471
2481
|
* Logs that the user clicked the given banner. This should generally be called through the Braze JavaScript bridge
|
|
@@ -2620,7 +2630,7 @@ export type InitializationOptions = {
|
|
|
2620
2630
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2621
2631
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2622
2632
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2623
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2633
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.8/service-worker.js');` or by including the content
|
|
2624
2634
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2625
2635
|
*/
|
|
2626
2636
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
const d = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
gc: "pc",
|
|
5
|
+
Ac: "ca",
|
|
6
|
+
zu: "i",
|
|
7
|
+
Du: "ie",
|
|
8
8
|
xt: "cci",
|
|
9
9
|
$t: "ccic",
|
|
10
10
|
lt: "ccc",
|
|
11
11
|
dt: "ccd",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
Il: "ss",
|
|
13
|
+
Dl: "se",
|
|
14
|
+
Ir: "si",
|
|
15
|
+
Mr: "sc",
|
|
16
|
+
Tr: "sbc",
|
|
17
|
+
Mc: "sfe",
|
|
18
|
+
qo: "iec",
|
|
19
|
+
fc: "lr",
|
|
20
|
+
mc: "uae",
|
|
21
21
|
yt: "ci",
|
|
22
22
|
ut: "cc",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
wc: "lcaa",
|
|
24
|
+
bc: "lcar",
|
|
25
|
+
Jn: "inc",
|
|
26
|
+
Mn: "add",
|
|
27
|
+
Yn: "rem",
|
|
28
|
+
Hn: "set",
|
|
29
|
+
Kn: "ncam",
|
|
30
|
+
kc: "sgu",
|
|
31
31
|
yr: "ffi",
|
|
32
32
|
ro: "bi",
|
|
33
|
-
|
|
33
|
+
ds: "bc",
|
|
34
34
|
},
|
|
35
|
-
dr = { Fr: "feed_displayed",
|
|
35
|
+
dr = { Fr: "feed_displayed", Sc: "content_cards_displayed" };
|
|
36
36
|
export { d as EventTypes, dr as InternalEventTypes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class tt {
|
|
2
2
|
constructor(t, e) {
|
|
3
3
|
(this.database = t),
|
|
4
4
|
(this.vd = e),
|
|
@@ -64,11 +64,11 @@ export default class it {
|
|
|
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.Ks) {
|
|
68
68
|
const e = t;
|
|
69
|
-
i.database.
|
|
70
|
-
!n.objectStoreNames.contains(i.database.
|
|
71
|
-
n.createObjectStore(i.database.
|
|
69
|
+
i.database.Ks.hasOwnProperty(t) &&
|
|
70
|
+
!n.objectStoreNames.contains(i.database.Ks[e]) &&
|
|
71
|
+
n.createObjectStore(i.database.Ks[e]);
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
(o.onsuccess = (n) => {
|
|
@@ -180,7 +180,7 @@ export default class it {
|
|
|
180
180
|
});
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
cr(t, e, n) {
|
|
184
184
|
if (!this.isSupported()) return "function" == typeof n && n(), !1;
|
|
185
185
|
const o = this;
|
|
186
186
|
return this.Bd((i) => {
|
|
@@ -249,7 +249,7 @@ export default class it {
|
|
|
249
249
|
};
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
Gs(t, e) {
|
|
253
253
|
if (!this.isSupported()) return !1;
|
|
254
254
|
const n = this;
|
|
255
255
|
return this.Bd((o) => {
|
|
@@ -304,11 +304,11 @@ export default class it {
|
|
|
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.Ks) {
|
|
308
308
|
const n = e;
|
|
309
|
-
this.database.
|
|
310
|
-
this.database.
|
|
311
|
-
t.push(this.database.
|
|
309
|
+
this.database.Ks.hasOwnProperty(e) &&
|
|
310
|
+
this.database.Ks[n] !== this.database.Ks.oe &&
|
|
311
|
+
t.push(this.database.Ks[n]);
|
|
312
312
|
}
|
|
313
313
|
const e = this;
|
|
314
314
|
return this.Bd(function (n) {
|
|
@@ -333,20 +333,20 @@ export default class it {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
tt._s = {
|
|
337
|
+
Xs: {
|
|
338
338
|
Sd: "AppboyServiceWorkerAsyncStorage",
|
|
339
339
|
VERSION: 6,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
Ks: {
|
|
341
|
+
Su: "data",
|
|
342
|
+
jr: "pushClicks",
|
|
343
343
|
cu: "pushSubscribed",
|
|
344
344
|
Cd: "fallbackDevice",
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
Hs: "cardUpdates",
|
|
346
|
+
oe: "optOut",
|
|
347
|
+
kr: "pendingData",
|
|
348
348
|
yh: "sdkAuthenticationSignature",
|
|
349
349
|
},
|
|
350
|
-
|
|
350
|
+
te: 1,
|
|
351
351
|
},
|
|
352
352
|
};
|
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.8.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.8.0)";
|
|
34
34
|
null != N.vd ? N.vd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Wo: "allowCrawlerActivity",
|
|
3
|
+
Vo: "baseUrl",
|
|
4
|
+
Ko: "noCookies",
|
|
5
|
+
Yo: "devicePropertyAllowlist",
|
|
6
6
|
Da: "disablePushTokenMaintenance",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Xo: "enableLogging",
|
|
8
|
+
Zo: "enableSdkAuthentication",
|
|
9
9
|
Ca: "manageServiceWorkerExternally",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
Qo: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
Wh: "sessionTimeoutInSeconds",
|
|
12
|
+
Vh: "appVersion",
|
|
13
|
+
$h: "appVersionNumber",
|
|
14
14
|
_a: "serviceWorkerLocation",
|
|
15
15
|
Ba: "safariWebsitePushId",
|
|
16
16
|
Ea: "localization",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
er: "contentSecurityNonce",
|
|
18
|
+
re: "allowUserSuppliedJavascript",
|
|
19
|
+
To: "inAppMessageZIndex",
|
|
20
|
+
Fo: "openInAppMessagesInNewTab",
|
|
21
21
|
en: "openNewsFeedCardsInNewTab",
|
|
22
22
|
mh: "requireExplicitInAppMessageDismissal",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Yh: "doNotLoadFontAwesome",
|
|
24
|
+
Xh: "deviceId",
|
|
25
25
|
Aa: "serviceWorkerScope",
|
|
26
|
-
|
|
26
|
+
Zh: "sdkFlavor",
|
|
27
27
|
tn: "openCardsInNewTab",
|
|
28
28
|
};
|
|
@@ -68,33 +68,40 @@ export default class e extends s {
|
|
|
68
68
|
let m = !1;
|
|
69
69
|
o.V(
|
|
70
70
|
u,
|
|
71
|
-
(
|
|
72
|
-
|
|
71
|
+
(e = -1) => {
|
|
72
|
+
const n = this.S;
|
|
73
|
+
if (!n) return void r();
|
|
73
74
|
const o = new Date().valueOf();
|
|
74
75
|
h.W(this.C, h.O.K, o),
|
|
75
|
-
-1 !==
|
|
76
|
+
-1 !== e && d.push(["X-Braze-Req-Tokens-Remaining", e.toString()]),
|
|
76
77
|
l.Y({
|
|
77
|
-
url: `${
|
|
78
|
+
url: `${n.Z()}/banners/sync`,
|
|
78
79
|
headers: d,
|
|
79
80
|
data: u,
|
|
80
81
|
ss: (s) => {
|
|
81
|
-
if (!
|
|
82
|
-
|
|
83
|
-
this.U(s),
|
|
84
|
-
(m = !1),
|
|
85
|
-
h.ns(this.C, h.O.K, 1),
|
|
86
|
-
"function" == typeof t && t();
|
|
82
|
+
if (!n.ts(u, s, d)) return (m = !0), void r();
|
|
83
|
+
n.es(), this.U(s), (m = !1), "function" == typeof t && t();
|
|
87
84
|
},
|
|
88
85
|
error: (s) => {
|
|
89
|
-
|
|
86
|
+
n.ns(s, "retrieving banners"), (m = !0), r();
|
|
90
87
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
(null ==
|
|
96
|
-
|
|
88
|
+
rs: (e, r) => {
|
|
89
|
+
let o;
|
|
90
|
+
if (((this.D = s), m)) {
|
|
91
|
+
let s = this.I;
|
|
92
|
+
(null == s || s < 1e3 * this.R) && (s = 1e3 * this.R),
|
|
93
|
+
(o = Math.min(3e5, a(1e3 * this.R, 3 * s)));
|
|
97
94
|
}
|
|
95
|
+
n.os(
|
|
96
|
+
r,
|
|
97
|
+
() => {
|
|
98
|
+
this.$(s, t, i, !1);
|
|
99
|
+
},
|
|
100
|
+
h.O.K,
|
|
101
|
+
(s) => this.hs(s),
|
|
102
|
+
() => this.G(),
|
|
103
|
+
o,
|
|
104
|
+
);
|
|
98
105
|
},
|
|
99
106
|
});
|
|
100
107
|
},
|
|
@@ -102,27 +109,23 @@ export default class e extends s {
|
|
|
102
109
|
i,
|
|
103
110
|
);
|
|
104
111
|
}
|
|
105
|
-
|
|
112
|
+
ls() {
|
|
106
113
|
return this.D;
|
|
107
114
|
}
|
|
108
|
-
|
|
115
|
+
us(s, t) {
|
|
109
116
|
const i = { id: s.id };
|
|
110
117
|
t && (i.bid = t);
|
|
111
|
-
return c.
|
|
118
|
+
return c.cs(d.ds, i).ss;
|
|
112
119
|
}
|
|
113
120
|
G() {
|
|
114
121
|
null != this.q && (clearTimeout(this.q), (this.q = null));
|
|
115
122
|
}
|
|
116
|
-
|
|
117
|
-
this.G(),
|
|
118
|
-
(this.q = window.setTimeout(() => {
|
|
119
|
-
this.$(s, t, i);
|
|
120
|
-
}, e)),
|
|
121
|
-
(this.I = e);
|
|
123
|
+
hs(s) {
|
|
124
|
+
this.G(), (this.q = s);
|
|
122
125
|
}
|
|
123
|
-
|
|
126
|
+
fs() {
|
|
124
127
|
let s = {};
|
|
125
|
-
this.C && (s = this.C.
|
|
128
|
+
this.C && (s = this.C.vs(t.gs.ps));
|
|
126
129
|
const i = {};
|
|
127
130
|
for (const t in s) {
|
|
128
131
|
let e = null;
|
|
@@ -136,63 +139,63 @@ export default class e extends s {
|
|
|
136
139
|
const i = {};
|
|
137
140
|
for (const t in this.banners) {
|
|
138
141
|
const e =
|
|
139
|
-
(null === (s = this.banners[t]) || void 0 === s ? void 0 : s.
|
|
142
|
+
(null === (s = this.banners[t]) || void 0 === s ? void 0 : s.bs()) ||
|
|
140
143
|
null;
|
|
141
144
|
i[t] = e;
|
|
142
145
|
}
|
|
143
|
-
this.C.
|
|
146
|
+
this.C.Bs(t.gs.ps, i), this.js();
|
|
144
147
|
}
|
|
145
|
-
|
|
148
|
+
js() {
|
|
146
149
|
var s, i;
|
|
147
150
|
null === (s = this.C) ||
|
|
148
151
|
void 0 === s ||
|
|
149
|
-
s.
|
|
152
|
+
s.Bs(t.gs.ys, null === (i = this.T) || void 0 === i ? void 0 : i.Ss());
|
|
150
153
|
}
|
|
151
|
-
|
|
154
|
+
ws() {
|
|
152
155
|
var s;
|
|
153
156
|
return (
|
|
154
|
-
(null === (s = this.C) || void 0 === s ? void 0 : s.
|
|
157
|
+
(null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.ys)) || null
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
|
-
|
|
160
|
+
Cs() {
|
|
158
161
|
return this.k;
|
|
159
162
|
}
|
|
160
|
-
|
|
163
|
+
Ts(s) {
|
|
161
164
|
this.k = s;
|
|
162
165
|
}
|
|
163
|
-
|
|
166
|
+
Rs() {
|
|
164
167
|
var s;
|
|
165
168
|
const t = null === (s = this.T) || void 0 === s ? void 0 : s.Ss(),
|
|
166
|
-
i = this.
|
|
169
|
+
i = this.ws();
|
|
167
170
|
return null != i && t === i;
|
|
168
171
|
}
|
|
169
|
-
|
|
172
|
+
Is() {
|
|
170
173
|
var s;
|
|
171
174
|
const t = null === (s = this.T) || void 0 === s ? void 0 : s.Ss(),
|
|
172
|
-
i = this.
|
|
175
|
+
i = this.ws();
|
|
173
176
|
return null == i || t === i;
|
|
174
177
|
}
|
|
175
|
-
|
|
176
|
-
return this.F.
|
|
178
|
+
qs(s) {
|
|
179
|
+
return this.F.Fs(s);
|
|
177
180
|
}
|
|
178
|
-
|
|
181
|
+
Ns() {
|
|
179
182
|
var s;
|
|
180
183
|
return (
|
|
181
|
-
(null === (s = this.C) || void 0 === s ? void 0 : s.
|
|
184
|
+
(null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.ks)) || {}
|
|
182
185
|
);
|
|
183
186
|
}
|
|
184
|
-
|
|
185
|
-
this.C && this.C.
|
|
187
|
+
xs(s) {
|
|
188
|
+
this.C && this.C.Bs(t.gs.ks, s);
|
|
186
189
|
}
|
|
187
190
|
changeUser() {
|
|
188
|
-
this.
|
|
191
|
+
this.zs();
|
|
189
192
|
}
|
|
190
193
|
L() {
|
|
191
|
-
return !!this.B && (!!this.B.
|
|
194
|
+
return !!this.B && (!!this.B.Ds() || (0 !== this.B.Us() && this.zs(), !1));
|
|
192
195
|
}
|
|
193
|
-
|
|
196
|
+
zs() {
|
|
194
197
|
(this.banners = {}),
|
|
195
|
-
this.C && (this.C.
|
|
198
|
+
this.C && (this.C.Es(t.gs.ps), this.C.Es(t.gs.ks)),
|
|
196
199
|
this.F.X({});
|
|
197
200
|
}
|
|
198
201
|
}
|
package/src/Banner/banner.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { logger as N } from "../../shared-lib/index.js";
|
|
2
1
|
import r from "../managers/braze-instance.js";
|
|
3
2
|
import i from "./banner-provider-factory.js";
|
|
4
3
|
import { getBannerIfNotExpired as v } from "./get-banner.js";
|
|
5
4
|
export function getAllBanners() {
|
|
6
5
|
if (!r.rr()) return;
|
|
7
6
|
const n = {},
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
const o = i.m().
|
|
7
|
+
t = r.v();
|
|
8
|
+
if (t && !t.Ds()) return n;
|
|
9
|
+
const o = i.m().fs();
|
|
11
10
|
for (const r in o) n[r] = v(o, r);
|
|
12
11
|
return n;
|
|
13
12
|
}
|
package/src/Banner/get-banner.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { logger as N } from "../../shared-lib/index.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
3
|
import i from "./banner-provider-factory.js";
|
|
4
|
-
export function getBannerIfNotExpired(n,
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
7
|
-
const t =
|
|
8
|
-
|
|
9
|
-
return -1 !== t && 1e3 * t <
|
|
10
|
-
? (N.info(`Banner with ID: ${
|
|
4
|
+
export function getBannerIfNotExpired(n, r) {
|
|
5
|
+
const e = n[r];
|
|
6
|
+
if (!e) return null;
|
|
7
|
+
const t = e.it,
|
|
8
|
+
o = new Date().valueOf();
|
|
9
|
+
return -1 !== t && 1e3 * t < o
|
|
10
|
+
? (N.info(`Banner with ID: ${e.id} and placement ID: ${r} has expired.`),
|
|
11
11
|
null)
|
|
12
|
-
:
|
|
12
|
+
: e;
|
|
13
13
|
}
|
|
14
14
|
export function getBanner(n) {
|
|
15
15
|
if (!r.rr()) return;
|
|
16
|
-
const e =
|
|
17
|
-
if (
|
|
18
|
-
return getBannerIfNotExpired(
|
|
16
|
+
const e = i.m();
|
|
17
|
+
if (!e.L()) return null;
|
|
18
|
+
return getBannerIfNotExpired(e.fs(), n);
|
|
19
19
|
}
|
|
@@ -10,7 +10,7 @@ export function logBannerClick(n, o) {
|
|
|
10
10
|
N.error("Banner argument to logBannerClick must be an Banner object."), !1
|
|
11
11
|
);
|
|
12
12
|
const e = i.m(),
|
|
13
|
-
t = e.
|
|
13
|
+
t = e.fs();
|
|
14
14
|
return 0 === y(t).length
|
|
15
15
|
? (N.info("Not logging banner click. No banners exist."), !1)
|
|
16
16
|
: t[n.placementId]
|
|
@@ -7,10 +7,10 @@ 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
|
-
s = n.
|
|
10
|
+
s = n.fs();
|
|
11
11
|
if (0 === y(s).length)
|
|
12
12
|
return N.info("Not logging banners impression. No banners exist."), !1;
|
|
13
|
-
const e = n.
|
|
13
|
+
const e = n.Ns(),
|
|
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.xs(e);
|
|
29
29
|
const a = { ids: t };
|
|
30
|
-
return c.
|
|
30
|
+
return c.cs(d.ro, a).ss;
|
|
31
31
|
}
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { logger as N } from "../../shared-lib/index.js";
|
|
2
2
|
import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../common/constants.js";
|
|
3
|
-
import r from "../managers/braze-instance.js";
|
|
4
|
-
import { isArray as
|
|
3
|
+
import r, { OPTIONS as w } from "../managers/braze-instance.js";
|
|
4
|
+
import { isArray as z } from "../util/code-utils.js";
|
|
5
5
|
import { isValidBannerPlacementId as D } from "../util/validation-utils.js";
|
|
6
6
|
import i from "./banner-provider-factory.js";
|
|
7
|
-
export function requestBannersRefresh(e, n,
|
|
7
|
+
export function requestBannersRefresh(e, n, t) {
|
|
8
8
|
if (!r.rr()) return void N.warn(p);
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
if (!
|
|
12
|
-
if (!w(e) || 0 === e.length)
|
|
9
|
+
const s = r.v();
|
|
10
|
+
if (!s) return;
|
|
11
|
+
if (!z(e) || 0 === e.length)
|
|
13
12
|
return void N.warn("placementIds should be a non-empty array.");
|
|
14
|
-
if (
|
|
13
|
+
if (!r.ee(w.re))
|
|
14
|
+
return void N.error(
|
|
15
|
+
"Banners are disabled. Use the 'allowUserSuppliedJavascript' option for braze.initialize to enable these messages.",
|
|
16
|
+
);
|
|
17
|
+
const o = i.m();
|
|
18
|
+
if (i.m().Rs())
|
|
15
19
|
return void N.warn(
|
|
16
20
|
"Banners can be refreshed only once per session per user.",
|
|
17
21
|
);
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
if (!s || !o.L())
|
|
23
|
+
return void s.A(() => {
|
|
24
|
+
requestBannersRefresh(e, n, t);
|
|
25
|
+
});
|
|
26
|
+
const a = s.ne();
|
|
27
|
+
e.length > a &&
|
|
20
28
|
(N.warn(
|
|
21
|
-
`Number of placement IDs requested exceeds the max allowed. Trimming placementIds array from length ${e.length} to ${
|
|
29
|
+
`Number of placement IDs requested exceeds the max allowed. Trimming placementIds array from length ${e.length} to ${a} (max allowed).`,
|
|
22
30
|
),
|
|
23
|
-
(e = e.slice(0,
|
|
31
|
+
(e = e.slice(0, a))),
|
|
24
32
|
0 !==
|
|
25
33
|
(e = e.filter(
|
|
26
34
|
(e) =>
|
|
@@ -31,5 +39,5 @@ export function requestBannersRefresh(e, n, o) {
|
|
|
31
39
|
!1),
|
|
32
40
|
)).length &&
|
|
33
41
|
(N.info(`Requesting banners for placement IDs: ${JSON.stringify(e)}`),
|
|
34
|
-
i.m().$(e, n,
|
|
42
|
+
i.m().$(e, n, t));
|
|
35
43
|
}
|
|
@@ -2,22 +2,23 @@ import r from "../managers/braze-instance.js";
|
|
|
2
2
|
import i from "./banner-provider-factory.js";
|
|
3
3
|
import { getAllBanners } from "./get-all-banners.js";
|
|
4
4
|
export function subscribeToBannersUpdates(n) {
|
|
5
|
+
var o;
|
|
5
6
|
if (!r.rr()) return;
|
|
6
|
-
const
|
|
7
|
-
if (
|
|
7
|
+
const t = i.m();
|
|
8
|
+
if (t.Is()) {
|
|
8
9
|
const r = getAllBanners();
|
|
9
10
|
r && "function" == typeof n && n(r);
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
13
|
-
const n =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const s = t.qs(n);
|
|
13
|
+
if (!t.Cs()) {
|
|
14
|
+
const n =
|
|
15
|
+
null === (o = r.nn()) || void 0 === o
|
|
16
|
+
? void 0
|
|
17
|
+
: o.rn(() => {
|
|
18
|
+
const n = t.ls();
|
|
19
|
+
n && n.length > 0 && t.$(n);
|
|
20
|
+
});
|
|
21
|
+
n && t.Ts(n);
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return s;
|
|
23
24
|
}
|