@braze/web-sdk 4.5.1 → 4.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/README.md +1 -1
- package/index.d.ts +49 -8
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +7 -7
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +14 -14
- package/shared-lib/guid.js +2 -2
- package/shared-lib/indexed-db-adapter.js +3 -3
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +15 -15
- package/src/Card/index.js +1 -0
- package/src/Card/log-content-card-click.js +4 -0
- package/src/FeatureFlags/feature-flag-factory.js +13 -5
- package/src/FeatureFlags/feature-flag.js +36 -8
- package/src/FeatureFlags/feature-flags-provider.js +58 -33
- package/src/FeatureFlags/get-all-feature-flags.js +3 -3
- package/src/FeatureFlags/get-feature-flag.js +5 -5
- package/src/FeatureFlags/index.js +1 -0
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +3 -3
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/log-feed-displayed.js +1 -1
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/ui/show-feed.js +2 -2
- package/src/InAppMessage/display/html-message-to-html.js +3 -3
- package/src/InAppMessage/display/in-app-message-to-html.js +101 -86
- package/src/InAppMessage/display/modal-utils.js +9 -9
- package/src/InAppMessage/in-app-message-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager-factory.js +3 -3
- package/src/InAppMessage/in-app-message-manager.js +52 -52
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +68 -68
- package/src/InAppMessage/models/modal-message.js +2 -2
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- package/src/InAppMessage/models/templated-in-app-message.js +4 -4
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +24 -21
- package/src/Push/push-manager.js +54 -54
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +13 -13
- package/src/common/base-feed.js +1 -1
- package/src/common/feed-display.js +22 -22
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/managers/auth-manager.js +23 -23
- package/src/managers/braze-instance.js +93 -93
- package/src/managers/device-manager.js +2 -2
- package/src/managers/network-manager.js +42 -42
- package/src/managers/server-config-manager.js +9 -9
- package/src/managers/session-manager.js +27 -27
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +61 -61
- package/src/managers/subscription-manager.js +6 -6
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +2 -2
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +6 -6
- package/src/models/push-token.js +3 -3
- package/src/models/server-config.js +3 -3
- package/src/request-controller.js +52 -52
- package/src/triggers/models/filter-set.js +2 -2
- package/src/triggers/models/filter.js +34 -34
- package/src/triggers/models/in-app-message-click-data.js +6 -6
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +8 -8
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +30 -30
- package/src/triggers/triggers-provider-factory.js +2 -2
- package/src/triggers/triggers-provider.js +37 -37
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +2 -2
- package/src/util/dom-utils.js +8 -8
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +3 -3
- package/src/util/window-utils.js +1 -1
package/README.md
CHANGED
|
@@ -8,5 +8,5 @@ Note: The Braze Web SDK is meant to be used client-side in a web application and
|
|
|
8
8
|
|
|
9
9
|
See the [Public Github Repo](https://github.com/braze-inc/braze-web-sdk#readme) for getting started instructions or [our documentation pages](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/initial_sdk_setup/) for use-case based documentation.
|
|
10
10
|
|
|
11
|
-
(c) Braze, Inc.
|
|
11
|
+
(c) Braze, Inc. 2023 - http://braze.com
|
|
12
12
|
License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v4.
|
|
2
|
+
* Type definitions for @braze/web-sdk v4.6.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
|
-
* (c) Braze, Inc.
|
|
4
|
+
* (c) Braze, Inc. 2023 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -1496,7 +1496,7 @@
|
|
|
1496
1496
|
subscribeToClickedEvent(subscriber: () => void): string;
|
|
1497
1497
|
}
|
|
1498
1498
|
|
|
1499
|
-
export
|
|
1499
|
+
export class FeatureFlag {
|
|
1500
1500
|
/** Indicates whether or not this feature flag is enabled. */
|
|
1501
1501
|
enabled: boolean;
|
|
1502
1502
|
|
|
@@ -1505,6 +1505,36 @@
|
|
|
1505
1505
|
|
|
1506
1506
|
/** The ID for this feature flag. */
|
|
1507
1507
|
id: string;
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Get value of a feature flag property of type string.
|
|
1511
|
+
*
|
|
1512
|
+
* @param key - The key of the property.
|
|
1513
|
+
*
|
|
1514
|
+
* @returns The value of the property if the key is found and is of type string.
|
|
1515
|
+
* If the key is not found or if there is a type mismatch, this method will return a null.
|
|
1516
|
+
*/
|
|
1517
|
+
getStringProperty(key: string): string | null;
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Get value of a feature flag property of type number.
|
|
1521
|
+
*
|
|
1522
|
+
* @param key - The key of the property.
|
|
1523
|
+
*
|
|
1524
|
+
* @returns The value of the property if the key is found and is of type number.
|
|
1525
|
+
* If the key is not found or if there is a type mismatch, this method will return a null.
|
|
1526
|
+
*/
|
|
1527
|
+
getNumberProperty(key: string): number | null;
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Get value of a feature flag property of type boolean.
|
|
1531
|
+
*
|
|
1532
|
+
* @param key - The key of the property.
|
|
1533
|
+
*
|
|
1534
|
+
* @returns The value of the property if the key is found and is of type boolean.
|
|
1535
|
+
* If the key is not found or if there is a type mismatch, this method will return a null.
|
|
1536
|
+
*/
|
|
1537
|
+
getBooleanProperty(key: string): boolean | null;
|
|
1508
1538
|
}
|
|
1509
1539
|
|
|
1510
1540
|
/**
|
|
@@ -1802,9 +1832,20 @@
|
|
|
1802
1832
|
*
|
|
1803
1833
|
* @returns Whether or not the event was successfully logged (to be flushed later).
|
|
1804
1834
|
*/
|
|
1805
|
-
export function logContentCardImpressions(
|
|
1806
|
-
|
|
1807
|
-
|
|
1835
|
+
export function logContentCardImpressions(contentCards: Card[]): boolean;
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* A convenient method to log when user clicks on a Content Card. This method is equivalent to
|
|
1839
|
+
* calling [`logCardClick` method with `forContentCards` param set to true.
|
|
1840
|
+
* This is done automatically when you use Braze's display module and should only be called
|
|
1841
|
+
* if you're bypassing that and manually building the DOM for displaying content cards in
|
|
1842
|
+
* your own code.
|
|
1843
|
+
*
|
|
1844
|
+
* @param contentCard - the `Card` object that received a click
|
|
1845
|
+
*
|
|
1846
|
+
* @returns Whether or not the event was successfully logged (to be flushed later).
|
|
1847
|
+
*/
|
|
1848
|
+
export function logContentCardClick(contentCard: Card): boolean;
|
|
1808
1849
|
|
|
1809
1850
|
/**
|
|
1810
1851
|
* @deprecated This method has been deprecated and is currently a no-op.
|
|
@@ -1944,7 +1985,7 @@
|
|
|
1944
1985
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
1945
1986
|
*
|
|
1946
1987
|
* ```
|
|
1947
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
1988
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.6/service-worker.js');
|
|
1948
1989
|
* ```
|
|
1949
1990
|
*
|
|
1950
1991
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2297,7 +2338,7 @@
|
|
|
2297
2338
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2298
2339
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2299
2340
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2300
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
2341
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.6/service-worker.js');` or by including the content
|
|
2301
2342
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2302
2343
|
*/
|
|
2303
2344
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { EventTypes as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const r = {
|
|
1
|
+
import je from "./encoding-utils.js";
|
|
2
|
+
import { EventTypes as ve, InternalEventTypes as De } from "./event-types.js";
|
|
3
|
+
import Be from "./guid.js";
|
|
4
|
+
import Ae from "./indexed-db-adapter.js";
|
|
5
|
+
import Ge from "./logger.js";
|
|
6
|
+
import Oe from "./supported-options.js";
|
|
7
|
+
const r = { Dn: je, A: ve, Ar: De, it: Be, qt: Ae, xt: Ae.ep, D: Ge, Go: Oe };
|
|
8
8
|
export default r;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const je = {
|
|
2
|
+
Pn: function(t) {
|
|
3
3
|
const r = (t + "=".repeat((4 - (t.length % 4)) % 4))
|
|
4
4
|
.replace(/\-/g, "+")
|
|
5
5
|
.replace(/_/g, "/"),
|
|
@@ -9,4 +9,4 @@ const ve = {
|
|
|
9
9
|
return o;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
export default
|
|
12
|
+
export default je;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ve = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
4
|
xl: "pc",
|
|
5
5
|
cc: "ca",
|
|
6
|
-
|
|
6
|
+
Ba: "i",
|
|
7
7
|
qs: "ie",
|
|
8
8
|
T: "cci",
|
|
9
9
|
W: "ccic",
|
|
10
10
|
_: "ccc",
|
|
11
11
|
L: "ccd",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
_h: "ss",
|
|
13
|
+
gh: "se",
|
|
14
|
+
bi: "si",
|
|
15
|
+
yi: "sc",
|
|
16
|
+
ji: "sbc",
|
|
17
|
+
vi: "sfe",
|
|
18
18
|
ro: "iec",
|
|
19
19
|
Ul: "lr",
|
|
20
20
|
Ol: "uae",
|
|
@@ -22,11 +22,11 @@ const De = {
|
|
|
22
22
|
F: "cc",
|
|
23
23
|
Bl: "lcaa",
|
|
24
24
|
Wl: "lcar",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
Tn: "inc",
|
|
26
|
+
En: "add",
|
|
27
|
+
Fn: "rem",
|
|
28
|
+
Un: "set",
|
|
29
29
|
Gl: "sgu"
|
|
30
30
|
},
|
|
31
|
-
|
|
32
|
-
export {
|
|
31
|
+
De = { qr: "feed_displayed", dc: "content_cards_displayed" };
|
|
32
|
+
export { ve as EventTypes, De as InternalEventTypes };
|
package/shared-lib/guid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default class
|
|
1
|
+
export default class Ae {
|
|
2
2
|
constructor(t, e) {
|
|
3
3
|
(this.td = "undefined" == typeof window ? self : window),
|
|
4
4
|
(this.ed = t),
|
|
@@ -296,7 +296,7 @@ export default class Ge {
|
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
Ae.ep = {
|
|
300
300
|
Ft: {
|
|
301
301
|
dd: "AppboyServiceWorkerAsyncStorage",
|
|
302
302
|
VERSION: 6,
|
|
@@ -308,7 +308,7 @@ Ge.ep = {
|
|
|
308
308
|
Mt: "cardUpdates",
|
|
309
309
|
oe: "optOut",
|
|
310
310
|
$r: "pendingData",
|
|
311
|
-
|
|
311
|
+
Vn: "sdkAuthenticationSignature"
|
|
312
312
|
},
|
|
313
313
|
se: 1
|
|
314
314
|
}
|
package/shared-lib/logger.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Ge = {
|
|
2
2
|
init: function(n) {
|
|
3
|
-
(void 0 === n && void 0 !==
|
|
3
|
+
(void 0 === n && void 0 !== Ge.zg) || (Ge.zg = !!n), Ge.Eg || (Ge.Eg = !0);
|
|
4
4
|
},
|
|
5
5
|
destroy: function() {
|
|
6
|
-
(
|
|
6
|
+
(Ge.Eg = !1), (Ge.zg = void 0), (Ge.nd = void 0);
|
|
7
7
|
},
|
|
8
8
|
setLogger: function(n) {
|
|
9
9
|
"function" == typeof n
|
|
10
|
-
? (
|
|
11
|
-
:
|
|
10
|
+
? (Ge.init(), (Ge.nd = n))
|
|
11
|
+
: Ge.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
|
+
Ge.init(),
|
|
15
|
+
Ge.zg
|
|
16
|
+
? (console.log("Disabling Braze logging"), (Ge.zg = !1))
|
|
17
|
+
: (console.log("Enabled Braze logging"), (Ge.zg = !0));
|
|
18
18
|
},
|
|
19
19
|
info: function(n) {
|
|
20
|
-
if (
|
|
20
|
+
if (Ge.zg) {
|
|
21
21
|
const o = "Braze: " + n;
|
|
22
|
-
null !=
|
|
22
|
+
null != Ge.nd ? Ge.nd(o) : console.log(o);
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
warn: function(n) {
|
|
26
|
-
if (
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v4.
|
|
28
|
-
null !=
|
|
26
|
+
if (Ge.zg) {
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v4.6.0)";
|
|
28
|
+
null != Ge.nd ? Ge.nd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function(n) {
|
|
32
|
-
if (
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v4.
|
|
34
|
-
null !=
|
|
32
|
+
if (Ge.zg) {
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v4.6.0)";
|
|
34
|
+
null != Ge.nd ? Ge.nd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
export default
|
|
38
|
+
export default Ge;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
ho: "allowCrawlerActivity",
|
|
3
|
+
po: "baseUrl",
|
|
4
|
+
Eo: "noCookies",
|
|
5
|
+
_o: "devicePropertyAllowlist",
|
|
6
6
|
ta: "disablePushTokenMaintenance",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Io: "enableLogging",
|
|
8
|
+
Ao: "enableSdkAuthentication",
|
|
9
9
|
ia: "manageServiceWorkerExternally",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
So: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
No: "sessionTimeoutInSeconds",
|
|
12
|
+
wo: "appVersion",
|
|
13
13
|
na: "serviceWorkerLocation",
|
|
14
14
|
ra: "safariWebsitePushId",
|
|
15
|
-
|
|
15
|
+
zn: "localization",
|
|
16
16
|
ao: "contentSecurityNonce",
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
To: "enableHtmlInAppMessages",
|
|
18
|
+
Oo: "allowUserSuppliedJavascript",
|
|
19
19
|
no: "inAppMessageZIndex",
|
|
20
20
|
lo: "openInAppMessagesInNewTab",
|
|
21
21
|
en: "openNewsFeedCardsInNewTab",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
eh: "requireExplicitInAppMessageDismissal",
|
|
23
|
+
vo: "doNotLoadFontAwesome",
|
|
24
|
+
Co: "sdkFlavor",
|
|
25
25
|
tn: "openCardsInNewTab"
|
|
26
26
|
};
|
package/src/Card/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { logCardClick } from "./log-card-click.js";
|
|
|
3
3
|
export { logCardDismissal } from "./log-card-dismissal.js";
|
|
4
4
|
export { logCardImpressions } from "./log-card-impressions.js";
|
|
5
5
|
export { logContentCardImpressions } from "./log-content-card-impressions.js";
|
|
6
|
+
export { logContentCardClick } from "./log-content-card-click.js";
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
|
-
import
|
|
2
|
+
import FeatureFlag from "./feature-flag.js";
|
|
3
3
|
export function newFeatureFlagFromJson(e) {
|
|
4
|
-
if (e[
|
|
5
|
-
return new
|
|
4
|
+
if (e[FeatureFlag.At.ns] && "boolean" == typeof e[FeatureFlag.At.Fe])
|
|
5
|
+
return new FeatureFlag(
|
|
6
|
+
e[FeatureFlag.At.ns],
|
|
7
|
+
e[FeatureFlag.At.Fe],
|
|
8
|
+
e[FeatureFlag.At.we]
|
|
9
|
+
);
|
|
6
10
|
r.D.info(`Unable to create feature flag from ${JSON.stringify(e, null, 2)}`);
|
|
7
11
|
}
|
|
8
12
|
export function newFeatureFlagFromSerializedValue(e) {
|
|
9
|
-
if (e[
|
|
10
|
-
return new
|
|
13
|
+
if (e[FeatureFlag.hs.ns] && "boolean" == typeof e[FeatureFlag.hs.Fe])
|
|
14
|
+
return new FeatureFlag(
|
|
15
|
+
e[FeatureFlag.hs.ns],
|
|
16
|
+
e[FeatureFlag.hs.Fe],
|
|
17
|
+
e[FeatureFlag.hs.we]
|
|
18
|
+
);
|
|
11
19
|
r.D.info(
|
|
12
20
|
`Unable to deserialize feature flag from ${JSON.stringify(e, null, 2)}`
|
|
13
21
|
);
|
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
|
+
export default class FeatureFlag {
|
|
3
|
+
constructor(t, r = !1, e = {}) {
|
|
4
|
+
(this.id = t), (this.enabled = r), (this.properties = e);
|
|
5
|
+
}
|
|
6
|
+
getStringProperty(t) {
|
|
7
|
+
if (!this.yr(t)) return null;
|
|
8
|
+
const r = this.properties[t];
|
|
9
|
+
return this.Er(r, "string") ? r.value : null;
|
|
10
|
+
}
|
|
11
|
+
getNumberProperty(t) {
|
|
12
|
+
if (!this.yr(t)) return null;
|
|
13
|
+
const r = this.properties[t];
|
|
14
|
+
return this.Er(r, "number") ? r.value : null;
|
|
15
|
+
}
|
|
16
|
+
getBooleanProperty(t) {
|
|
17
|
+
if (!this.yr(t)) return null;
|
|
18
|
+
const r = this.properties[t];
|
|
19
|
+
return this.Er(r, "boolean") ? r.value : null;
|
|
4
20
|
}
|
|
5
21
|
ss() {
|
|
6
22
|
const t = {};
|
|
7
23
|
return (
|
|
8
|
-
(t[
|
|
9
|
-
(t[
|
|
10
|
-
(t[
|
|
24
|
+
(t[FeatureFlag.hs.ns] = this.id),
|
|
25
|
+
(t[FeatureFlag.hs.Fe] = this.enabled),
|
|
26
|
+
(t[FeatureFlag.hs.we] = this.properties),
|
|
11
27
|
t
|
|
12
28
|
);
|
|
13
29
|
}
|
|
30
|
+
yr(t) {
|
|
31
|
+
return (
|
|
32
|
+
!(!this.properties || !this.properties[t]) ||
|
|
33
|
+
(r.D.info(`${t} not found in feature flag properties.`), !1)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
Er(t, e) {
|
|
37
|
+
return (
|
|
38
|
+
(t.type === e && typeof t.value === e) ||
|
|
39
|
+
(r.D.info(`Property is not of type ${e}.`), !1)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
14
42
|
}
|
|
15
|
-
(
|
|
16
|
-
(
|
|
43
|
+
(FeatureFlag.hs = { ns: "id", Fe: "e", we: "pr" }),
|
|
44
|
+
(FeatureFlag.At = { ns: "id", Fe: "enabled", we: "properties" });
|
|
@@ -3,76 +3,101 @@ import y from "../common/base-provider.js";
|
|
|
3
3
|
import e from "../managers/braze-instance.js";
|
|
4
4
|
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
5
5
|
import u from "../managers/subscription-manager.js";
|
|
6
|
+
import { randomInclusive as tt } from "../util/math.js";
|
|
6
7
|
import b from "../util/net.js";
|
|
7
8
|
import {
|
|
8
|
-
newFeatureFlagFromJson as
|
|
9
|
-
newFeatureFlagFromSerializedValue as
|
|
9
|
+
newFeatureFlagFromJson as et,
|
|
10
|
+
newFeatureFlagFromSerializedValue as st
|
|
10
11
|
} from "./feature-flag-factory.js";
|
|
11
12
|
export default class er extends y {
|
|
12
|
-
constructor(t, s,
|
|
13
|
+
constructor(t, s, i) {
|
|
13
14
|
super(),
|
|
14
15
|
(this.gt = t),
|
|
15
16
|
(this.vt = s),
|
|
16
|
-
(this.h =
|
|
17
|
+
(this.h = i),
|
|
17
18
|
(this.he = new u()),
|
|
19
|
+
(this.ye = 10),
|
|
20
|
+
(this.Te = null),
|
|
18
21
|
e.jt(this.he);
|
|
19
22
|
}
|
|
20
23
|
Rs(t) {
|
|
21
|
-
if (this.gt.
|
|
22
|
-
this.
|
|
24
|
+
if (this.gt._e() && null != t && t.feature_flags) {
|
|
25
|
+
this.Re = [];
|
|
23
26
|
for (const e of t.feature_flags) {
|
|
24
|
-
let t =
|
|
25
|
-
t && this.
|
|
27
|
+
let t = et(e);
|
|
28
|
+
t && this.Re.push(t);
|
|
26
29
|
}
|
|
27
|
-
(this.
|
|
30
|
+
(this.De = new Date().getTime()), this.Ne(), this.he.St(this.Re);
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
xe() {
|
|
31
34
|
const t = this.h.I(o.q.ze) || {};
|
|
32
35
|
let e = {};
|
|
33
36
|
for (let s in t) {
|
|
34
|
-
let
|
|
35
|
-
|
|
37
|
+
let i = st(t[s]);
|
|
38
|
+
i && (e[i.id] = i);
|
|
36
39
|
}
|
|
37
40
|
return e;
|
|
38
41
|
}
|
|
39
42
|
Ws(t) {
|
|
40
43
|
return this.he.ut(t);
|
|
41
44
|
}
|
|
42
|
-
refreshFeatureFlags(t, e, s) {
|
|
43
|
-
if (!this.
|
|
44
|
-
return
|
|
45
|
-
this
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
refreshFeatureFlags(t, e, s, i) {
|
|
46
|
+
if (!this.Se(s))
|
|
47
|
+
return (
|
|
48
|
+
this.$e ||
|
|
49
|
+
(this.$e = this.gt.qe(() => {
|
|
50
|
+
this.refreshFeatureFlags(t, e);
|
|
51
|
+
})),
|
|
52
|
+
void ("function" == typeof e && e())
|
|
49
53
|
);
|
|
54
|
+
null == i && (i = !0), i && this.Me();
|
|
50
55
|
const r = this.vt.Ps({}, !0),
|
|
51
|
-
|
|
56
|
+
a = this.vt.Bs(r, !1, !0);
|
|
57
|
+
let h = !1;
|
|
52
58
|
this.vt.Gs(r, () => {
|
|
53
59
|
b.Hs({
|
|
54
60
|
url: `${this.vt.Ks()}/feature_flags/sync`,
|
|
55
|
-
headers:
|
|
61
|
+
headers: a,
|
|
56
62
|
data: r,
|
|
57
63
|
S: s => {
|
|
58
|
-
this.vt.Os(r, s)
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
if (!this.vt.Os(r, s))
|
|
65
|
+
return (h = !0), void ("function" == typeof e && e());
|
|
66
|
+
this.vt.Qs(), this.Rs(s), "function" == typeof t && t();
|
|
61
67
|
},
|
|
62
68
|
error: t => {
|
|
63
69
|
this.vt.Vs(t, "retrieving feature flags"),
|
|
70
|
+
(h = !0),
|
|
64
71
|
"function" == typeof e && e();
|
|
72
|
+
},
|
|
73
|
+
Ue: () => {
|
|
74
|
+
if (i && h && !this.ke) {
|
|
75
|
+
let i = this.Te;
|
|
76
|
+
(null == i || i < 1e3 * this.ye) && (i = 1e3 * this.ye),
|
|
77
|
+
this.Ae(Math.min(3e5, tt(1e3 * this.ye, 3 * i)), t, e, s);
|
|
78
|
+
}
|
|
65
79
|
}
|
|
66
80
|
});
|
|
67
81
|
});
|
|
68
82
|
}
|
|
69
|
-
|
|
83
|
+
Me() {
|
|
84
|
+
null != this.ke && (clearTimeout(this.ke), (this.ke = null));
|
|
85
|
+
}
|
|
86
|
+
Ae(t, e, s, i) {
|
|
87
|
+
null == t && (t = 1e3 * this.ye),
|
|
88
|
+
this.Me(),
|
|
89
|
+
(this.ke = setTimeout(() => {
|
|
90
|
+
this.refreshFeatureFlags(e, s, i);
|
|
91
|
+
}, t)),
|
|
92
|
+
(this.Te = t);
|
|
93
|
+
}
|
|
94
|
+
Se(t) {
|
|
70
95
|
if (!t) {
|
|
71
|
-
const t = parseFloat(this.gt
|
|
96
|
+
const t = parseFloat(this.gt.Be());
|
|
72
97
|
let e = !1;
|
|
73
98
|
if (!isNaN(t)) {
|
|
74
99
|
if (-1 === t) return r.D.info("Feature flag refreshes not allowed"), !1;
|
|
75
|
-
e = new Date().getTime() >= (this.
|
|
100
|
+
e = new Date().getTime() >= (this.De || 0) + 1e3 * t;
|
|
76
101
|
}
|
|
77
102
|
if (!e)
|
|
78
103
|
return (
|
|
@@ -80,15 +105,15 @@ export default class er extends y {
|
|
|
80
105
|
!1
|
|
81
106
|
);
|
|
82
107
|
}
|
|
83
|
-
return this.gt.
|
|
108
|
+
return this.gt._e();
|
|
84
109
|
}
|
|
85
|
-
|
|
110
|
+
Ne() {
|
|
86
111
|
const t = {};
|
|
87
|
-
for (let e = 0; e < this.
|
|
88
|
-
let s = this.
|
|
89
|
-
|
|
90
|
-
t[s.id] =
|
|
112
|
+
for (let e = 0; e < this.Re.length; e++) {
|
|
113
|
+
let s = this.Re[e],
|
|
114
|
+
i = s.ss();
|
|
115
|
+
t[s.id] = i;
|
|
91
116
|
}
|
|
92
|
-
this.h.B(o.q.ze, t), this.h.B(o.q.
|
|
117
|
+
this.h.B(o.q.ze, t), this.h.B(o.q.Ce, this.De);
|
|
93
118
|
}
|
|
94
119
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
import e from "../managers/braze-instance.js";
|
|
3
|
-
import { newFeatureFlagFromJson as
|
|
3
|
+
import { newFeatureFlagFromJson as et } from "./feature-flag-factory.js";
|
|
4
4
|
import ir from "./feature-flags-provider-factory.js";
|
|
5
5
|
export function getAllFeatureFlags() {
|
|
6
6
|
if (!e.rr()) return;
|
|
7
7
|
let t = [];
|
|
8
|
-
if (!e.ir().
|
|
8
|
+
if (!e.ir()._e()) return r.D.info("Feature flags are not enabled."), t;
|
|
9
9
|
const a = ir.er().xe();
|
|
10
|
-
for (let r in a) t.push(
|
|
10
|
+
for (let r in a) t.push(et(a[r]));
|
|
11
11
|
return t;
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
import e from "../managers/braze-instance.js";
|
|
3
|
-
import { newFeatureFlagFromJson as
|
|
4
|
-
import
|
|
3
|
+
import { newFeatureFlagFromJson as et } from "./feature-flag-factory.js";
|
|
4
|
+
import FeatureFlag from "./feature-flag.js";
|
|
5
5
|
import ir from "./feature-flags-provider-factory.js";
|
|
6
6
|
export function getFeatureFlag(a) {
|
|
7
7
|
if (!e.rr()) return;
|
|
8
|
-
if (!e.ir().
|
|
9
|
-
return r.D.info("Feature flags are not enabled."), new
|
|
8
|
+
if (!e.ir()._e())
|
|
9
|
+
return r.D.info("Feature flags are not enabled."), new FeatureFlag(a);
|
|
10
10
|
const t = ir.er().xe();
|
|
11
|
-
return t[a] ?
|
|
11
|
+
return t[a] ? et(t[a]) : new FeatureFlag(a);
|
|
12
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as FeatureFlag } from "./feature-flag.js";
|
|
1
2
|
export { refreshFeatureFlags } from "./refresh-feature-flags.js";
|
|
2
3
|
export { getFeatureFlag } from "./get-feature-flag.js";
|
|
3
4
|
export { subscribeToFeatureFlagsUpdates } from "./subscribe-to-feature-flags-updates.js";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
3
|
-
const
|
|
2
|
+
import ee from "./feed-provider.js";
|
|
3
|
+
const re = {
|
|
4
4
|
t: !1,
|
|
5
5
|
provider: null,
|
|
6
6
|
er: () => (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
re.o(),
|
|
8
|
+
re.provider || ((re.provider = new ee(e.l(), e.mr())), e.ar(re.provider)),
|
|
9
|
+
re.provider
|
|
10
10
|
),
|
|
11
11
|
o: () => {
|
|
12
|
-
|
|
12
|
+
re.t || (e.u(re), (re.t = !0));
|
|
13
13
|
},
|
|
14
14
|
destroy: () => {
|
|
15
|
-
(
|
|
15
|
+
(re.provider = null), (re.t = !1);
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
export default
|
|
18
|
+
export default re;
|