@braze/web-sdk 5.4.0 → 5.6.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 +109 -7
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +33 -31
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +20 -20
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +24 -24
- package/src/Banner/banner-factory.js +14 -0
- package/src/Banner/banner-provider-factory.js +19 -0
- package/src/Banner/banner-provider.js +198 -0
- package/src/Banner/banner.js +30 -0
- package/src/Banner/display/banner-to-html.js +57 -0
- package/src/Banner/display/destroy-banner-html.js +7 -0
- package/src/Banner/display/detect-banner-impressions.js +28 -0
- package/src/Banner/get-all-banners.js +13 -0
- package/src/Banner/get-banner.js +19 -0
- package/src/Banner/index.js +7 -0
- package/src/Banner/log-banner-click.js +22 -0
- package/src/Banner/log-banner-impressions.js +31 -0
- package/src/Banner/request-banners-refresh.js +35 -0
- package/src/Banner/subscribe-to-banners-updates.js +23 -0
- package/src/Banner/types.js +1 -0
- package/src/Banner/ui/insert-banner.js +24 -0
- package/src/Card/card-manager-factory.js +10 -10
- package/src/Card/card-manager.js +64 -58
- package/src/Card/display/card-display.js +77 -91
- package/src/Card/log-card-click.js +6 -6
- package/src/Card/log-card-dismissal.js +6 -5
- package/src/Card/log-card-impressions.js +11 -11
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +111 -105
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +19 -19
- package/src/Card/util/card-factory.js +58 -58
- package/src/ContentCards/content-cards-provider-factory.js +14 -14
- package/src/ContentCards/content-cards-provider.js +260 -262
- package/src/ContentCards/content-cards.js +5 -5
- package/src/ContentCards/get-cached-content-cards.js +3 -3
- package/src/ContentCards/request-content-cards-refresh.js +4 -4
- package/src/ContentCards/subscribe-to-content-cards-updates.js +13 -13
- package/src/ContentCards/ui/hide-content-cards.js +7 -7
- package/src/ContentCards/ui/show-content-cards.js +52 -52
- package/src/ContentCards/ui/toggle-content-cards.js +4 -4
- package/src/Core/add-sdk-metadata.js +9 -9
- package/src/Core/change-user.js +14 -14
- package/src/Core/destroy.js +3 -3
- package/src/Core/disable-sdk.js +13 -13
- package/src/Core/enable-sdk.js +9 -9
- package/src/Core/get-device-id.js +10 -10
- package/src/Core/get-user.js +2 -2
- package/src/Core/handle-braze-action.js +53 -53
- package/src/Core/initialize.js +2 -2
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +2 -2
- package/src/Core/log-custom-event.js +24 -24
- package/src/Core/log-purchase.js +38 -38
- package/src/Core/open-session.js +18 -18
- package/src/Core/remove-all-subscriptions.js +2 -2
- package/src/Core/remove-subscription.js +3 -3
- package/src/Core/request-immediate-data-flush.js +5 -5
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +6 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +5 -5
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +10 -10
- package/src/FeatureFlags/feature-flag-factory.js +13 -13
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +13 -14
- package/src/FeatureFlags/feature-flags-provider.js +118 -116
- package/src/FeatureFlags/get-all-feature-flags.js +10 -10
- package/src/FeatureFlags/get-feature-flag.js +9 -9
- package/src/FeatureFlags/log-feature-flag-impression.js +18 -18
- package/src/FeatureFlags/refresh-feature-flags.js +6 -6
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -9
- package/src/Feed/feed-provider-factory.js +12 -12
- package/src/Feed/feed-provider.js +59 -59
- package/src/Feed/feed.js +4 -4
- package/src/Feed/get-cached-feed.js +3 -3
- package/src/Feed/log-feed-displayed.js +5 -5
- package/src/Feed/request-feed-refresh.js +3 -3
- package/src/Feed/subscribe-to-feed-updates.js +4 -4
- package/src/Feed/ui/hide-feed.js +5 -5
- package/src/Feed/ui/show-feed.js +53 -53
- package/src/Feed/ui/toggle-feed.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +9 -9
- package/src/InAppMessage/display/html-message-display-utils.js +18 -164
- package/src/InAppMessage/display/html-message-to-html.js +55 -62
- package/src/InAppMessage/display/in-app-message-to-html.js +74 -74
- package/src/InAppMessage/display/modal-utils.js +17 -17
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +61 -61
- package/src/InAppMessage/in-app-message-manager-factory.js +9 -9
- package/src/InAppMessage/in-app-message-manager.js +158 -156
- package/src/InAppMessage/log-in-app-message-button-click.js +16 -16
- package/src/InAppMessage/log-in-app-message-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-html-click.js +15 -15
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/control-message.js +15 -8
- package/src/InAppMessage/models/full-screen-message.js +34 -34
- package/src/InAppMessage/models/html-message.js +23 -23
- package/src/InAppMessage/models/in-app-message-button.js +10 -10
- package/src/InAppMessage/models/in-app-message.js +155 -155
- package/src/InAppMessage/models/modal-message.js +33 -33
- package/src/InAppMessage/models/slide-up-message.js +35 -35
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +3 -3
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +6 -6
- package/src/InAppMessage/ui/show-in-app-message.js +103 -103
- 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 +25 -25
- package/src/Push/push-manager.js +176 -176
- package/src/Push/request-push-permission.js +8 -8
- package/src/Push/unregister-push.js +4 -4
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +38 -38
- package/src/User/user.js +95 -92
- package/src/common/base-feed.js +9 -9
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +1 -0
- package/src/common/detect-impression.js +18 -0
- package/src/common/event-logger.js +22 -22
- package/src/common/feed-display.js +53 -53
- package/src/index.js +1 -0
- package/src/l10n/l10n-manager-factory.js +15 -15
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +38 -38
- package/src/managers/braze-instance.js +212 -212
- package/src/managers/device-manager.js +30 -30
- package/src/managers/network-manager.js +231 -232
- package/src/managers/server-config-manager.js +99 -83
- package/src/managers/session-manager.js +46 -50
- package/src/managers/storage-manager-factory.js +13 -13
- package/src/managers/storage-manager.js +182 -180
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +4 -4
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +15 -15
- package/src/models/push-token.js +10 -10
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +38 -34
- package/src/request-controller.js +228 -228
- 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 +10 -10
- package/src/triggers/models/filter.js +66 -66
- package/src/triggers/models/in-app-message-click-data.js +10 -10
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +6 -6
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +46 -46
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +33 -33
- package/src/triggers/triggers-provider-factory.js +16 -16
- package/src/triggers/triggers-provider.js +156 -154
- package/src/ui/js/attach-css.js +7 -7
- package/src/ui/js/banner-css.js +11 -0
- package/src/ui/js/feed-css.js +4 -4
- package/src/ui/js/iam-css.js +4 -4
- package/src/ui/js/index.js +1 -0
- package/src/ui/js/load-font-awesome.js +8 -8
- package/src/util/base-device-parser.js +9 -9
- package/src/util/braze-actions.js +32 -32
- package/src/util/browser-detector.js +27 -27
- package/src/util/client-hints-parser.js +9 -9
- package/src/util/code-utils.js +5 -5
- package/src/util/component-utils.js +5 -5
- package/src/util/deprecation-utils.js +3 -3
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +13 -13
- package/src/util/html-display-utils.js +158 -0
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +21 -21
- package/src/util/request-header-utils.js +31 -30
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +9 -9
- package/src/util/validation-utils.js +89 -85
- package/src/util/window-utils.js +3 -3
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.6.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2024 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -1648,6 +1648,20 @@ export class FeatureFlag {
|
|
|
1648
1648
|
getTimestampProperty(key: string): number | null;
|
|
1649
1649
|
}
|
|
1650
1650
|
|
|
1651
|
+
export class Banner {
|
|
1652
|
+
/** Analytics / tracking string. */
|
|
1653
|
+
id: string;
|
|
1654
|
+
|
|
1655
|
+
/** The placement ID this banner is matched to. */
|
|
1656
|
+
placementId: string;
|
|
1657
|
+
|
|
1658
|
+
/** HTML to display for the banner. */
|
|
1659
|
+
html: string;
|
|
1660
|
+
|
|
1661
|
+
/** Whether this banner is a control banner. */
|
|
1662
|
+
isControl: boolean;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1651
1665
|
/**
|
|
1652
1666
|
* Automatically display in-app messages when they are triggered. This method should be called before
|
|
1653
1667
|
* calling `openSession`.
|
|
@@ -2138,7 +2152,7 @@ export function openSession(): void;
|
|
|
2138
2152
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2139
2153
|
*
|
|
2140
2154
|
* ```
|
|
2141
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2155
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.6/service-worker.js');
|
|
2142
2156
|
* ```
|
|
2143
2157
|
*
|
|
2144
2158
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2418,6 +2432,95 @@ export function logFeatureFlagImpression(
|
|
|
2418
2432
|
featureFlagId: string,
|
|
2419
2433
|
): boolean | undefined;
|
|
2420
2434
|
|
|
2435
|
+
/**
|
|
2436
|
+
* Requests banners by a list of placement IDs from the Braze backend.
|
|
2437
|
+
* Note that this method can only be called once per session.
|
|
2438
|
+
*
|
|
2439
|
+
* @param placementIds - A list of placement IDs for banners.
|
|
2440
|
+
* @param successCallback - Callback that is invoked when the banners refresh request has been successfully completed.
|
|
2441
|
+
* This callback is useful for determining when a request has completed regardless of whether new banners were returned.
|
|
2442
|
+
* @param errorCallback - Callback that is invoked when an error occurs during the refresh.
|
|
2443
|
+
*/
|
|
2444
|
+
export function requestBannersRefresh(
|
|
2445
|
+
placementIds: string[],
|
|
2446
|
+
successCallback?: () => void,
|
|
2447
|
+
errorCallback?: () => void,
|
|
2448
|
+
): void;
|
|
2449
|
+
|
|
2450
|
+
/**
|
|
2451
|
+
* Gets a Banner by its placement ID.
|
|
2452
|
+
*
|
|
2453
|
+
* @param placementId - The placement ID of the banner.
|
|
2454
|
+
* @returns - An object of type `Banner`, if a banner with the given placement ID exists. The method returns null if
|
|
2455
|
+
* the banner does not exist, or if banners are disabled. Returns undefined if the SDK has not been initialized.
|
|
2456
|
+
*/
|
|
2457
|
+
export function getBanner(placementId: string): Banner | null | undefined;
|
|
2458
|
+
|
|
2459
|
+
/**
|
|
2460
|
+
* Renders a Banner into the provided parent node by replacing all children of the parent node. The Banner will be styled
|
|
2461
|
+
* to use the entire width and height of the parent node. If the `allowUserSuppliedJavascript` initialization option is
|
|
2462
|
+
* not set to `true`, this method will no-op. Once the Banner is inserted into the DOM, it will automatically log impressions
|
|
2463
|
+
* and listen for updates from the Braze backend.
|
|
2464
|
+
*
|
|
2465
|
+
* @param banner - The `Banner` to insert onto the page.
|
|
2466
|
+
* @param parentNode - The HTML element to render the banner into.
|
|
2467
|
+
*/
|
|
2468
|
+
export function insertBanner(banner: Banner, parentNode: HTMLElement): void;
|
|
2469
|
+
|
|
2470
|
+
/**
|
|
2471
|
+
* Logs that the user clicked the given banner. This should generally be called through the Braze JavaScript bridge
|
|
2472
|
+
* inside the Banner's HTML as defined in the Braze dashboard.
|
|
2473
|
+
*
|
|
2474
|
+
* @param banner - The `Banner` object which received the click.
|
|
2475
|
+
* @param buttonId - An optional button ID to associate with this click for analytics.
|
|
2476
|
+
*
|
|
2477
|
+
* @returns - Whether the click was logged successfully, or undefined if the SDK is not intialized.
|
|
2478
|
+
*/
|
|
2479
|
+
export function logBannerClick(
|
|
2480
|
+
banner: Banner,
|
|
2481
|
+
buttonId?: string,
|
|
2482
|
+
): boolean | undefined;
|
|
2483
|
+
|
|
2484
|
+
/**
|
|
2485
|
+
* Logs that the user saw the given banners. This is done automatically when you use Braze's display module
|
|
2486
|
+
* and should only be called if you're bypassing that and manually building the DOM for displaying the banners in
|
|
2487
|
+
* your own code.
|
|
2488
|
+
*
|
|
2489
|
+
* @param placementIds - The placement IDs of the banners that received impressions.
|
|
2490
|
+
*
|
|
2491
|
+
* @returns - Whether the impressions were logged successfully, or undefiend if the SDK is not initialized.
|
|
2492
|
+
*/
|
|
2493
|
+
export function logBannerImpressions(
|
|
2494
|
+
placementIds: Array<string>,
|
|
2495
|
+
): boolean | undefined;
|
|
2496
|
+
|
|
2497
|
+
/**
|
|
2498
|
+
* Gets all available banners.
|
|
2499
|
+
*
|
|
2500
|
+
* @returns - A map of placement IDs to `Banner` objects.
|
|
2501
|
+
* If the banner has expired, the placement ID will map to a null value instead.
|
|
2502
|
+
* Returns undefined if the SDK has not been initialized.
|
|
2503
|
+
*/
|
|
2504
|
+
export function getAllBanners(): Record<string, Banner | null> | undefined;
|
|
2505
|
+
|
|
2506
|
+
/**
|
|
2507
|
+
* Subscribe to banners updates. The subscriber callback will be called whenever banners are updated. This method
|
|
2508
|
+
* should be called before calling `openSession`.
|
|
2509
|
+
*
|
|
2510
|
+
* @param subscriber - The callback function to handle new banners. This function is always called first with the
|
|
2511
|
+
* available cached map of placement IDs to `Banner` objects, and will also be called when banner updates are available.
|
|
2512
|
+
* If you want to be notified when a refresh has completed regardless of whether new banners are available,
|
|
2513
|
+
* you should use the `successCallback` of `requestBannersRefresh`.
|
|
2514
|
+
*
|
|
2515
|
+
* @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel the subscription.
|
|
2516
|
+
* Returns undefined if the SDK has not been initialized.
|
|
2517
|
+
*/
|
|
2518
|
+
export function subscribeToBannersUpdates(
|
|
2519
|
+
subscriber: (banners: Record<string, Banner | null>) => void,
|
|
2520
|
+
): string | undefined;
|
|
2521
|
+
|
|
2522
|
+
|
|
2523
|
+
|
|
2421
2524
|
/**
|
|
2422
2525
|
* Getter method to determine if the Braze SDK has been initialized.
|
|
2423
2526
|
*/
|
|
@@ -2435,10 +2538,9 @@ export type InitializationOptions = {
|
|
|
2435
2538
|
*/
|
|
2436
2539
|
allowCrawlerActivity?: boolean;
|
|
2437
2540
|
/**
|
|
2438
|
-
* By default, the Braze Web SDK does not allow user-supplied Javascript click actions or enable HTML in-app messages
|
|
2439
|
-
*
|
|
2440
|
-
*
|
|
2441
|
-
* Javascript click actions, set this property to true.
|
|
2541
|
+
* By default, the Braze Web SDK does not allow user-supplied Javascript click actions, or enable HTML in-app messages
|
|
2542
|
+
* and Banners, as they allow Braze dashboard users to run Javascript on your site. To indicate that you trust the
|
|
2543
|
+
* Braze dashboard users to write non-malicious Javascript click actions, set this property to true.
|
|
2442
2544
|
*/
|
|
2443
2545
|
allowUserSuppliedJavascript?: boolean;
|
|
2444
2546
|
/**
|
|
@@ -2518,7 +2620,7 @@ export type InitializationOptions = {
|
|
|
2518
2620
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2519
2621
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2520
2622
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2521
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2623
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.6/service-worker.js');` or by including the content
|
|
2522
2624
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2523
2625
|
*/
|
|
2524
2626
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
const
|
|
1
|
+
const d = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
mc: "pc",
|
|
5
|
+
Cc: "ca",
|
|
6
|
+
Mu: "i",
|
|
7
|
+
Li: "ie",
|
|
8
|
+
xt: "cci",
|
|
9
|
+
$t: "ccic",
|
|
10
|
+
lt: "ccc",
|
|
11
|
+
dt: "ccd",
|
|
12
|
+
Jl: "ss",
|
|
13
|
+
Gl: "se",
|
|
14
|
+
Nr: "si",
|
|
15
|
+
Cr: "sc",
|
|
16
|
+
Or: "sbc",
|
|
17
|
+
yc: "sfe",
|
|
18
|
+
zo: "iec",
|
|
19
|
+
dc: "lr",
|
|
20
|
+
cc: "uae",
|
|
21
|
+
yt: "ci",
|
|
22
|
+
ut: "cc",
|
|
23
|
+
vc: "lcaa",
|
|
24
|
+
gc: "lcar",
|
|
25
|
+
fu: "inc",
|
|
26
|
+
pu: "add",
|
|
27
|
+
bu: "rem",
|
|
28
|
+
au: "set",
|
|
29
|
+
du: "ncam",
|
|
30
|
+
bc: "sgu",
|
|
31
|
+
yr: "ffi",
|
|
32
|
+
ro: "bi",
|
|
33
|
+
fs: "bc",
|
|
32
34
|
},
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
+
dr = { Fr: "feed_displayed", Mc: "content_cards_displayed" };
|
|
36
|
+
export { d as EventTypes, dr as InternalEventTypes };
|
package/shared-lib/guid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const G = {
|
|
2
|
+
Rt: function () {
|
|
3
3
|
const t = (t = !1) => {
|
|
4
4
|
const n = (Math.random().toString(16) + "000000000").substr(2, 8);
|
|
5
5
|
return t ? "-" + n.substr(0, 4) + "-" + n.substr(4, 4) : n;
|
|
@@ -7,4 +7,4 @@ const p = {
|
|
|
7
7
|
return t() + t(!0) + t(!0) + t();
|
|
8
8
|
},
|
|
9
9
|
};
|
|
10
|
-
export default
|
|
10
|
+
export default G;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class it {
|
|
2
2
|
constructor(t, e) {
|
|
3
3
|
(this.database = t),
|
|
4
4
|
(this.vd = e),
|
|
@@ -64,11 +64,11 @@ export default class A {
|
|
|
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.Os) {
|
|
68
68
|
const e = t;
|
|
69
|
-
i.database.
|
|
70
|
-
!n.objectStoreNames.contains(i.database.
|
|
71
|
-
n.createObjectStore(i.database.
|
|
69
|
+
i.database.Os.hasOwnProperty(t) &&
|
|
70
|
+
!n.objectStoreNames.contains(i.database.Os[e]) &&
|
|
71
|
+
n.createObjectStore(i.database.Os[e]);
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
(o.onsuccess = (n) => {
|
|
@@ -216,7 +216,7 @@ export default class A {
|
|
|
216
216
|
});
|
|
217
217
|
}, n);
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
me(t, e) {
|
|
220
220
|
if (!this.isSupported()) return !1;
|
|
221
221
|
const n = this;
|
|
222
222
|
return this.Bd((o) => {
|
|
@@ -249,7 +249,7 @@ export default class A {
|
|
|
249
249
|
};
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
Hs(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 A {
|
|
|
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.Os) {
|
|
308
308
|
const n = e;
|
|
309
|
-
this.database.
|
|
310
|
-
this.database.
|
|
311
|
-
t.push(this.database.
|
|
309
|
+
this.database.Os.hasOwnProperty(e) &&
|
|
310
|
+
this.database.Os[n] !== this.database.Os.ie &&
|
|
311
|
+
t.push(this.database.Os[n]);
|
|
312
312
|
}
|
|
313
313
|
const e = this;
|
|
314
314
|
return this.Bd(function (n) {
|
|
@@ -333,20 +333,20 @@ export default class A {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
it.Gs = {
|
|
337
|
+
_s: {
|
|
338
338
|
Sd: "AppboyServiceWorkerAsyncStorage",
|
|
339
339
|
VERSION: 6,
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
Os: {
|
|
341
|
+
Xu: "data",
|
|
342
342
|
hr: "pushClicks",
|
|
343
343
|
cu: "pushSubscribed",
|
|
344
344
|
Cd: "fallbackDevice",
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
345
|
+
Ks: "cardUpdates",
|
|
346
|
+
ie: "optOut",
|
|
347
|
+
$r: "pendingData",
|
|
348
|
+
yh: "sdkAuthenticationSignature",
|
|
349
349
|
},
|
|
350
|
-
|
|
350
|
+
oe: 1,
|
|
351
351
|
},
|
|
352
352
|
};
|
package/shared-lib/logger.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const
|
|
1
|
+
const N = {
|
|
2
2
|
init: function (n) {
|
|
3
|
-
(void 0 === n && void 0 !==
|
|
3
|
+
(void 0 === n && void 0 !== N.zg) || (N.zg = !!n), N.l || (N.l = !0);
|
|
4
4
|
},
|
|
5
5
|
destroy: function () {
|
|
6
|
-
(
|
|
6
|
+
(N.l = !1), (N.zg = void 0), (N.vd = void 0);
|
|
7
7
|
},
|
|
8
8
|
setLogger: function (n) {
|
|
9
9
|
"function" == typeof n
|
|
10
|
-
? (
|
|
11
|
-
:
|
|
10
|
+
? (N.init(), (N.vd = n))
|
|
11
|
+
: N.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
|
+
N.init(),
|
|
15
|
+
N.zg
|
|
16
|
+
? (console.log("Disabling Braze logging"), (N.zg = !1))
|
|
17
|
+
: (console.log("Enabled Braze logging"), (N.zg = !0));
|
|
18
18
|
},
|
|
19
19
|
info: function (n) {
|
|
20
|
-
if (
|
|
20
|
+
if (N.zg) {
|
|
21
21
|
const o = "Braze: " + n;
|
|
22
|
-
null !=
|
|
22
|
+
null != N.vd ? N.vd(o) : console.log(o);
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
|
-
if (
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v5.
|
|
28
|
-
null !=
|
|
26
|
+
if (N.zg) {
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v5.6.0)";
|
|
28
|
+
null != N.vd ? N.vd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
|
-
if (
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v5.
|
|
34
|
-
null !=
|
|
32
|
+
if (N.zg) {
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v5.6.0)";
|
|
34
|
+
null != N.vd ? N.vd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
|
-
export default
|
|
38
|
+
export default N;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
Oo: "allowCrawlerActivity",
|
|
3
|
+
Ro: "baseUrl",
|
|
4
|
+
Lo: "noCookies",
|
|
5
|
+
Wo: "devicePropertyAllowlist",
|
|
6
|
+
Da: "disablePushTokenMaintenance",
|
|
7
|
+
Vo: "enableLogging",
|
|
8
|
+
Ko: "enableSdkAuthentication",
|
|
9
|
+
Ca: "manageServiceWorkerExternally",
|
|
10
|
+
Go: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
Yo: "sessionTimeoutInSeconds",
|
|
12
|
+
Ho: "appVersion",
|
|
13
|
+
Xo: "appVersionNumber",
|
|
14
|
+
_a: "serviceWorkerLocation",
|
|
15
|
+
Ba: "safariWebsitePushId",
|
|
16
|
+
Ea: "localization",
|
|
17
|
+
ir: "contentSecurityNonce",
|
|
18
|
+
er: "allowUserSuppliedJavascript",
|
|
19
|
+
Jo: "inAppMessageZIndex",
|
|
20
|
+
Do: "openInAppMessagesInNewTab",
|
|
21
21
|
en: "openNewsFeedCardsInNewTab",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
mh: "requireExplicitInAppMessageDismissal",
|
|
23
|
+
Zo: "doNotLoadFontAwesome",
|
|
24
|
+
Qo: "deviceId",
|
|
25
|
+
Aa: "serviceWorkerScope",
|
|
26
|
+
Wh: "sdkFlavor",
|
|
27
27
|
tn: "openCardsInNewTab",
|
|
28
28
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Banner from "./banner.js";
|
|
2
|
+
export function newBannerFromSerializedValue(n) {
|
|
3
|
+
return new Banner(n.id, n.o, n.html, n.t, n.i, n.u);
|
|
4
|
+
}
|
|
5
|
+
export function newBannerFromJson(n) {
|
|
6
|
+
return new Banner(
|
|
7
|
+
n.id,
|
|
8
|
+
n.placement_id,
|
|
9
|
+
n.html,
|
|
10
|
+
n.is_test_send,
|
|
11
|
+
n.is_control,
|
|
12
|
+
n.expires_at,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import e from "./banner-provider.js";
|
|
3
|
+
const i = {
|
|
4
|
+
l: !1,
|
|
5
|
+
provider: null,
|
|
6
|
+
m: () => (
|
|
7
|
+
i.p(),
|
|
8
|
+
i.provider ||
|
|
9
|
+
((i.provider = new e(r.v(), r.g(), r.j(), r.P())), r._(i.provider)),
|
|
10
|
+
i.provider
|
|
11
|
+
),
|
|
12
|
+
p: () => {
|
|
13
|
+
i.l || (r.h(i), (i.l = !0));
|
|
14
|
+
},
|
|
15
|
+
destroy: () => {
|
|
16
|
+
(i.provider = null), (i.l = !1);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export default i;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import s from "../common/base-provider.js";
|
|
2
|
+
import { STORAGE_KEYS as t } from "../managers/storage-manager.js";
|
|
3
|
+
import {
|
|
4
|
+
newBannerFromJson as n,
|
|
5
|
+
newBannerFromSerializedValue as o,
|
|
6
|
+
} from "./banner-factory.js";
|
|
7
|
+
import h from "../util/request-header-utils.js";
|
|
8
|
+
import l from "../util/net.js";
|
|
9
|
+
import { randomInclusive as a } from "../util/math.js";
|
|
10
|
+
import u from "../managers/subscription-manager.js";
|
|
11
|
+
import r from "../managers/braze-instance.js";
|
|
12
|
+
import c from "../common/event-logger.js";
|
|
13
|
+
import { EventTypes as d } from "../../shared-lib/event-types.js";
|
|
14
|
+
export default class e extends s {
|
|
15
|
+
constructor(s, t, i, e) {
|
|
16
|
+
super(),
|
|
17
|
+
(this.B = s),
|
|
18
|
+
(this.S = t),
|
|
19
|
+
(this.C = i),
|
|
20
|
+
(this.T = e),
|
|
21
|
+
(this.banners = {}),
|
|
22
|
+
(this.B = s),
|
|
23
|
+
(this.S = t),
|
|
24
|
+
(this.C = i),
|
|
25
|
+
(this.T = e),
|
|
26
|
+
(this.R = 10),
|
|
27
|
+
(this.I = null),
|
|
28
|
+
(this.q = null),
|
|
29
|
+
(this.F = new u()),
|
|
30
|
+
r.N(this.F),
|
|
31
|
+
(this.k = null),
|
|
32
|
+
(this.D = null);
|
|
33
|
+
}
|
|
34
|
+
U(s) {
|
|
35
|
+
if (this.L() && null != s && s.banners) {
|
|
36
|
+
this.banners = {};
|
|
37
|
+
const t = s.banners;
|
|
38
|
+
for (const s in t) {
|
|
39
|
+
const i = t[s];
|
|
40
|
+
let e = null;
|
|
41
|
+
null != i && null != i.banner && (e = n(i.banner)),
|
|
42
|
+
e && (this.banners[s] = e);
|
|
43
|
+
}
|
|
44
|
+
this.M(), this.F.X(this.banners);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
$(s, t, i, e = !0) {
|
|
48
|
+
var n;
|
|
49
|
+
const r = () => {
|
|
50
|
+
"function" == typeof i && i();
|
|
51
|
+
};
|
|
52
|
+
if (!this.L())
|
|
53
|
+
return void (
|
|
54
|
+
null === (n = this.B) ||
|
|
55
|
+
void 0 === n ||
|
|
56
|
+
n.A(() => {
|
|
57
|
+
this.$(s, t, i);
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
const o = this.S;
|
|
61
|
+
if (!o) return void r();
|
|
62
|
+
e && this.G();
|
|
63
|
+
const u = o.H({}, !0),
|
|
64
|
+
c = [];
|
|
65
|
+
for (const t of s) c.push({ id: t });
|
|
66
|
+
u.placements = c;
|
|
67
|
+
const d = o.J(u, h.O.K);
|
|
68
|
+
let m = !1;
|
|
69
|
+
o.V(
|
|
70
|
+
u,
|
|
71
|
+
(n = -1) => {
|
|
72
|
+
if (!this.S) return void r();
|
|
73
|
+
const o = new Date().valueOf();
|
|
74
|
+
h.W(this.C, h.O.K, o),
|
|
75
|
+
-1 !== n && d.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
|
|
76
|
+
l.Y({
|
|
77
|
+
url: `${this.S.Z()}/banners/sync`,
|
|
78
|
+
headers: d,
|
|
79
|
+
data: u,
|
|
80
|
+
ss: (s) => {
|
|
81
|
+
if (!this.S.ts(u, s, d)) return (m = !0), void r();
|
|
82
|
+
this.S.es(),
|
|
83
|
+
this.U(s),
|
|
84
|
+
(m = !1),
|
|
85
|
+
h.ns(this.C, h.O.K, 1),
|
|
86
|
+
"function" == typeof t && t();
|
|
87
|
+
},
|
|
88
|
+
error: (s) => {
|
|
89
|
+
this.S.rs(s, "retrieving banners"), (m = !0), r();
|
|
90
|
+
},
|
|
91
|
+
os: () => {
|
|
92
|
+
if (((this.D = s), e && m && !this.q)) {
|
|
93
|
+
h.hs(this.C, h.O.K);
|
|
94
|
+
let e = this.I;
|
|
95
|
+
(null == e || e < 1e3 * this.R) && (e = 1e3 * this.R),
|
|
96
|
+
this.ls(s, t, i, Math.min(3e5, a(1e3 * this.R, 3 * e)));
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
h.O.K,
|
|
102
|
+
i,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
us() {
|
|
106
|
+
return this.D;
|
|
107
|
+
}
|
|
108
|
+
cs(s, t) {
|
|
109
|
+
const i = { id: s.id };
|
|
110
|
+
t && (i.bid = t);
|
|
111
|
+
return c.ds(d.fs, i).ss;
|
|
112
|
+
}
|
|
113
|
+
G() {
|
|
114
|
+
null != this.q && (clearTimeout(this.q), (this.q = null));
|
|
115
|
+
}
|
|
116
|
+
ls(s, t, i, e = 1e3 * this.R) {
|
|
117
|
+
this.G(),
|
|
118
|
+
(this.q = window.setTimeout(() => {
|
|
119
|
+
this.$(s, t, i);
|
|
120
|
+
}, e)),
|
|
121
|
+
(this.I = e);
|
|
122
|
+
}
|
|
123
|
+
vs() {
|
|
124
|
+
let s = {};
|
|
125
|
+
this.C && (s = this.C.ps(t.bs.gs));
|
|
126
|
+
const i = {};
|
|
127
|
+
for (const t in s) {
|
|
128
|
+
let e = null;
|
|
129
|
+
null != s[t] && (e = o(s[t])), e && (i[e.placementId] = e);
|
|
130
|
+
}
|
|
131
|
+
return i;
|
|
132
|
+
}
|
|
133
|
+
M() {
|
|
134
|
+
var s;
|
|
135
|
+
if (!this.C) return;
|
|
136
|
+
const i = {};
|
|
137
|
+
for (const t in this.banners) {
|
|
138
|
+
const e =
|
|
139
|
+
(null === (s = this.banners[t]) || void 0 === s ? void 0 : s.Bs()) ||
|
|
140
|
+
null;
|
|
141
|
+
i[t] = e;
|
|
142
|
+
}
|
|
143
|
+
this.C.js(t.bs.gs, i), this.ws();
|
|
144
|
+
}
|
|
145
|
+
ws() {
|
|
146
|
+
var s, i;
|
|
147
|
+
null === (s = this.C) ||
|
|
148
|
+
void 0 === s ||
|
|
149
|
+
s.js(t.bs.ys, null === (i = this.T) || void 0 === i ? void 0 : i.Ss());
|
|
150
|
+
}
|
|
151
|
+
Cs() {
|
|
152
|
+
var s;
|
|
153
|
+
return (
|
|
154
|
+
(null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.ys)) || null
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
Ts() {
|
|
158
|
+
return this.k;
|
|
159
|
+
}
|
|
160
|
+
Rs(s) {
|
|
161
|
+
this.k = s;
|
|
162
|
+
}
|
|
163
|
+
Is() {
|
|
164
|
+
var s;
|
|
165
|
+
const t = null === (s = this.T) || void 0 === s ? void 0 : s.Ss(),
|
|
166
|
+
i = this.Cs();
|
|
167
|
+
return null != i && t === i;
|
|
168
|
+
}
|
|
169
|
+
qs() {
|
|
170
|
+
var s;
|
|
171
|
+
const t = null === (s = this.T) || void 0 === s ? void 0 : s.Ss(),
|
|
172
|
+
i = this.Cs();
|
|
173
|
+
return null == i || t === i;
|
|
174
|
+
}
|
|
175
|
+
Fs(s) {
|
|
176
|
+
return this.F.Ns(s);
|
|
177
|
+
}
|
|
178
|
+
ks() {
|
|
179
|
+
var s;
|
|
180
|
+
return (
|
|
181
|
+
(null === (s = this.C) || void 0 === s ? void 0 : s.ps(t.bs.xs)) || {}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
zs(s) {
|
|
185
|
+
this.C && this.C.js(t.bs.xs, s);
|
|
186
|
+
}
|
|
187
|
+
changeUser() {
|
|
188
|
+
this.Ds();
|
|
189
|
+
}
|
|
190
|
+
L() {
|
|
191
|
+
return !!this.B && (!!this.B.Us() || (0 !== this.B.Es() && this.Ds(), !1));
|
|
192
|
+
}
|
|
193
|
+
Ds() {
|
|
194
|
+
(this.banners = {}),
|
|
195
|
+
this.C && (this.C.Ls(t.bs.gs), this.C.Ls(t.bs.xs)),
|
|
196
|
+
this.F.X({});
|
|
197
|
+
}
|
|
198
|
+
}
|