@braze/web-sdk 4.7.2 → 4.8.1
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 +32 -26
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +5 -5
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +25 -25
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +74 -74
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +18 -18
- package/src/Card/card-manager-factory.js +2 -2
- package/src/Card/card-manager.js +48 -42
- package/src/Card/display/card-display.js +70 -67
- package/src/Card/log-card-click.js +1 -1
- package/src/Card/log-card-dismissal.js +1 -1
- package/src/Card/log-card-impressions.js +3 -3
- package/src/Card/models/banner.js +3 -2
- package/src/Card/models/captioned-image.js +6 -5
- package/src/Card/models/card.js +107 -87
- package/src/Card/models/classic-card.js +5 -5
- package/src/Card/models/control-card.js +5 -21
- package/src/Card/types.js +1 -0
- package/src/Card/util/card-factory.js +32 -32
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +283 -175
- package/src/ContentCards/content-cards.js +2 -2
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/log-content-cards-displayed.js +2 -2
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +9 -6
- package/src/ContentCards/types.js +1 -0
- package/src/ContentCards/ui/hide-content-cards.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +36 -34
- package/src/Core/add-sdk-metadata.js +17 -18
- package/src/Core/change-user.js +12 -14
- package/src/Core/destroy.js +1 -1
- package/src/Core/disable-sdk.js +8 -6
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/get-device-id.js +7 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +57 -40
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +22 -15
- package/src/Core/log-purchase.js +33 -33
- package/src/Core/open-session.js +17 -15
- package/src/Core/request-immediate-data-flush.js +4 -2
- package/src/Core/set-logger.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +5 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +3 -1
- package/src/Core/toggle-logging.js +1 -1
- package/src/Core/types.js +1 -0
- package/src/Core/wipe-data.js +11 -10
- package/src/FeatureFlags/feature-flag-factory.js +6 -6
- package/src/FeatureFlags/feature-flag.js +17 -17
- package/src/FeatureFlags/feature-flags-provider-factory.js +2 -2
- package/src/FeatureFlags/feature-flags-provider.js +67 -65
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +4 -1
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +57 -46
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/log-feed-displayed.js +3 -1
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/types.js +1 -0
- package/src/Feed/ui/hide-feed.js +2 -2
- package/src/Feed/ui/show-feed.js +41 -37
- package/src/InAppMessage/display/html-message-to-html.js +125 -119
- package/src/InAppMessage/display/in-app-message-to-html.js +72 -69
- package/src/InAppMessage/display/modal-utils.js +18 -13
- package/src/InAppMessage/in-app-message-factory.js +9 -8
- package/src/InAppMessage/in-app-message-manager-factory.js +7 -7
- package/src/InAppMessage/in-app-message-manager.js +130 -110
- package/src/InAppMessage/log-in-app-message-button-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +10 -10
- package/src/InAppMessage/log-in-app-message-impression.js +5 -5
- package/src/InAppMessage/models/control-message.js +4 -1
- package/src/InAppMessage/models/full-screen-message.js +35 -37
- package/src/InAppMessage/models/html-message.js +34 -33
- package/src/InAppMessage/models/in-app-message-button.js +23 -16
- package/src/InAppMessage/models/in-app-message.js +147 -105
- package/src/InAppMessage/models/modal-message.js +34 -36
- package/src/InAppMessage/models/slide-up-message.js +25 -27
- package/src/InAppMessage/models/templated-in-app-message.js +12 -7
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/types.js +1 -0
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +95 -89
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -0
- 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 +20 -20
- package/src/Push/push-manager.js +193 -174
- package/src/Push/request-push-permission.js +4 -3
- package/src/Push/types.js +1 -0
- package/src/Push/unregister-push.js +2 -2
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/types.js +1 -0
- package/src/User/user-manager.js +24 -24
- package/src/User/user.js +117 -105
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +6 -0
- package/src/common/event-logger.js +6 -6
- package/src/common/feed-display.js +95 -85
- package/src/common/types.js +1 -0
- package/src/l10n/l10n-manager-factory.js +10 -10
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +37 -34
- package/src/managers/braze-instance.js +209 -193
- package/src/managers/device-manager.js +43 -38
- package/src/managers/network-manager.js +119 -96
- package/src/managers/server-config-manager.js +68 -48
- package/src/managers/session-manager.js +52 -45
- package/src/managers/storage-manager-factory.js +29 -22
- package/src/managers/storage-manager.js +288 -273
- package/src/managers/subscription-manager.js +9 -6
- package/src/managers/types.js +1 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +14 -8
- package/src/models/device.js +10 -18
- package/src/models/identifier.js +10 -11
- package/src/models/push-token.js +17 -12
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +36 -20
- package/src/models/types.js +1 -0
- package/src/request-controller.js +176 -174
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +64 -64
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +9 -9
- package/src/triggers/models/push-click-data.js +7 -7
- package/src/triggers/models/trigger-condition.js +57 -57
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +42 -42
- package/src/triggers/triggers-provider-factory.js +8 -8
- package/src/triggers/triggers-provider.js +173 -170
- package/src/types.js +1 -0
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +20 -20
- package/src/util/browser-detector.js +22 -22
- package/src/util/client-hints-parser.js +7 -7
- package/src/util/code-utils.js +1 -1
- package/src/util/color-utils.js +2 -2
- package/src/util/component-utils.js +2 -2
- package/src/util/deprecation-utils.js +1 -1
- package/src/util/device-constants.js +3 -3
- package/src/util/dom-utils.js +7 -7
- package/src/util/error-utils.js +2 -0
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +11 -11
- package/src/util/request-header-utils.js +23 -0
- package/src/util/string-utils.js +1 -1
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/validation-utils.js +44 -44
- 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 v4.
|
|
2
|
+
* Type definitions for @braze/web-sdk v4.8.1
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2023 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
* no arguments when this card records a click.
|
|
89
89
|
*
|
|
90
90
|
* @returns The identifier of the subscription created. This can be passed to `Card.removeSubscription`
|
|
91
|
-
* to cancel the subscription.
|
|
91
|
+
* to cancel the subscription. Returns null if the subscriber passed is not a function.
|
|
92
92
|
*/
|
|
93
|
-
subscribeToClickedEvent(subscriber: () => void): string;
|
|
93
|
+
subscribeToClickedEvent(subscriber: () => void): string | null;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Subscribe to receive dismissed events. The subscriber callback will be called whenever this card is dismissed by the
|
|
@@ -100,9 +100,9 @@
|
|
|
100
100
|
* no arguments when this card records a dismissal.
|
|
101
101
|
*
|
|
102
102
|
* @returns The identifier of the subscription created. This can be passed to `Card.removeSubscription`
|
|
103
|
-
* to cancel the subscription.
|
|
103
|
+
* to cancel the subscription. Returns null if the subscriber passed is not a function.
|
|
104
104
|
*/
|
|
105
|
-
subscribeToDismissedEvent(subscriber: () => void): string;
|
|
105
|
+
subscribeToDismissedEvent(subscriber: () => void): string | null;
|
|
106
106
|
|
|
107
107
|
/** The id of the card. This will be reported back to Braze with events for analytics purposes. */
|
|
108
108
|
id?: string;
|
|
@@ -390,6 +390,9 @@
|
|
|
390
390
|
extras?: Record<string, string>,
|
|
391
391
|
pinned?: boolean
|
|
392
392
|
);
|
|
393
|
+
|
|
394
|
+
/** Whether this card is a ControlCard. */
|
|
395
|
+
isControl: true;
|
|
393
396
|
}
|
|
394
397
|
|
|
395
398
|
export class ContentCards {
|
|
@@ -473,10 +476,10 @@
|
|
|
473
476
|
triggerId?: string;
|
|
474
477
|
|
|
475
478
|
/** Object of string/string key/value pairs. */
|
|
476
|
-
extras: Record<string,
|
|
479
|
+
extras: Record<string, string>;
|
|
477
480
|
|
|
478
481
|
/** Whether this message is a ControlMessage. */
|
|
479
|
-
isControl:
|
|
482
|
+
isControl: true;
|
|
480
483
|
}
|
|
481
484
|
|
|
482
485
|
|
|
@@ -562,7 +565,7 @@
|
|
|
562
565
|
message?: string;
|
|
563
566
|
|
|
564
567
|
/** Object of string/string key/value pairs. */
|
|
565
|
-
extras: Record<string,
|
|
568
|
+
extras: Record<string, string>;
|
|
566
569
|
|
|
567
570
|
/**
|
|
568
571
|
* The id of the trigger that created this message. The SDK will report back this to
|
|
@@ -598,7 +601,7 @@
|
|
|
598
601
|
css?: string;
|
|
599
602
|
|
|
600
603
|
/** Whether this message is a ControlMessage. */
|
|
601
|
-
isControl:
|
|
604
|
+
isControl: false;
|
|
602
605
|
|
|
603
606
|
/**
|
|
604
607
|
* Call this method if you wish to programmatically remove the message from the DOM. This method will only
|
|
@@ -625,9 +628,9 @@
|
|
|
625
628
|
* no arguments when this message records a click.
|
|
626
629
|
*
|
|
627
630
|
* @returns The identifier of the subscription created. This can be passed to `removeSubscription`
|
|
628
|
-
* to cancel the subscription.
|
|
631
|
+
* to cancel the subscription. Returns null if the subscriber passed is not a function.
|
|
629
632
|
*/
|
|
630
|
-
subscribeToClickedEvent(subscriber: () => void): string;
|
|
633
|
+
subscribeToClickedEvent(subscriber: () => void): string | null;
|
|
631
634
|
|
|
632
635
|
/**
|
|
633
636
|
* Subscribe to receive dismissed events. The subscriber callback will be called whenever this message is closed
|
|
@@ -637,9 +640,9 @@
|
|
|
637
640
|
* no arguments when this message records a dismissal.
|
|
638
641
|
*
|
|
639
642
|
* @returns The identifier of the subscription created. This can be passed to `removeSubscription`
|
|
640
|
-
* to cancel the subscription.
|
|
643
|
+
* to cancel the subscription. Returns null if the subscriber passed is not a function.
|
|
641
644
|
*/
|
|
642
|
-
subscribeToDismissedEvent(subscriber: () => void): string;
|
|
645
|
+
subscribeToDismissedEvent(subscriber: () => void): string | null;
|
|
643
646
|
|
|
644
647
|
|
|
645
648
|
}
|
|
@@ -698,7 +701,7 @@
|
|
|
698
701
|
constructor(
|
|
699
702
|
message?: string,
|
|
700
703
|
messageAlignment?: TextAlignment,
|
|
701
|
-
extras?: Record<string,
|
|
704
|
+
extras?: Record<string, string>,
|
|
702
705
|
triggerId?: string,
|
|
703
706
|
clickAction?: ClickAction,
|
|
704
707
|
uri?: string,
|
|
@@ -857,7 +860,7 @@
|
|
|
857
860
|
constructor(
|
|
858
861
|
message?: string,
|
|
859
862
|
messageAlignment?: TextAlignment,
|
|
860
|
-
extras?: Record<string,
|
|
863
|
+
extras?: Record<string, string>,
|
|
861
864
|
triggerId?: string,
|
|
862
865
|
clickAction?: ClickAction,
|
|
863
866
|
uri?: string,
|
|
@@ -980,7 +983,7 @@
|
|
|
980
983
|
*/
|
|
981
984
|
constructor(
|
|
982
985
|
message: string,
|
|
983
|
-
extras?: Record<string,
|
|
986
|
+
extras?: Record<string, string>,
|
|
984
987
|
triggerId?: string,
|
|
985
988
|
dismissType?: DismissType,
|
|
986
989
|
duration?: number,
|
|
@@ -1047,7 +1050,7 @@
|
|
|
1047
1050
|
message: string,
|
|
1048
1051
|
messageAlignment?: TextAlignment,
|
|
1049
1052
|
slideFrom?: SlideFrom,
|
|
1050
|
-
extras?: Record<string,
|
|
1053
|
+
extras?: Record<string, string>,
|
|
1051
1054
|
triggerId?: string,
|
|
1052
1055
|
clickAction?: ClickAction,
|
|
1053
1056
|
uri?: string,
|
|
@@ -1496,9 +1499,9 @@
|
|
|
1496
1499
|
* no arguments when this button records a click.
|
|
1497
1500
|
*
|
|
1498
1501
|
* @returns The identifier of the subscription created. This can be passed to `removeSubscription`
|
|
1499
|
-
* to cancel the subscription.
|
|
1502
|
+
* to cancel the subscription. Returns null if the subscriber passed is not a function.
|
|
1500
1503
|
*/
|
|
1501
|
-
subscribeToClickedEvent(subscriber: () => void): string;
|
|
1504
|
+
subscribeToClickedEvent(subscriber: () => void): string | null;
|
|
1502
1505
|
}
|
|
1503
1506
|
|
|
1504
1507
|
export interface FeatureFlagStringProperty {
|
|
@@ -1842,7 +1845,7 @@
|
|
|
1842
1845
|
): boolean;
|
|
1843
1846
|
|
|
1844
1847
|
/**
|
|
1845
|
-
* A
|
|
1848
|
+
* A convenient method to log that the user saw the given Content Cards. This method is equivalent to
|
|
1846
1849
|
* calling [`logCardImpressions` method with `forContentCards` param set to true.
|
|
1847
1850
|
* This is done automatically when you use Braze's display module and should only be called
|
|
1848
1851
|
* if you're bypassing that and manually building the DOM for displaying content cards in
|
|
@@ -2005,7 +2008,7 @@
|
|
|
2005
2008
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2006
2009
|
*
|
|
2007
2010
|
* ```
|
|
2008
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
2011
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.8/service-worker.js');
|
|
2009
2012
|
* ```
|
|
2010
2013
|
*
|
|
2011
2014
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2138,10 +2141,11 @@
|
|
|
2138
2141
|
* regardless of whether new cards are available, you should use the `successCallback` of `requestContentCardsRefresh`.
|
|
2139
2142
|
*
|
|
2140
2143
|
* @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel the subscription.
|
|
2144
|
+
* Returns undefined if the SDK has not been initialized.
|
|
2141
2145
|
*/
|
|
2142
2146
|
export function subscribeToContentCardsUpdates(
|
|
2143
2147
|
subscriber: (cards: ContentCards) => void
|
|
2144
|
-
): string;
|
|
2148
|
+
): string | undefined;
|
|
2145
2149
|
|
|
2146
2150
|
/**
|
|
2147
2151
|
* Subscribe to news feed updates. The subscriber callback will be called whenever the news feed is updated.
|
|
@@ -2245,15 +2249,17 @@
|
|
|
2245
2249
|
* Subscribe to feature flag updates. The subscriber callback will be called whenever feature flags are updated. This method
|
|
2246
2250
|
* should be called before calling `openSession`.
|
|
2247
2251
|
*
|
|
2248
|
-
* @param subscriber - The callback function to handle new feature flags. This function
|
|
2249
|
-
*
|
|
2252
|
+
* @param subscriber - The callback function to handle new feature flags. This function is always called first with the
|
|
2253
|
+
* available cached list of `FeatureFlag` objects, and will also be called when feature flag updates are available.
|
|
2254
|
+
* If you want to be notified when a refresh has completed
|
|
2250
2255
|
* regardless of whether new feature flags are available, you should use the `successCallback` of `refreshFeatureFlags`.
|
|
2251
2256
|
*
|
|
2252
2257
|
* @returns The identifier of the subscription created. This can be passed to `removeSubscription` to cancel the subscription.
|
|
2258
|
+
* Returns undefined if the SDK has not been initialized.
|
|
2253
2259
|
*/
|
|
2254
2260
|
export function subscribeToFeatureFlagsUpdates(
|
|
2255
2261
|
subscriber: (featureFlags: FeatureFlag[]) => void
|
|
2256
|
-
): string;
|
|
2262
|
+
): string | undefined;
|
|
2257
2263
|
|
|
2258
2264
|
/**
|
|
2259
2265
|
* Gets all available feature flags.
|
|
@@ -2358,7 +2364,7 @@
|
|
|
2358
2364
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2359
2365
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2360
2366
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2361
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
2367
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.8/service-worker.js');` or by including the content
|
|
2362
2368
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2363
2369
|
*/
|
|
2364
2370
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import je from "./encoding-utils.js";
|
|
2
2
|
import { EventTypes as ve, InternalEventTypes as De } from "./event-types.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const r = {
|
|
3
|
+
import Ie from "./guid.js";
|
|
4
|
+
import Be from "./indexed-db-adapter.js";
|
|
5
|
+
import Ae from "./logger.js";
|
|
6
|
+
import Ge from "./supported-options.js";
|
|
7
|
+
const r = { xn: je, q: ve, Cr: De, Z: Ie, xt: Be, zt: Be.ep, j: Ae, xo: Ge };
|
|
8
8
|
export default r;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
const ve = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
du: "pc",
|
|
5
|
+
dc: "ca",
|
|
6
|
+
ka: "i",
|
|
7
|
+
Is: "ie",
|
|
8
|
+
P: "cci",
|
|
9
|
+
T: "ccic",
|
|
10
|
+
$: "ccc",
|
|
11
|
+
H: "ccd",
|
|
12
|
+
Wl: "ss",
|
|
13
|
+
xl: "se",
|
|
14
|
+
_i: "si",
|
|
15
15
|
Ii: "sc",
|
|
16
|
-
|
|
16
|
+
Mi: "sbc",
|
|
17
17
|
Ze: "sfe",
|
|
18
18
|
ro: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
au: "lr",
|
|
20
|
+
Zh: "uae",
|
|
21
|
+
R: "ci",
|
|
22
|
+
B: "cc",
|
|
23
|
+
gu: "lcaa",
|
|
24
|
+
fu: "lcar",
|
|
25
|
+
Rn: "inc",
|
|
26
|
+
Bn: "add",
|
|
27
|
+
Ln: "rem",
|
|
28
|
+
Fn: "set",
|
|
29
|
+
$n: "ncam",
|
|
30
|
+
pu: "sgu"
|
|
31
31
|
},
|
|
32
|
-
De = {
|
|
32
|
+
De = { Ar: "feed_displayed", Cc: "content_cards_displayed" };
|
|
33
33
|
export { ve as EventTypes, De as InternalEventTypes };
|
package/shared-lib/guid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const Ie = {
|
|
2
|
+
Y: () => {
|
|
3
3
|
const t = t => {
|
|
4
4
|
const e = (Math.random().toString(16) + "000000000").substr(2, 8);
|
|
5
5
|
return t ? "-" + e.substr(0, 4) + "-" + e.substr(4, 4) : e;
|
|
@@ -7,4 +7,4 @@ const Be = {
|
|
|
7
7
|
return t() + t(!0) + t(!0) + t();
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
export default
|
|
10
|
+
export default Ie;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Be {
|
|
2
2
|
constructor(t, e) {
|
|
3
|
-
(this.
|
|
4
|
-
(this.
|
|
5
|
-
(this.
|
|
3
|
+
(this.nd = "undefined" == typeof window ? self : window),
|
|
4
|
+
(this.od = t),
|
|
5
|
+
(this.sd = e);
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
if ("indexedDB" in this.
|
|
7
|
+
dd() {
|
|
8
|
+
if ("indexedDB" in this.nd) return this.nd.indexedDB;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
ud() {
|
|
11
11
|
try {
|
|
12
|
-
if (null == this.
|
|
12
|
+
if (null == this.dd()) return !1;
|
|
13
13
|
{
|
|
14
|
-
const t = this.
|
|
14
|
+
const t = this.dd().open("Braze IndexedDB Support Test");
|
|
15
15
|
if (
|
|
16
16
|
((t.onupgradeneeded = () => t.result.close()),
|
|
17
17
|
(t.onsuccess = () => t.result.close()),
|
|
@@ -20,7 +20,7 @@ export default class Ae {
|
|
|
20
20
|
const t = window.chrome || window.browser || window.msBrowser;
|
|
21
21
|
if (t && t.runtime && t.runtime.id)
|
|
22
22
|
return (
|
|
23
|
-
this.
|
|
23
|
+
this.sd.info(
|
|
24
24
|
"Not using IndexedDB for storage because we are running inside an extension"
|
|
25
25
|
),
|
|
26
26
|
!1
|
|
@@ -30,45 +30,45 @@ export default class Ae {
|
|
|
30
30
|
}
|
|
31
31
|
} catch (t) {
|
|
32
32
|
return (
|
|
33
|
-
this.
|
|
33
|
+
this.sd.info(
|
|
34
34
|
"Not using IndexedDB for storage due to following error: " + t
|
|
35
35
|
),
|
|
36
36
|
!1
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
const n = this.
|
|
40
|
+
fd(t, e) {
|
|
41
|
+
const n = this.dd().open(this.od.ad, this.od.VERSION);
|
|
42
42
|
if (null == n) return "function" == typeof e && e(), !1;
|
|
43
43
|
const o = this;
|
|
44
44
|
return (
|
|
45
45
|
(n.onupgradeneeded = t => {
|
|
46
|
-
o.
|
|
47
|
-
"Upgrading indexedDB " + o.
|
|
46
|
+
o.sd.info(
|
|
47
|
+
"Upgrading indexedDB " + o.od.ad + " to v" + o.od.VERSION + "..."
|
|
48
48
|
);
|
|
49
49
|
const e = t.target.result;
|
|
50
|
-
for (const t in o.
|
|
51
|
-
o.
|
|
52
|
-
!e.objectStoreNames.contains(o.
|
|
53
|
-
e.createObjectStore(o.
|
|
50
|
+
for (const t in o.od.Jt)
|
|
51
|
+
o.od.Jt.hasOwnProperty(t) &&
|
|
52
|
+
!e.objectStoreNames.contains(o.od.Jt[t]) &&
|
|
53
|
+
e.createObjectStore(o.od.Jt[t]);
|
|
54
54
|
}),
|
|
55
55
|
(n.onsuccess = n => {
|
|
56
56
|
const i = n.target.result;
|
|
57
57
|
(i.onversionchange = () => {
|
|
58
58
|
i.close(),
|
|
59
59
|
"function" == typeof e && e(),
|
|
60
|
-
o.
|
|
60
|
+
o.sd.error(
|
|
61
61
|
"Needed to close the database unexpectedly because of an upgrade in another tab"
|
|
62
62
|
);
|
|
63
63
|
}),
|
|
64
64
|
t(i);
|
|
65
65
|
}),
|
|
66
66
|
(n.onerror = t => (
|
|
67
|
-
o.
|
|
67
|
+
o.sd.info(
|
|
68
68
|
"Could not open indexedDB " +
|
|
69
|
-
o.
|
|
69
|
+
o.od.ad +
|
|
70
70
|
" v" +
|
|
71
|
-
o.
|
|
71
|
+
o.od.VERSION +
|
|
72
72
|
": " +
|
|
73
73
|
t.target.errorCode
|
|
74
74
|
),
|
|
@@ -79,18 +79,18 @@ export default class Ae {
|
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
setItem(t, e, n, o, i) {
|
|
82
|
-
if (!this.
|
|
82
|
+
if (!this.ud()) return "function" == typeof i && i(), !1;
|
|
83
83
|
const r = this;
|
|
84
|
-
return this.
|
|
84
|
+
return this.fd(s => {
|
|
85
85
|
if (!s.objectStoreNames.contains(t))
|
|
86
86
|
return (
|
|
87
|
-
r.
|
|
87
|
+
r.sd.error(
|
|
88
88
|
"Could not store object " +
|
|
89
89
|
e +
|
|
90
90
|
" in " +
|
|
91
91
|
t +
|
|
92
92
|
" on indexedDB " +
|
|
93
|
-
r.
|
|
93
|
+
r.od.ad +
|
|
94
94
|
" - " +
|
|
95
95
|
t +
|
|
96
96
|
" is not a valid objectStore"
|
|
@@ -102,13 +102,13 @@ export default class Ae {
|
|
|
102
102
|
d.oncomplete = () => s.close();
|
|
103
103
|
const u = d.objectStore(t).put(n, e);
|
|
104
104
|
(u.onerror = () => {
|
|
105
|
-
r.
|
|
105
|
+
r.sd.error(
|
|
106
106
|
"Could not store object " +
|
|
107
107
|
e +
|
|
108
108
|
" in " +
|
|
109
109
|
t +
|
|
110
110
|
" on indexedDB " +
|
|
111
|
-
r.
|
|
111
|
+
r.od.ad
|
|
112
112
|
),
|
|
113
113
|
"function" == typeof i && i();
|
|
114
114
|
}),
|
|
@@ -118,18 +118,18 @@ export default class Ae {
|
|
|
118
118
|
}, i);
|
|
119
119
|
}
|
|
120
120
|
getItem(t, e, n) {
|
|
121
|
-
if (!this.
|
|
121
|
+
if (!this.ud()) return !1;
|
|
122
122
|
const o = this;
|
|
123
|
-
return this.
|
|
123
|
+
return this.fd(i => {
|
|
124
124
|
if (!i.objectStoreNames.contains(t))
|
|
125
125
|
return (
|
|
126
|
-
o.
|
|
126
|
+
o.sd.error(
|
|
127
127
|
"Could not retrieve object " +
|
|
128
128
|
e +
|
|
129
129
|
" in " +
|
|
130
130
|
t +
|
|
131
131
|
" on indexedDB " +
|
|
132
|
-
o.
|
|
132
|
+
o.od.ad +
|
|
133
133
|
" - " +
|
|
134
134
|
t +
|
|
135
135
|
" is not a valid objectStore"
|
|
@@ -140,13 +140,13 @@ export default class Ae {
|
|
|
140
140
|
r.oncomplete = () => i.close();
|
|
141
141
|
const s = r.objectStore(t).get(e);
|
|
142
142
|
(s.onerror = () => {
|
|
143
|
-
o.
|
|
143
|
+
o.sd.error(
|
|
144
144
|
"Could not retrieve object " +
|
|
145
145
|
e +
|
|
146
146
|
" in " +
|
|
147
147
|
t +
|
|
148
148
|
" on indexedDB " +
|
|
149
|
-
o.
|
|
149
|
+
o.od.ad
|
|
150
150
|
);
|
|
151
151
|
}),
|
|
152
152
|
(s.onsuccess = t => {
|
|
@@ -156,16 +156,16 @@ export default class Ae {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
hr(t, e, n) {
|
|
159
|
-
if (!this.
|
|
159
|
+
if (!this.ud()) return "function" == typeof n && n(), !1;
|
|
160
160
|
const o = this;
|
|
161
|
-
return this.
|
|
161
|
+
return this.fd(i => {
|
|
162
162
|
if (!i.objectStoreNames.contains(t))
|
|
163
163
|
return (
|
|
164
|
-
o.
|
|
164
|
+
o.sd.error(
|
|
165
165
|
"Could not retrieve last record from " +
|
|
166
166
|
t +
|
|
167
167
|
" on indexedDB " +
|
|
168
|
-
o.
|
|
168
|
+
o.od.ad +
|
|
169
169
|
" - " +
|
|
170
170
|
t +
|
|
171
171
|
" is not a valid objectStore"
|
|
@@ -177,8 +177,8 @@ export default class Ae {
|
|
|
177
177
|
r.oncomplete = () => i.close();
|
|
178
178
|
const s = r.objectStore(t).openCursor(null, "prev");
|
|
179
179
|
(s.onerror = () => {
|
|
180
|
-
o.
|
|
181
|
-
"Could not open cursor for " + t + " on indexedDB " + o.
|
|
180
|
+
o.sd.error(
|
|
181
|
+
"Could not open cursor for " + t + " on indexedDB " + o.od.ad
|
|
182
182
|
),
|
|
183
183
|
"function" == typeof n && n();
|
|
184
184
|
}),
|
|
@@ -191,18 +191,18 @@ export default class Ae {
|
|
|
191
191
|
}, n);
|
|
192
192
|
}
|
|
193
193
|
br(t, e) {
|
|
194
|
-
if (!this.
|
|
194
|
+
if (!this.ud()) return !1;
|
|
195
195
|
const n = this;
|
|
196
|
-
return this.
|
|
196
|
+
return this.fd(o => {
|
|
197
197
|
if (!o.objectStoreNames.contains(t))
|
|
198
198
|
return (
|
|
199
|
-
n.
|
|
199
|
+
n.sd.error(
|
|
200
200
|
"Could not delete record " +
|
|
201
201
|
e +
|
|
202
202
|
" from " +
|
|
203
203
|
t +
|
|
204
204
|
" on indexedDB " +
|
|
205
|
-
n.
|
|
205
|
+
n.od.ad +
|
|
206
206
|
" - " +
|
|
207
207
|
t +
|
|
208
208
|
" is not a valid objectStore"
|
|
@@ -212,28 +212,28 @@ export default class Ae {
|
|
|
212
212
|
const i = o.transaction([t], "readwrite");
|
|
213
213
|
i.oncomplete = () => o.close();
|
|
214
214
|
i.objectStore(t).delete(e).onerror = () => {
|
|
215
|
-
n.
|
|
215
|
+
n.sd.error(
|
|
216
216
|
"Could not delete record " +
|
|
217
217
|
e +
|
|
218
218
|
" from " +
|
|
219
219
|
t +
|
|
220
220
|
" on indexedDB " +
|
|
221
|
-
n.
|
|
221
|
+
n.od.ad
|
|
222
222
|
);
|
|
223
223
|
};
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
|
-
|
|
227
|
-
if (!this.
|
|
226
|
+
Mt(t, e) {
|
|
227
|
+
if (!this.ud()) return !1;
|
|
228
228
|
const n = this;
|
|
229
|
-
return this.
|
|
229
|
+
return this.fd(o => {
|
|
230
230
|
if (!o.objectStoreNames.contains(t))
|
|
231
231
|
return (
|
|
232
|
-
n.
|
|
232
|
+
n.sd.error(
|
|
233
233
|
"Could not retrieve objects from " +
|
|
234
234
|
t +
|
|
235
235
|
" on indexedDB " +
|
|
236
|
-
n.
|
|
236
|
+
n.od.ad +
|
|
237
237
|
" - " +
|
|
238
238
|
t +
|
|
239
239
|
" is not a valid objectStore"
|
|
@@ -247,15 +247,15 @@ export default class Ae {
|
|
|
247
247
|
d = [];
|
|
248
248
|
(s.onerror = () => {
|
|
249
249
|
d.length > 0
|
|
250
|
-
? (n.
|
|
250
|
+
? (n.sd.info(
|
|
251
251
|
"Cursor closed midway through for " +
|
|
252
252
|
t +
|
|
253
253
|
" on indexedDB " +
|
|
254
|
-
n.
|
|
254
|
+
n.od.ad
|
|
255
255
|
),
|
|
256
256
|
e(d))
|
|
257
|
-
: n.
|
|
258
|
-
"Could not open cursor for " + t + " on indexedDB " + n.
|
|
257
|
+
: n.sd.error(
|
|
258
|
+
"Could not open cursor for " + t + " on indexedDB " + n.od.ad
|
|
259
259
|
);
|
|
260
260
|
}),
|
|
261
261
|
(s.onsuccess = t => {
|
|
@@ -272,43 +272,43 @@ export default class Ae {
|
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
clearData() {
|
|
275
|
-
if (!this.
|
|
275
|
+
if (!this.ud()) return !1;
|
|
276
276
|
const t = [];
|
|
277
|
-
for (const e in this.
|
|
278
|
-
this.
|
|
279
|
-
this.
|
|
280
|
-
t.push(this.
|
|
277
|
+
for (const e in this.od.Jt)
|
|
278
|
+
this.od.Jt.hasOwnProperty(e) &&
|
|
279
|
+
this.od.Jt[e] !== this.od.Jt.oe &&
|
|
280
|
+
t.push(this.od.Jt[e]);
|
|
281
281
|
const e = this;
|
|
282
|
-
return this.
|
|
282
|
+
return this.fd(function(n) {
|
|
283
283
|
const o = n.transaction(t, "readwrite");
|
|
284
284
|
o.oncomplete = () => n.close();
|
|
285
285
|
for (let n = 0; n < t.length; n++) {
|
|
286
286
|
const i = t[n];
|
|
287
287
|
o.objectStore(i).clear().onerror = function() {
|
|
288
|
-
e.
|
|
289
|
-
"Could not clear " + this.source.name + " on indexedDB " + e.
|
|
288
|
+
e.sd.error(
|
|
289
|
+
"Could not clear " + this.source.name + " on indexedDB " + e.od.ad
|
|
290
290
|
);
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
o.onerror = function() {
|
|
294
|
-
e.
|
|
294
|
+
e.sd.error("Could not clear object stores on indexedDB " + e.od.ad);
|
|
295
295
|
};
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
Be.ep = {
|
|
300
300
|
Ft: {
|
|
301
|
-
|
|
301
|
+
ad: "AppboyServiceWorkerAsyncStorage",
|
|
302
302
|
VERSION: 6,
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
Jt: {
|
|
304
|
+
Sa: "data",
|
|
305
|
+
kr: "pushClicks",
|
|
306
306
|
cu: "pushSubscribed",
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
hd: "fallbackDevice",
|
|
308
|
+
qt: "cardUpdates",
|
|
309
309
|
oe: "optOut",
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
yr: "pendingData",
|
|
311
|
+
kh: "sdkAuthenticationSignature"
|
|
312
312
|
},
|
|
313
313
|
se: 1
|
|
314
314
|
}
|