@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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v6.
|
|
2
|
+
* Type definitions for @braze/web-sdk v6.10.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2026 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -1626,10 +1626,6 @@ export interface EcommerceProductProperties {
|
|
|
1626
1626
|
* and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
|
|
1627
1627
|
*/
|
|
1628
1628
|
metadata?: {
|
|
1629
|
-
/**
|
|
1630
|
-
* Shopify SKU, only applicable to Shopify integrations. Cannot exceed 255 characters in length.
|
|
1631
|
-
*/
|
|
1632
|
-
sku?: string;
|
|
1633
1629
|
[key: string]: any;
|
|
1634
1630
|
};
|
|
1635
1631
|
}
|
|
@@ -1675,6 +1671,21 @@ export interface CheckoutStartedEventProperties
|
|
|
1675
1671
|
*/
|
|
1676
1672
|
total_value: number;
|
|
1677
1673
|
|
|
1674
|
+
/**
|
|
1675
|
+
* Subtotal value of the cart (post-discount, pre-tax/shipping).
|
|
1676
|
+
*/
|
|
1677
|
+
subtotal_value?: number;
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* Total tax applied to the cart.
|
|
1681
|
+
*/
|
|
1682
|
+
tax?: number;
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Total shipping cost for the cart.
|
|
1686
|
+
*/
|
|
1687
|
+
shipping?: number;
|
|
1688
|
+
|
|
1678
1689
|
/**
|
|
1679
1690
|
* The products associated with the checkout.
|
|
1680
1691
|
*/
|
|
@@ -1698,6 +1709,21 @@ type CartUpdatedBaseProperties = EcommerceEventProperties & {
|
|
|
1698
1709
|
*/
|
|
1699
1710
|
cart_id: string;
|
|
1700
1711
|
|
|
1712
|
+
/**
|
|
1713
|
+
* Subtotal value of the cart (post-discount, pre-tax/shipping).
|
|
1714
|
+
*/
|
|
1715
|
+
subtotal_value?: number;
|
|
1716
|
+
|
|
1717
|
+
/**
|
|
1718
|
+
* Total tax applied to the cart.
|
|
1719
|
+
*/
|
|
1720
|
+
tax?: number;
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Total shipping cost for the cart.
|
|
1724
|
+
*/
|
|
1725
|
+
shipping?: number;
|
|
1726
|
+
|
|
1701
1727
|
/**
|
|
1702
1728
|
* The products in the updated cart.
|
|
1703
1729
|
*/
|
|
@@ -1774,21 +1800,17 @@ export interface ProductViewedEventProperties extends EcommerceEventProperties {
|
|
|
1774
1800
|
*/
|
|
1775
1801
|
price: number;
|
|
1776
1802
|
|
|
1803
|
+
/**
|
|
1804
|
+
* A list of types for the product that was viewed. The `back_in_stock` and `price_drop` types can be used to trigger
|
|
1805
|
+
* back-in-stock and price drop notifications. Each type cannot exceed 255 characters in length.
|
|
1806
|
+
*/
|
|
1807
|
+
type?: string[];
|
|
1808
|
+
|
|
1777
1809
|
/**
|
|
1778
1810
|
* Additional metadata about the product viewed. Keys are limited to 255 characters in length, cannot begin with a $ character,
|
|
1779
1811
|
* and can only contain alphanumeric characters and punctuation. Total size of metadata cannot exceed 50KB.
|
|
1780
1812
|
*/
|
|
1781
1813
|
metadata?: {
|
|
1782
|
-
/**
|
|
1783
|
-
* Shopify SKU, only applicable to Shopify integrations. Cannot exceed 255 characters in length.
|
|
1784
|
-
*/
|
|
1785
|
-
sku?: string;
|
|
1786
|
-
|
|
1787
|
-
/**
|
|
1788
|
-
* A list of types for the product that was viewed. The `back_in_stock` and `price_drop` types can be used to trigger
|
|
1789
|
-
* back-in-stock and price drop notifications. Each type cannot exceed 255 characters in length.
|
|
1790
|
-
*/
|
|
1791
|
-
type?: string[];
|
|
1792
1814
|
[key: string]: any;
|
|
1793
1815
|
};
|
|
1794
1816
|
}
|
|
@@ -1811,6 +1833,21 @@ export interface OrderPlacedEventProperties extends EcommerceEventProperties {
|
|
|
1811
1833
|
*/
|
|
1812
1834
|
total_value: number;
|
|
1813
1835
|
|
|
1836
|
+
/**
|
|
1837
|
+
* Subtotal value of the cart (post-discount, pre-tax/shipping).
|
|
1838
|
+
*/
|
|
1839
|
+
subtotal_value?: number;
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* Total tax applied to the cart.
|
|
1843
|
+
*/
|
|
1844
|
+
tax?: number;
|
|
1845
|
+
|
|
1846
|
+
/**
|
|
1847
|
+
* Total shipping cost for the cart.
|
|
1848
|
+
*/
|
|
1849
|
+
shipping?: number;
|
|
1850
|
+
|
|
1814
1851
|
/**
|
|
1815
1852
|
* The total amount of discounts applied to the order (ex: 12.99).
|
|
1816
1853
|
*/
|
|
@@ -1865,9 +1902,15 @@ export interface OrderPlacedEventProperties extends EcommerceEventProperties {
|
|
|
1865
1902
|
* `properties` must match the corresponding properties interface.
|
|
1866
1903
|
*/
|
|
1867
1904
|
export type EcommerceEvent =
|
|
1868
|
-
| {
|
|
1905
|
+
| {
|
|
1906
|
+
name: "ecommerce.product_viewed";
|
|
1907
|
+
properties: ProductViewedEventProperties;
|
|
1908
|
+
}
|
|
1869
1909
|
| { name: "ecommerce.cart_updated"; properties: CartUpdatedEventProperties }
|
|
1870
|
-
| {
|
|
1910
|
+
| {
|
|
1911
|
+
name: "ecommerce.checkout_started";
|
|
1912
|
+
properties: CheckoutStartedEventProperties;
|
|
1913
|
+
}
|
|
1871
1914
|
| { name: "ecommerce.order_placed"; properties: OrderPlacedEventProperties };
|
|
1872
1915
|
|
|
1873
1916
|
export class FeatureFlag {
|
|
@@ -1959,6 +2002,28 @@ export class Banner {
|
|
|
1959
2002
|
/** Whether this banner is a control banner. */
|
|
1960
2003
|
isControl: boolean;
|
|
1961
2004
|
|
|
2005
|
+
/** Remove all event subscriptions from this banner. */
|
|
2006
|
+
removeAllSubscriptions(): void;
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* Remove an event subscription that you previously subscribed to.
|
|
2010
|
+
*
|
|
2011
|
+
* @param subscriptionGuid - The identifier of the subscription you wish to remove, returned by the method
|
|
2012
|
+
* you initially used to create it.
|
|
2013
|
+
*/
|
|
2014
|
+
removeSubscription(subscriptionGuid: string): void;
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* Subscribe to receive dismissed events. The subscriber callback will be called whenever this banner is dismissed.
|
|
2018
|
+
*
|
|
2019
|
+
* @param subscriber - The callback function to receive dismissed events. This function will be invoked with
|
|
2020
|
+
* no arguments when this banner records a dismissal.
|
|
2021
|
+
*
|
|
2022
|
+
* @returns The identifier of the subscription created. This can be passed to `Banner.removeSubscription`
|
|
2023
|
+
* to cancel the subscription. Returns null if the subscriber passed is not a function.
|
|
2024
|
+
*/
|
|
2025
|
+
subscribeToDismissedEvent(subscriber: () => void): string | null;
|
|
2026
|
+
|
|
1962
2027
|
/**
|
|
1963
2028
|
* Properties of this object.
|
|
1964
2029
|
*
|
|
@@ -2324,6 +2389,21 @@ export function logBannerClick(
|
|
|
2324
2389
|
buttonId?: string,
|
|
2325
2390
|
): boolean | undefined;
|
|
2326
2391
|
|
|
2392
|
+
/**
|
|
2393
|
+
* Dismisses the given Banner.
|
|
2394
|
+
*
|
|
2395
|
+
* Use this when rendering Banners with a custom UI and handling your own close button or dismissal gesture.
|
|
2396
|
+
* The SDK will update its dismissal state, remove the Banner from the active Banner cache, notify
|
|
2397
|
+
* `subscribeToBannersUpdates` subscribers, and sync the dismissal to Braze.
|
|
2398
|
+
*
|
|
2399
|
+
* @param banner - the `Banner` object to dismiss
|
|
2400
|
+
*
|
|
2401
|
+
* @returns `true` if the dismissal event was accepted for logging. Returns `false` if the dismissal was ignored,
|
|
2402
|
+
* including when no Banner is matched to the placement or when the Banner was already dismissed.
|
|
2403
|
+
* Returns `undefined` if the SDK has not been initialized.
|
|
2404
|
+
*/
|
|
2405
|
+
export function dismissBanner(banner: Banner): boolean | undefined;
|
|
2406
|
+
|
|
2327
2407
|
/**
|
|
2328
2408
|
* Reports that the current user performed a custom named event.
|
|
2329
2409
|
*
|
|
@@ -2455,6 +2535,18 @@ export function logPurchase(
|
|
|
2455
2535
|
*/
|
|
2456
2536
|
export function openSession(): void;
|
|
2457
2537
|
|
|
2538
|
+
/**
|
|
2539
|
+
* Logs out the current user. This unregisters push for this browser via `unregisterPush`, and on success
|
|
2540
|
+
* wipes all locally stored SDK data (see `wipeData`) and disables the SDK (see `disableSDK`).
|
|
2541
|
+
*
|
|
2542
|
+
* @param successCallback - When the user is successfully logged out, this callback will be invoked.
|
|
2543
|
+
* @param errorCallback - If the logout fails for unknown reasons, this callback will be invoked.
|
|
2544
|
+
*/
|
|
2545
|
+
export function logout(
|
|
2546
|
+
successCallback?: () => void,
|
|
2547
|
+
errorCallback?: () => void,
|
|
2548
|
+
): void;
|
|
2549
|
+
|
|
2458
2550
|
/**
|
|
2459
2551
|
* Register this browser environment to receive web push for this user. Supports browsers which implement the
|
|
2460
2552
|
* [W3C Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) (browsers in which
|
|
@@ -2467,7 +2559,7 @@ export function openSession(): void;
|
|
|
2467
2559
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2468
2560
|
*
|
|
2469
2561
|
* ```
|
|
2470
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk/6.
|
|
2562
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk/6.10/service-worker.js');
|
|
2471
2563
|
* ```
|
|
2472
2564
|
*
|
|
2473
2565
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2658,8 +2750,8 @@ export function toggleLogging(): void;
|
|
|
2658
2750
|
* Note that for Safari, Apple does not offer any unsubscribe mechanism, so on Safari this method leaves the user
|
|
2659
2751
|
* with push permission granted and simply sets their subscription status to unsubscribed.
|
|
2660
2752
|
*
|
|
2661
|
-
* @param successCallback -
|
|
2662
|
-
*
|
|
2753
|
+
* @param successCallback - Invoked when unregister processing completes. This includes when push is not supported
|
|
2754
|
+
* in the browser or the device is already unsubscribed.
|
|
2663
2755
|
* @param errorCallback - If the unsubscribe fails for unknown reasons, this callback will be invoked.
|
|
2664
2756
|
*/
|
|
2665
2757
|
export function unregisterPush(
|
|
@@ -2889,7 +2981,7 @@ export type InitializationOptions = {
|
|
|
2889
2981
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2890
2982
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2891
2983
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2892
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk/6.
|
|
2984
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk/6.10/service-worker.js');` or by including the content
|
|
2893
2985
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2894
2986
|
*/
|
|
2895
2987
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
const p = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
$c: "pc",
|
|
5
|
+
Fc: "ca",
|
|
6
|
+
bl: "i",
|
|
7
|
+
Qa: "ie",
|
|
8
|
+
vs: "cci",
|
|
9
|
+
ws: "ccic",
|
|
10
|
+
us: "ccc",
|
|
11
|
+
gs: "ccd",
|
|
12
12
|
wm: "ss",
|
|
13
13
|
hm: "se",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
Fn: "si",
|
|
15
|
+
On: "sc",
|
|
16
|
+
Xn: "sbc",
|
|
17
|
+
Lc: "sfe",
|
|
18
18
|
om: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
Dc: "lr",
|
|
20
|
+
Ac: "uae",
|
|
21
|
+
Mc: "lcaa",
|
|
22
|
+
Cc: "lcar",
|
|
23
23
|
Zu: "inc",
|
|
24
24
|
Qu: "add",
|
|
25
25
|
Xu: "rem",
|
|
26
26
|
Yu: "set",
|
|
27
27
|
Vu: "ncam",
|
|
28
|
-
|
|
28
|
+
Tc: "sgu",
|
|
29
29
|
xo: "ffi",
|
|
30
30
|
ro: "bi",
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Nt: "bc",
|
|
32
|
+
Rt: "bd",
|
|
33
33
|
},
|
|
34
|
-
We = {
|
|
34
|
+
We = { Gc: "content_cards_displayed" };
|
|
35
35
|
export { p as EventTypes, We as InternalEventTypes };
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export default class et {
|
|
2
2
|
constructor(t, e) {
|
|
3
3
|
(this.database = t),
|
|
4
|
-
(this.
|
|
4
|
+
(this.Ud = e),
|
|
5
5
|
(this.parent = "undefined" == typeof window ? self : window),
|
|
6
6
|
(this.database = t),
|
|
7
|
-
(this.
|
|
7
|
+
(this.Ud = e);
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
kd() {
|
|
10
10
|
if ("indexedDB" in this.parent) return this.parent.indexedDB;
|
|
11
11
|
}
|
|
12
12
|
isSupported() {
|
|
13
13
|
var t;
|
|
14
14
|
try {
|
|
15
|
-
if (null == this.
|
|
15
|
+
if (null == this.kd()) return !1;
|
|
16
16
|
{
|
|
17
17
|
const e =
|
|
18
|
-
null === (t = this.
|
|
18
|
+
null === (t = this.kd()) || void 0 === t
|
|
19
19
|
? void 0
|
|
20
20
|
: t.open("Braze IndexedDB Support Test");
|
|
21
21
|
if (
|
|
@@ -25,10 +25,10 @@ export default class et {
|
|
|
25
25
|
"undefined" != typeof window)
|
|
26
26
|
) {
|
|
27
27
|
const t = window,
|
|
28
|
-
e = t.chrome || t.browser || t.
|
|
28
|
+
e = t.chrome || t.browser || t.Kd;
|
|
29
29
|
if (e && e.runtime && e.runtime.id)
|
|
30
30
|
return (
|
|
31
|
-
this.
|
|
31
|
+
this.Ud.info(
|
|
32
32
|
"Not using IndexedDB for storage because we are running inside an extension",
|
|
33
33
|
),
|
|
34
34
|
!1
|
|
@@ -38,37 +38,37 @@ export default class et {
|
|
|
38
38
|
}
|
|
39
39
|
} catch (t) {
|
|
40
40
|
return (
|
|
41
|
-
this.
|
|
41
|
+
this.Ud.info(
|
|
42
42
|
"Not using IndexedDB for storage due to following error: " + t,
|
|
43
43
|
),
|
|
44
44
|
!1
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
Gd(t, e) {
|
|
49
49
|
var n;
|
|
50
50
|
const o =
|
|
51
|
-
null === (n = this.
|
|
51
|
+
null === (n = this.kd()) || void 0 === n
|
|
52
52
|
? void 0
|
|
53
|
-
: n.open(this.database.
|
|
53
|
+
: n.open(this.database.Hd, this.database.VERSION);
|
|
54
54
|
if (null == o) return "function" == typeof e && e(), !1;
|
|
55
55
|
const i = this;
|
|
56
56
|
return (
|
|
57
57
|
(o.onupgradeneeded = (t) => {
|
|
58
58
|
var e;
|
|
59
|
-
i.
|
|
59
|
+
i.Ud.info(
|
|
60
60
|
"Upgrading indexedDB " +
|
|
61
|
-
i.database.
|
|
61
|
+
i.database.Hd +
|
|
62
62
|
" to v" +
|
|
63
63
|
i.database.VERSION +
|
|
64
64
|
"...",
|
|
65
65
|
);
|
|
66
66
|
const n = null === (e = t.target) || void 0 === e ? void 0 : e.result;
|
|
67
|
-
for (const t in i.database.
|
|
67
|
+
for (const t in i.database.Ws) {
|
|
68
68
|
const e = t;
|
|
69
|
-
i.database.
|
|
70
|
-
!n.objectStoreNames.contains(i.database.
|
|
71
|
-
n.createObjectStore(i.database.
|
|
69
|
+
i.database.Ws.hasOwnProperty(t) &&
|
|
70
|
+
!n.objectStoreNames.contains(i.database.Ws[e]) &&
|
|
71
|
+
n.createObjectStore(i.database.Ws[e]);
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
(o.onsuccess = (n) => {
|
|
@@ -77,7 +77,7 @@ export default class et {
|
|
|
77
77
|
(r.onversionchange = () => {
|
|
78
78
|
r.close(),
|
|
79
79
|
"function" == typeof e && e(),
|
|
80
|
-
i.
|
|
80
|
+
i.Ud.error(
|
|
81
81
|
"Needed to close the database unexpectedly because of an upgrade in another tab",
|
|
82
82
|
);
|
|
83
83
|
}),
|
|
@@ -87,9 +87,9 @@ export default class et {
|
|
|
87
87
|
var n;
|
|
88
88
|
const o = t;
|
|
89
89
|
return (
|
|
90
|
-
i.
|
|
90
|
+
i.Ud.info(
|
|
91
91
|
"Could not open indexedDB " +
|
|
92
|
-
i.database.
|
|
92
|
+
i.database.Hd +
|
|
93
93
|
" v" +
|
|
94
94
|
i.database.VERSION +
|
|
95
95
|
": " +
|
|
@@ -105,16 +105,16 @@ export default class et {
|
|
|
105
105
|
setItem(t, e, n, o, i) {
|
|
106
106
|
if (!this.isSupported()) return "function" == typeof i && i(), !1;
|
|
107
107
|
const r = this;
|
|
108
|
-
return this.
|
|
108
|
+
return this.Gd((d) => {
|
|
109
109
|
if (!d.objectStoreNames.contains(t))
|
|
110
110
|
return (
|
|
111
|
-
r.
|
|
111
|
+
r.Ud.error(
|
|
112
112
|
"Could not store object " +
|
|
113
113
|
e +
|
|
114
114
|
" in " +
|
|
115
115
|
t +
|
|
116
116
|
" on indexedDB " +
|
|
117
|
-
r.database.
|
|
117
|
+
r.database.Hd +
|
|
118
118
|
" - " +
|
|
119
119
|
t +
|
|
120
120
|
" is not a valid objectStore",
|
|
@@ -126,13 +126,13 @@ export default class et {
|
|
|
126
126
|
s.oncomplete = () => d.close();
|
|
127
127
|
const u = s.objectStore(t).put(n, e);
|
|
128
128
|
(u.onerror = () => {
|
|
129
|
-
r.
|
|
129
|
+
r.Ud.error(
|
|
130
130
|
"Could not store object " +
|
|
131
131
|
e +
|
|
132
132
|
" in " +
|
|
133
133
|
t +
|
|
134
134
|
" on indexedDB " +
|
|
135
|
-
r.database.
|
|
135
|
+
r.database.Hd,
|
|
136
136
|
),
|
|
137
137
|
"function" == typeof i && i();
|
|
138
138
|
}),
|
|
@@ -144,16 +144,16 @@ export default class et {
|
|
|
144
144
|
getItem(t, e, n) {
|
|
145
145
|
if (!this.isSupported()) return !1;
|
|
146
146
|
const o = this;
|
|
147
|
-
return this.
|
|
147
|
+
return this.Gd((i) => {
|
|
148
148
|
if (!i.objectStoreNames.contains(t))
|
|
149
149
|
return (
|
|
150
|
-
o.
|
|
150
|
+
o.Ud.error(
|
|
151
151
|
"Could not retrieve object " +
|
|
152
152
|
e +
|
|
153
153
|
" in " +
|
|
154
154
|
t +
|
|
155
155
|
" on indexedDB " +
|
|
156
|
-
o.database.
|
|
156
|
+
o.database.Hd +
|
|
157
157
|
" - " +
|
|
158
158
|
t +
|
|
159
159
|
" is not a valid objectStore",
|
|
@@ -164,13 +164,13 @@ export default class et {
|
|
|
164
164
|
r.oncomplete = () => i.close();
|
|
165
165
|
const d = r.objectStore(t).get(e);
|
|
166
166
|
(d.onerror = () => {
|
|
167
|
-
o.
|
|
167
|
+
o.Ud.error(
|
|
168
168
|
"Could not retrieve object " +
|
|
169
169
|
e +
|
|
170
170
|
" in " +
|
|
171
171
|
t +
|
|
172
172
|
" on indexedDB " +
|
|
173
|
-
o.database.
|
|
173
|
+
o.database.Hd,
|
|
174
174
|
);
|
|
175
175
|
}),
|
|
176
176
|
(d.onsuccess = (t) => {
|
|
@@ -183,14 +183,14 @@ export default class et {
|
|
|
183
183
|
kr(t, e, n) {
|
|
184
184
|
if (!this.isSupported()) return "function" == typeof n && n(), !1;
|
|
185
185
|
const o = this;
|
|
186
|
-
return this.
|
|
186
|
+
return this.Gd((i) => {
|
|
187
187
|
if (!i.objectStoreNames.contains(t))
|
|
188
188
|
return (
|
|
189
|
-
o.
|
|
189
|
+
o.Ud.error(
|
|
190
190
|
"Could not retrieve last record from " +
|
|
191
191
|
t +
|
|
192
192
|
" on indexedDB " +
|
|
193
|
-
o.database.
|
|
193
|
+
o.database.Hd +
|
|
194
194
|
" - " +
|
|
195
195
|
t +
|
|
196
196
|
" is not a valid objectStore",
|
|
@@ -202,8 +202,8 @@ export default class et {
|
|
|
202
202
|
r.oncomplete = () => i.close();
|
|
203
203
|
const d = r.objectStore(t).openCursor(null, "prev");
|
|
204
204
|
(d.onerror = () => {
|
|
205
|
-
o.
|
|
206
|
-
"Could not open cursor for " + t + " on indexedDB " + o.database.
|
|
205
|
+
o.Ud.error(
|
|
206
|
+
"Could not open cursor for " + t + " on indexedDB " + o.database.Hd,
|
|
207
207
|
),
|
|
208
208
|
"function" == typeof n && n();
|
|
209
209
|
}),
|
|
@@ -219,16 +219,16 @@ export default class et {
|
|
|
219
219
|
ge(t, e) {
|
|
220
220
|
if (!this.isSupported()) return !1;
|
|
221
221
|
const n = this;
|
|
222
|
-
return this.
|
|
222
|
+
return this.Gd((o) => {
|
|
223
223
|
if (!o.objectStoreNames.contains(t))
|
|
224
224
|
return (
|
|
225
|
-
n.
|
|
225
|
+
n.Ud.error(
|
|
226
226
|
"Could not delete record " +
|
|
227
227
|
e +
|
|
228
228
|
" from " +
|
|
229
229
|
t +
|
|
230
230
|
" on indexedDB " +
|
|
231
|
-
n.database.
|
|
231
|
+
n.database.Hd +
|
|
232
232
|
" - " +
|
|
233
233
|
t +
|
|
234
234
|
" is not a valid objectStore",
|
|
@@ -238,28 +238,28 @@ export default class et {
|
|
|
238
238
|
const i = o.transaction([t], "readwrite");
|
|
239
239
|
i.oncomplete = () => o.close();
|
|
240
240
|
i.objectStore(t).delete(e).onerror = () => {
|
|
241
|
-
n.
|
|
241
|
+
n.Ud.error(
|
|
242
242
|
"Could not delete record " +
|
|
243
243
|
e +
|
|
244
244
|
" from " +
|
|
245
245
|
t +
|
|
246
246
|
" on indexedDB " +
|
|
247
|
-
n.database.
|
|
247
|
+
n.database.Hd,
|
|
248
248
|
);
|
|
249
249
|
};
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
Qs(t, e) {
|
|
253
253
|
if (!this.isSupported()) return !1;
|
|
254
254
|
const n = this;
|
|
255
|
-
return this.
|
|
255
|
+
return this.Gd((o) => {
|
|
256
256
|
if (!o.objectStoreNames.contains(t))
|
|
257
257
|
return (
|
|
258
|
-
n.
|
|
258
|
+
n.Ud.error(
|
|
259
259
|
"Could not retrieve objects from " +
|
|
260
260
|
t +
|
|
261
261
|
" on indexedDB " +
|
|
262
|
-
n.database.
|
|
262
|
+
n.database.Hd +
|
|
263
263
|
" - " +
|
|
264
264
|
t +
|
|
265
265
|
" is not a valid objectStore",
|
|
@@ -273,18 +273,18 @@ export default class et {
|
|
|
273
273
|
s = [];
|
|
274
274
|
(d.onerror = () => {
|
|
275
275
|
s.length > 0
|
|
276
|
-
? (n.
|
|
276
|
+
? (n.Ud.info(
|
|
277
277
|
"Cursor closed midway through for " +
|
|
278
278
|
t +
|
|
279
279
|
" on indexedDB " +
|
|
280
|
-
n.database.
|
|
280
|
+
n.database.Hd,
|
|
281
281
|
),
|
|
282
282
|
e(s))
|
|
283
|
-
: n.
|
|
283
|
+
: n.Ud.error(
|
|
284
284
|
"Could not open cursor for " +
|
|
285
285
|
t +
|
|
286
286
|
" on indexedDB " +
|
|
287
|
-
n.database.
|
|
287
|
+
n.database.Hd,
|
|
288
288
|
);
|
|
289
289
|
}),
|
|
290
290
|
(d.onsuccess = (t) => {
|
|
@@ -304,45 +304,45 @@ export default class et {
|
|
|
304
304
|
clearData() {
|
|
305
305
|
if (!this.isSupported()) return !1;
|
|
306
306
|
const t = [];
|
|
307
|
-
for (const e in this.database.
|
|
307
|
+
for (const e in this.database.Ws) {
|
|
308
308
|
const n = e;
|
|
309
|
-
this.database.
|
|
310
|
-
this.database.
|
|
311
|
-
t.push(this.database.
|
|
309
|
+
this.database.Ws.hasOwnProperty(e) &&
|
|
310
|
+
this.database.Ws[n] !== this.database.Ws.pe &&
|
|
311
|
+
t.push(this.database.Ws[n]);
|
|
312
312
|
}
|
|
313
313
|
const e = this;
|
|
314
|
-
return this.
|
|
314
|
+
return this.Gd(function (n) {
|
|
315
315
|
const o = n.transaction(t, "readwrite");
|
|
316
316
|
o.oncomplete = () => n.close();
|
|
317
317
|
for (let n = 0; n < t.length; n++) {
|
|
318
318
|
const i = t[n];
|
|
319
319
|
o.objectStore(i).clear().onerror = function () {
|
|
320
|
-
e.
|
|
320
|
+
e.Ud.error(
|
|
321
321
|
"Could not clear " +
|
|
322
322
|
this.source.name +
|
|
323
323
|
" on indexedDB " +
|
|
324
|
-
e.database.
|
|
324
|
+
e.database.Hd,
|
|
325
325
|
);
|
|
326
326
|
};
|
|
327
327
|
}
|
|
328
328
|
o.onerror = function () {
|
|
329
|
-
e.
|
|
330
|
-
"Could not clear object stores on indexedDB " + e.database.
|
|
329
|
+
e.Ud.error(
|
|
330
|
+
"Could not clear object stores on indexedDB " + e.database.Hd,
|
|
331
331
|
);
|
|
332
332
|
};
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
et.
|
|
337
|
-
|
|
338
|
-
|
|
336
|
+
et._s = {
|
|
337
|
+
Xs: {
|
|
338
|
+
Hd: "AppboyServiceWorkerAsyncStorage",
|
|
339
339
|
VERSION: 6,
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
Ws: {
|
|
341
|
+
pn: "data",
|
|
342
342
|
yr: "pushClicks",
|
|
343
343
|
Fu: "pushSubscribed",
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
Vd: "fallbackDevice",
|
|
345
|
+
Vs: "cardUpdates",
|
|
346
346
|
pe: "optOut",
|
|
347
347
|
Br: "pendingData",
|
|
348
348
|
wh: "sdkAuthenticationSignature",
|