@braze/web-sdk 4.6.3 → 4.7.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 +13 -8
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +2 -2
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +18 -17
- package/shared-lib/indexed-db-adapter.js +2 -2
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +15 -15
- package/src/Core/handle-braze-action.js +40 -34
- package/src/Core/log-custom-event.js +2 -7
- package/src/Core/log-purchase.js +3 -3
- package/src/Core/wipe-data.js +2 -2
- package/src/FeatureFlags/feature-flag.js +33 -16
- package/src/FeatureFlags/feature-flags-provider.js +86 -75
- package/src/FeatureFlags/get-all-feature-flags.js +5 -5
- package/src/FeatureFlags/get-feature-flag.js +6 -6
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/types.js +1 -0
- package/src/Feed/feed-provider.js +17 -17
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +135 -120
- package/src/InAppMessage/display/in-app-message-to-html.js +21 -21
- package/src/InAppMessage/display/modal-utils.js +6 -6
- package/src/InAppMessage/in-app-message-factory.js +3 -3
- package/src/InAppMessage/in-app-message-manager-factory.js +3 -3
- package/src/InAppMessage/in-app-message-manager.js +65 -65
- package/src/InAppMessage/log-in-app-message-button-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +3 -3
- package/src/InAppMessage/models/full-screen-message.js +1 -1
- package/src/InAppMessage/models/html-message.js +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +80 -80
- 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 +20 -20
- package/src/Push/push-manager.js +216 -209
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +11 -8
- package/src/User/user.js +52 -41
- package/src/common/base-feed.js +1 -1
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -0
- package/src/common/feed-display.js +6 -6
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/auth-manager.js +24 -24
- package/src/managers/braze-instance.js +120 -120
- package/src/managers/device-manager.js +11 -11
- package/src/managers/network-manager.js +63 -54
- package/src/managers/server-config-manager.js +20 -20
- package/src/managers/session-manager.js +29 -29
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +104 -104
- package/src/managers/subscription-manager.js +6 -6
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- 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 +15 -15
- package/src/request-controller.js +92 -88
- package/src/triggers/models/custom-event-data.js +4 -4
- 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 +63 -63
- package/src/triggers/models/in-app-message-click-data.js +5 -5
- 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 +5 -5
- package/src/triggers/models/trigger-condition.js +48 -48
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +29 -29
- package/src/triggers/triggers-provider-factory.js +2 -2
- package/src/triggers/triggers-provider.js +87 -89
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +4 -4
- package/src/ui/js/iam-css.js +4 -4
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +8 -8
- package/src/util/browser-detector.js +8 -8
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/code-utils.js +10 -3
- package/src/util/component-utils.js +1 -1
- package/src/util/date-utils.js +2 -2
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +9 -9
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +3 -3
- package/src/util/user-agent-parser.js +4 -4
- package/src/util/validation-utils.js +155 -74
- package/src/util/window-utils.js +1 -1
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.7.0
|
|
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
|
|
@@ -1270,12 +1270,17 @@
|
|
|
1270
1270
|
* @param value - Can be numeric, boolean, a Date object, a string, or an array of strings. Strings are limited to
|
|
1271
1271
|
* 255 characters in length, cannot begin with a $, and can only contain alphanumeric characters and punctuation.
|
|
1272
1272
|
* Passing a null value will remove this custom attribute from the user.
|
|
1273
|
+
* @param merge - Whether the value should be merged with the existing value on the backend. If `false` (default), any existing
|
|
1274
|
+
* attribute will be overwritten. If `true`, existing objects and arrays of objects will be merged. To update an array of objects,
|
|
1275
|
+
* follow the guidelines in our
|
|
1276
|
+
* [public docs](https://www.braze.com/docs/user_guide/data_and_analytics/custom_data/custom_attributes/array_of_objects/#usage-examples).
|
|
1273
1277
|
*
|
|
1274
1278
|
* @returns {boolean} Whether the update was successfully enqueued.
|
|
1275
1279
|
*/
|
|
1276
1280
|
setCustomUserAttribute(
|
|
1277
1281
|
key: string,
|
|
1278
|
-
value: number | boolean | Date | string | string[] | null
|
|
1282
|
+
value: number | boolean | Date | string | string[] | object | object[] | null,
|
|
1283
|
+
merge?: boolean
|
|
1279
1284
|
): boolean;
|
|
1280
1285
|
|
|
1281
1286
|
/**
|
|
@@ -2000,16 +2005,16 @@
|
|
|
2000
2005
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2001
2006
|
*
|
|
2002
2007
|
* ```
|
|
2003
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
2008
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.7/service-worker.js');
|
|
2004
2009
|
* ```
|
|
2005
2010
|
*
|
|
2006
2011
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
2007
2012
|
*
|
|
2008
2013
|
* @param successCallback - When the user subscribes to push successfully this callback will be
|
|
2009
2014
|
* invoked with the user's endpoint, public key, and user auth key (endpoint, publicKey, userAuth).
|
|
2010
|
-
* @param deniedCallback - If push permission is denied
|
|
2011
|
-
* is temporary, it will be invoked with a parameter of `true` - otherwise it will be invoked
|
|
2012
|
-
* of `false`.
|
|
2015
|
+
* @param deniedCallback - If push permission is denied or an error is encountered while registering, this callback will
|
|
2016
|
+
* be invoked. If the denial is temporary, it will be invoked with a parameter of `true` - otherwise it will be invoked
|
|
2017
|
+
* with a parameter of `false`.
|
|
2013
2018
|
*/
|
|
2014
2019
|
export function requestPushPermission(
|
|
2015
2020
|
successCallback?: (
|
|
@@ -2189,7 +2194,7 @@
|
|
|
2189
2194
|
*/
|
|
2190
2195
|
export function subscribeToSdkAuthenticationFailures(subscriber: (
|
|
2191
2196
|
error: {
|
|
2192
|
-
errorCode:
|
|
2197
|
+
errorCode: number,
|
|
2193
2198
|
reason?: string,
|
|
2194
2199
|
userId?: string,
|
|
2195
2200
|
signature?: string
|
|
@@ -2353,7 +2358,7 @@
|
|
|
2353
2358
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2354
2359
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2355
2360
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2356
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.
|
|
2361
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/4.7/service-worker.js');` or by including the content
|
|
2357
2362
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2358
2363
|
*/
|
|
2359
2364
|
manageServiceWorkerExternally?: boolean;
|
package/package.json
CHANGED
|
@@ -3,6 +3,6 @@ import { EventTypes as ve, InternalEventTypes as De } from "./event-types.js";
|
|
|
3
3
|
import Be from "./guid.js";
|
|
4
4
|
import Ae from "./indexed-db-adapter.js";
|
|
5
5
|
import Ge from "./logger.js";
|
|
6
|
-
import
|
|
7
|
-
const r = {
|
|
6
|
+
import Ue from "./supported-options.js";
|
|
7
|
+
const r = { yn: je, A: ve, Ar: De, it: Be, qt: Ae, xt: Ae.ep, D: Ge, Wo: Ue };
|
|
8
8
|
export default r;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
const ve = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
4
|
+
Nl: "pc",
|
|
5
5
|
cc: "ca",
|
|
6
|
-
|
|
6
|
+
qa: "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
|
+
yh: "ss",
|
|
13
|
+
wh: "se",
|
|
14
|
+
Mi: "si",
|
|
15
|
+
Ii: "sc",
|
|
16
|
+
Ai: "sbc",
|
|
17
|
+
Ze: "sfe",
|
|
18
18
|
ro: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Ml: "lr",
|
|
20
|
+
Rl: "uae",
|
|
21
21
|
U: "ci",
|
|
22
22
|
F: "cc",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
Ul: "lcaa",
|
|
24
|
+
Il: "lcar",
|
|
25
|
+
Fn: "inc",
|
|
26
|
+
Un: "add",
|
|
27
|
+
En: "rem",
|
|
28
|
+
Sn: "set",
|
|
29
|
+
An: "ncam",
|
|
30
|
+
xl: "sgu"
|
|
30
31
|
},
|
|
31
32
|
De = { qr: "feed_displayed", dc: "content_cards_displayed" };
|
|
32
33
|
export { ve as EventTypes, De as InternalEventTypes };
|
|
@@ -301,14 +301,14 @@ Ae.ep = {
|
|
|
301
301
|
dd: "AppboyServiceWorkerAsyncStorage",
|
|
302
302
|
VERSION: 6,
|
|
303
303
|
$t: {
|
|
304
|
-
|
|
304
|
+
Ol: "data",
|
|
305
305
|
jr: "pushClicks",
|
|
306
306
|
cu: "pushSubscribed",
|
|
307
307
|
ud: "fallbackDevice",
|
|
308
308
|
Mt: "cardUpdates",
|
|
309
309
|
oe: "optOut",
|
|
310
310
|
$r: "pendingData",
|
|
311
|
-
|
|
311
|
+
Mn: "sdkAuthenticationSignature"
|
|
312
312
|
},
|
|
313
313
|
se: 1
|
|
314
314
|
}
|
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const Ge = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function(n) {
|
|
26
26
|
if (Ge.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v4.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v4.7.0)";
|
|
28
28
|
null != Ge.nd ? Ge.nd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function(n) {
|
|
32
32
|
if (Ge.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v4.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v4.7.0)";
|
|
34
34
|
null != Ge.nd ? Ge.nd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Yn: "allowCrawlerActivity",
|
|
3
|
+
Xn: "baseUrl",
|
|
4
|
+
Zn: "noCookies",
|
|
5
|
+
ho: "devicePropertyAllowlist",
|
|
6
6
|
ta: "disablePushTokenMaintenance",
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
po: "enableLogging",
|
|
8
|
+
Eo: "enableSdkAuthentication",
|
|
9
9
|
ia: "manageServiceWorkerExternally",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
_o: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
+
Io: "sessionTimeoutInSeconds",
|
|
12
|
+
Ao: "appVersion",
|
|
13
13
|
na: "serviceWorkerLocation",
|
|
14
14
|
ra: "safariWebsitePushId",
|
|
15
|
-
|
|
15
|
+
jn: "localization",
|
|
16
16
|
ao: "contentSecurityNonce",
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
So: "enableHtmlInAppMessages",
|
|
18
|
+
No: "allowUserSuppliedJavascript",
|
|
19
19
|
no: "inAppMessageZIndex",
|
|
20
20
|
lo: "openInAppMessagesInNewTab",
|
|
21
21
|
en: "openNewsFeedCardsInNewTab",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
Ih: "requireExplicitInAppMessageDismissal",
|
|
23
|
+
wo: "doNotLoadFontAwesome",
|
|
24
|
+
To: "sdkFlavor",
|
|
25
25
|
tn: "openCardsInNewTab"
|
|
26
26
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
import e from "../managers/braze-instance.js";
|
|
3
3
|
import {
|
|
4
|
-
BRAZE_ACTIONS as
|
|
5
|
-
getDecodedBrazeAction as
|
|
4
|
+
BRAZE_ACTIONS as P,
|
|
5
|
+
getDecodedBrazeAction as _
|
|
6
6
|
} from "../util/braze-actions.js";
|
|
7
7
|
import {
|
|
8
|
-
BRAZE_ACTION_URI_REGEX as
|
|
9
|
-
isValidBrazeActionJson as
|
|
8
|
+
BRAZE_ACTION_URI_REGEX as J,
|
|
9
|
+
isValidBrazeActionJson as O
|
|
10
10
|
} from "../util/validation-utils.js";
|
|
11
11
|
import { WindowUtils as H } from "../util/window-utils.js";
|
|
12
12
|
import { getUser as Q } from "./get-user.js";
|
|
13
|
-
export function _handleBrazeAction(
|
|
13
|
+
export function _handleBrazeAction(s, o, i) {
|
|
14
14
|
if (e.rr())
|
|
15
|
-
if (
|
|
16
|
-
const e =
|
|
15
|
+
if (J.test(s)) {
|
|
16
|
+
const e = _(s);
|
|
17
17
|
if (!e) return;
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
18
|
+
const o = e => {
|
|
19
|
+
if (!O(e))
|
|
20
20
|
return void r.D.error(
|
|
21
21
|
`Decoded Braze Action json is invalid: ${JSON.stringify(
|
|
22
22
|
e,
|
|
@@ -24,40 +24,46 @@ export function _handleBrazeAction(a, s, i) {
|
|
|
24
24
|
2
|
|
25
25
|
)}`
|
|
26
26
|
);
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
27
|
+
const s = e[P.properties.type];
|
|
28
|
+
if (s === P.types.ue) for (const r of e[P.properties.me]) o(r);
|
|
29
29
|
else {
|
|
30
|
-
const
|
|
31
|
-
let i
|
|
32
|
-
switch (
|
|
33
|
-
case
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
const o = e[P.properties.fe];
|
|
31
|
+
let i;
|
|
32
|
+
switch (s) {
|
|
33
|
+
case P.types.logCustomEvent:
|
|
34
|
+
import("./log-custom-event.js").then(
|
|
35
|
+
({ logCustomEvent: logCustomEvent }) => {
|
|
36
|
+
logCustomEvent.apply(null, Array.prototype.slice.call(o));
|
|
37
|
+
}
|
|
38
|
+
);
|
|
36
39
|
break;
|
|
37
|
-
case
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
case P.types.requestPushPermission:
|
|
41
|
+
import("../Push/request-push-permission.js").then(
|
|
42
|
+
({ requestPushPermission: requestPushPermission }) => {
|
|
43
|
+
requestPushPermission();
|
|
44
|
+
}
|
|
45
|
+
);
|
|
40
46
|
break;
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
(
|
|
47
|
+
case P.types.setEmailNotificationSubscriptionType:
|
|
48
|
+
case P.types.setPushNotificationSubscriptionType:
|
|
49
|
+
case P.types.setCustomUserAttribute:
|
|
50
|
+
case P.types.addToSubscriptionGroup:
|
|
51
|
+
case P.types.removeFromSubscriptionGroup:
|
|
52
|
+
case P.types.addToCustomAttributeArray:
|
|
53
|
+
case P.types.removeFromCustomAttributeArray:
|
|
54
|
+
(i = Q()), i[s].apply(i, Array.prototype.slice.call(o));
|
|
49
55
|
break;
|
|
50
|
-
case
|
|
51
|
-
case
|
|
52
|
-
H.openUri.apply(null, Array.prototype.slice.call(
|
|
56
|
+
case P.types.de:
|
|
57
|
+
case P.types.pe:
|
|
58
|
+
H.openUri.apply(null, Array.prototype.slice.call(o));
|
|
53
59
|
break;
|
|
54
60
|
default:
|
|
55
|
-
r.D.info(`Ignoring unknown Braze Action: ${
|
|
61
|
+
r.D.info(`Ignoring unknown Braze Action: ${s}`);
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
};
|
|
59
|
-
|
|
60
|
-
} else H.openUri(
|
|
65
|
+
o(e);
|
|
66
|
+
} else H.openUri(s, i, o);
|
|
61
67
|
}
|
|
62
68
|
export function handleBrazeAction(e, r) {
|
|
63
69
|
_handleBrazeAction(e, r);
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
validateCustomProperties as X,
|
|
8
8
|
validateCustomString as Y
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
|
+
import { LOG_CUSTOM_EVENT_STRING as Z } from "../common/constants.js";
|
|
10
11
|
export function logCustomEvent(t, o) {
|
|
11
12
|
if (!e.rr()) return !1;
|
|
12
13
|
if (null == t || t.length <= 0)
|
|
@@ -17,13 +18,7 @@ export function logCustomEvent(t, o) {
|
|
|
17
18
|
!1
|
|
18
19
|
);
|
|
19
20
|
if (!Y(t, "log custom event", "the event name")) return !1;
|
|
20
|
-
const [n, i] = X(
|
|
21
|
-
o,
|
|
22
|
-
"logCustomEvent",
|
|
23
|
-
"eventProperties",
|
|
24
|
-
`log custom event "${t}"`,
|
|
25
|
-
"event"
|
|
26
|
-
);
|
|
21
|
+
const [n, i] = X(o, Z, "eventProperties", `log custom event "${t}"`, "event");
|
|
27
22
|
if (!n) return !1;
|
|
28
23
|
if (e.ir().ge(t))
|
|
29
24
|
return r.D.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1;
|
package/src/Core/log-purchase.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import { MAX_PURCHASE_QUANTITY as
|
|
2
|
+
import { MAX_PURCHASE_QUANTITY as rr } from "../common/constants.js";
|
|
3
3
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
4
4
|
import V from "../triggers/models/trigger-events.js";
|
|
5
5
|
import { TriggersProviderFactory as W } from "../triggers/triggers-provider-factory.js";
|
|
@@ -34,10 +34,10 @@ export function logPurchase(o, i, t, n, D) {
|
|
|
34
34
|
),
|
|
35
35
|
!1
|
|
36
36
|
);
|
|
37
|
-
if (g < 1 || g >
|
|
37
|
+
if (g < 1 || g > rr)
|
|
38
38
|
return (
|
|
39
39
|
r.D.error(
|
|
40
|
-
`logPurchase requires a quantity >1 and <${
|
|
40
|
+
`logPurchase requires a quantity >1 and <${rr}, got ${g}, ignoring.`
|
|
41
41
|
),
|
|
42
42
|
!1
|
|
43
43
|
);
|
package/src/Core/wipe-data.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import { keys as
|
|
2
|
+
import { keys as or } from "../util/code-utils.js";
|
|
3
3
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
4
4
|
export function wipeData() {
|
|
5
5
|
if (null == e.l())
|
|
6
6
|
throw new Error("Braze must be initialized before calling methods.");
|
|
7
7
|
e.l().clearData();
|
|
8
|
-
const o =
|
|
8
|
+
const o = or(r.xt);
|
|
9
9
|
for (let e = 0; e < o.length; e++) {
|
|
10
10
|
const i = o[e],
|
|
11
11
|
t = r.xt[i];
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
2
2
|
export default class FeatureFlag {
|
|
3
3
|
constructor(t, r = !1, e = {}) {
|
|
4
|
-
(this.id = t),
|
|
4
|
+
(this.id = t),
|
|
5
|
+
(this.enabled = r),
|
|
6
|
+
(this.properties = e),
|
|
7
|
+
(this.id = t),
|
|
8
|
+
(this.enabled = r),
|
|
9
|
+
(this.properties = e);
|
|
5
10
|
}
|
|
6
11
|
getStringProperty(t) {
|
|
7
|
-
if (!this.yr(t)) return null;
|
|
8
12
|
const r = this.properties[t];
|
|
9
|
-
return
|
|
13
|
+
return null == r
|
|
14
|
+
? (this.yr(t), null)
|
|
15
|
+
: this.Er(r)
|
|
16
|
+
? r.value
|
|
17
|
+
: (this.Br("string"), null);
|
|
10
18
|
}
|
|
11
19
|
getNumberProperty(t) {
|
|
12
|
-
if (!this.yr(t)) return null;
|
|
13
20
|
const r = this.properties[t];
|
|
14
|
-
return
|
|
21
|
+
return null == r
|
|
22
|
+
? (this.yr(t), null)
|
|
23
|
+
: this.Ir(r)
|
|
24
|
+
? r.value
|
|
25
|
+
: (this.Br("number"), null);
|
|
15
26
|
}
|
|
16
27
|
getBooleanProperty(t) {
|
|
17
|
-
if (!this.yr(t)) return null;
|
|
18
28
|
const r = this.properties[t];
|
|
19
|
-
return
|
|
29
|
+
return null == r
|
|
30
|
+
? (this.yr(t), null)
|
|
31
|
+
: this.Nr(r)
|
|
32
|
+
? r.value
|
|
33
|
+
: (this.Br("boolean"), null);
|
|
20
34
|
}
|
|
21
35
|
ss() {
|
|
22
36
|
const t = {};
|
|
@@ -27,17 +41,20 @@ export default class FeatureFlag {
|
|
|
27
41
|
t
|
|
28
42
|
);
|
|
29
43
|
}
|
|
44
|
+
Br(t) {
|
|
45
|
+
r.D.info(`Property is not of type ${t}.`);
|
|
46
|
+
}
|
|
30
47
|
yr(t) {
|
|
31
|
-
|
|
32
|
-
!(!this.properties || !this.properties[t]) ||
|
|
33
|
-
(r.D.info(`${t} not found in feature flag properties.`), !1)
|
|
34
|
-
);
|
|
48
|
+
r.D.info(`${t} not found in feature flag properties.`);
|
|
35
49
|
}
|
|
36
|
-
Er(t
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
Er(t) {
|
|
51
|
+
return "string" === t.type && "string" == typeof t.value;
|
|
52
|
+
}
|
|
53
|
+
Ir(t) {
|
|
54
|
+
return "number" === t.type && "number" == typeof t.value;
|
|
55
|
+
}
|
|
56
|
+
Nr(t) {
|
|
57
|
+
return "boolean" === t.type && "boolean" == typeof t.value;
|
|
41
58
|
}
|
|
42
59
|
}
|
|
43
60
|
(FeatureFlag.hs = { ns: "id", Fe: "e", we: "pr" }),
|