@braze/web-sdk 5.6.1 → 5.8.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 +15 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +23 -23
- package/shared-lib/indexed-db-adapter.js +20 -20
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +17 -17
- package/src/Banner/banner-provider.js +53 -50
- package/src/Banner/banner.js +1 -1
- package/src/Banner/get-all-banners.js +3 -4
- package/src/Banner/get-banner.js +11 -11
- package/src/Banner/log-banner-click.js +1 -1
- package/src/Banner/log-banner-impressions.js +4 -4
- package/src/Banner/request-banners-refresh.js +21 -13
- package/src/Banner/subscribe-to-banners-updates.js +14 -13
- package/src/Banner/ui/insert-banner.js +11 -9
- package/src/Card/card-manager.js +10 -10
- package/src/Card/log-card-impressions.js +2 -2
- package/src/Card/models/captioned-image.js +1 -1
- package/src/Card/models/card.js +3 -3
- package/src/Card/models/classic-card.js +1 -1
- package/src/Card/models/control-card.js +1 -1
- package/src/Card/models/image-only.js +1 -1
- package/src/ContentCards/content-cards-provider-factory.js +1 -1
- package/src/ContentCards/content-cards-provider.js +139 -180
- package/src/ContentCards/content-cards.js +3 -3
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +10 -10
- package/src/ContentCards/ui/show-content-cards.js +8 -8
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +3 -3
- package/src/Core/disable-sdk.js +7 -7
- package/src/Core/enable-sdk.js +5 -5
- package/src/Core/get-device-id.js +2 -2
- package/src/Core/get-user.js +1 -1
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +3 -3
- package/src/Core/log-purchase.js +1 -1
- package/src/Core/open-session.js +9 -9
- package/src/Core/wipe-data.js +5 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +18 -18
- package/src/FeatureFlags/feature-flags-provider.js +81 -78
- package/src/FeatureFlags/get-all-feature-flags.js +6 -7
- package/src/FeatureFlags/get-feature-flag.js +5 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +4 -4
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +34 -34
- package/src/Feed/feed.js +2 -2
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +5 -5
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- 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 +4 -4
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +115 -91
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +4 -4
- package/src/InAppMessage/log-in-app-message-impression.js +2 -2
- package/src/InAppMessage/models/control-message.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +5 -5
- package/src/InAppMessage/models/html-message.js +10 -10
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +42 -42
- package/src/InAppMessage/models/modal-message.js +5 -5
- package/src/InAppMessage/models/slide-up-message.js +8 -8
- 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 +24 -24
- 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 +8 -8
- package/src/Push/push-manager.js +90 -90
- package/src/Push/utils/push-utils.js +12 -12
- package/src/User/user-manager.js +12 -12
- package/src/User/user.js +48 -36
- package/src/common/base-feed.js +3 -3
- package/src/common/constants.js +1 -1
- package/src/common/event-logger.js +4 -4
- package/src/common/feed-display.js +14 -14
- package/src/l10n/l10n-manager-factory.js +2 -2
- package/src/l10n/l10n-manager.js +1 -1
- package/src/managers/auth-manager.js +10 -10
- package/src/managers/braze-instance.js +128 -128
- package/src/managers/device-manager.js +18 -18
- package/src/managers/network-manager.js +184 -147
- package/src/managers/server-config-manager.js +63 -63
- package/src/managers/session-manager.js +27 -27
- package/src/managers/storage-manager-factory.js +10 -10
- package/src/managers/storage-manager.js +146 -146
- package/src/managers/subscription-manager.js +8 -8
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +4 -4
- package/src/models/braze-event.js +8 -8
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +12 -12
- package/src/models/push-token.js +8 -8
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +163 -151
- package/src/triggers/models/custom-event-data.js +5 -5
- package/src/triggers/models/custom-event-property-data.js +6 -6
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +16 -16
- package/src/triggers/models/in-app-message-click-data.js +2 -2
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +37 -37
- package/src/triggers/models/trigger-events.js +2 -2
- package/src/triggers/models/trigger.js +11 -11
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +39 -39
- package/src/ui/js/attach-css.js +3 -3
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +2 -2
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +6 -6
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/component-utils.js +2 -2
- package/src/util/dom-utils.js +6 -6
- package/src/util/html-display-utils.js +1 -0
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +22 -23
- package/src/util/request-header-utils.js +25 -22
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/validation-utils.js +17 -17
- package/src/util/window-utils.js +2 -2
|
@@ -14,11 +14,11 @@ export default class ContentCards extends rr {
|
|
|
14
14
|
logCardClick(r) {
|
|
15
15
|
return logCardClick(r, !0);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
sr() {
|
|
18
18
|
requestContentCardsRefresh();
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
nr() {
|
|
21
21
|
return !0;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
ContentCards.
|
|
24
|
+
ContentCards.dr = 6e4;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import W from "./content-cards-provider-factory.js";
|
|
3
|
-
export function subscribeToContentCardsUpdates(
|
|
3
|
+
export function subscribeToContentCardsUpdates(o) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
if (!
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
const r =
|
|
11
|
-
|
|
5
|
+
const t = W.m(),
|
|
6
|
+
n = t.qs(o);
|
|
7
|
+
if (!t.Cs()) {
|
|
8
|
+
const o = r.nn();
|
|
9
|
+
if (o) {
|
|
10
|
+
const r = o.rn(() => {
|
|
11
|
+
t.Di(void 0, void 0, !0);
|
|
12
12
|
});
|
|
13
|
-
r &&
|
|
13
|
+
r && t.Ts(r);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return n;
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import r, { OPTIONS as
|
|
1
|
+
import r, { OPTIONS as w } from "../../managers/braze-instance.js";
|
|
2
2
|
import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
|
|
3
3
|
import W from "../content-cards-provider-factory.js";
|
|
4
4
|
import {
|
|
@@ -18,20 +18,20 @@ export function showContentCards(n, t) {
|
|
|
18
18
|
fn();
|
|
19
19
|
let e = !1;
|
|
20
20
|
null == n && ((n = document.body), (e = !0));
|
|
21
|
-
const o = r.
|
|
22
|
-
i = W.m().
|
|
21
|
+
const o = r.ee(w.tn) || r.ee(w.en) || !1,
|
|
22
|
+
i = W.m().Ri(!1);
|
|
23
23
|
"function" == typeof t && an(i, t(i.cards.slice()), i.lastUpdated, null, o);
|
|
24
24
|
const a = tn(i, o, e),
|
|
25
25
|
s = W.m(),
|
|
26
|
-
f = s.
|
|
26
|
+
f = s.Zs();
|
|
27
27
|
(null == i.lastUpdated ||
|
|
28
|
-
new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.
|
|
29
|
-
(null == f || new Date().valueOf() - f > ContentCards.
|
|
28
|
+
new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.dr) &&
|
|
29
|
+
(null == f || new Date().valueOf() - f > ContentCards.dr) &&
|
|
30
30
|
(N.info(
|
|
31
|
-
`Cached content cards were older than max TTL of ${ContentCards.
|
|
31
|
+
`Cached content cards were older than max TTL of ${ContentCards.dr} ms, requesting an update from the server.`,
|
|
32
32
|
),
|
|
33
33
|
on(i, a),
|
|
34
|
-
s.
|
|
34
|
+
s.fi(new Date().valueOf()));
|
|
35
35
|
const l = new Date().valueOf(),
|
|
36
36
|
c = subscribeToContentCardsUpdates(function (n) {
|
|
37
37
|
const e = a.querySelectorAll(".ab-refresh-button")[0];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import aa from "../managers/braze-instance.js";
|
|
2
2
|
import BrazeSdkMetadata from "./braze-sdk-metadata.js";
|
|
3
3
|
import {
|
|
4
|
-
isArray as
|
|
4
|
+
isArray as z,
|
|
5
5
|
validateValueIsFromEnum as ta,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
7
|
import { logger as N } from "../../shared-lib/index.js";
|
|
@@ -9,7 +9,7 @@ export function addSdkMetadata(a) {
|
|
|
9
9
|
if (!aa.rr()) return;
|
|
10
10
|
const t = aa.g();
|
|
11
11
|
if (t) {
|
|
12
|
-
if (!
|
|
12
|
+
if (!z(a))
|
|
13
13
|
return (
|
|
14
14
|
N.error("Cannot set SDK metadata because metadata is not an array."), !1
|
|
15
15
|
);
|
package/src/Core/change-user.js
CHANGED
|
@@ -7,11 +7,11 @@ export function changeUser(e, i) {
|
|
|
7
7
|
if (!r.rr()) return;
|
|
8
8
|
if (null == e || 0 === e.length || e != e)
|
|
9
9
|
return void N.error("changeUser requires a non-empty userId.");
|
|
10
|
-
if (er(e) > User.
|
|
10
|
+
if (er(e) > User.ur)
|
|
11
11
|
return void N.error(
|
|
12
|
-
`Rejected user id "${e}" because it is longer than ${User.
|
|
12
|
+
`Rejected user id "${e}" because it is longer than ${User.ur} bytes.`,
|
|
13
13
|
);
|
|
14
14
|
if (null != i && !ir(i, "set signature for new user", "signature")) return;
|
|
15
15
|
const t = r.nn();
|
|
16
|
-
t && t.changeUser(e.toString(), r.
|
|
16
|
+
t && t.changeUser(e.toString(), r.ar(), i);
|
|
17
17
|
}
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as N, IndexedDBAdapter as
|
|
2
|
+
import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
|
|
3
3
|
import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
|
|
4
4
|
export function disableSDK() {
|
|
5
5
|
const e = r.nn();
|
|
6
6
|
e && e.requestImmediateDataFlush();
|
|
7
|
-
const n = new ne.
|
|
8
|
-
s = "This-cookie-will-expire-in-" + n.
|
|
9
|
-
n.store(t.
|
|
10
|
-
const a =
|
|
11
|
-
new
|
|
7
|
+
const n = new ne.se(null, !0),
|
|
8
|
+
s = "This-cookie-will-expire-in-" + n.ae();
|
|
9
|
+
n.store(t.ie, s);
|
|
10
|
+
const a = tt._s.Xs;
|
|
11
|
+
new tt(a, N).setItem(a.Ks.oe, a.te, !0),
|
|
12
12
|
N.info("disableSDK was called"),
|
|
13
13
|
r.destroy(!1),
|
|
14
|
-
r.
|
|
14
|
+
r.le(!0);
|
|
15
15
|
}
|
package/src/Core/enable-sdk.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as N, IndexedDBAdapter as
|
|
2
|
+
import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
|
|
3
3
|
import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
|
|
4
4
|
export function enableSDK() {
|
|
5
|
-
new ne.
|
|
6
|
-
const e =
|
|
7
|
-
new
|
|
5
|
+
new ne.se(null, !0).remove(t.ie);
|
|
6
|
+
const e = tt._s.Xs;
|
|
7
|
+
new tt(e, N).me(e.Ks.oe, e.te),
|
|
8
8
|
N.info("enableSDK was called"),
|
|
9
9
|
r.destroy(!1),
|
|
10
|
-
r.
|
|
10
|
+
r.le(!1);
|
|
11
11
|
}
|
|
@@ -2,9 +2,9 @@ import r from "../managers/braze-instance.js";
|
|
|
2
2
|
import { logger as N } from "../../shared-lib/index.js";
|
|
3
3
|
export function getDeviceId(e) {
|
|
4
4
|
if (!r.rr()) return;
|
|
5
|
-
const t = r.
|
|
5
|
+
const t = r.ce();
|
|
6
6
|
if (!t) return;
|
|
7
|
-
const i = t.
|
|
7
|
+
const i = t.de().id;
|
|
8
8
|
if ("function" != typeof e) return i;
|
|
9
9
|
N.warn(
|
|
10
10
|
"The callback for getDeviceId is deprecated. You can access its return value directly instead (e.g. `const id = braze.getDeviceId()`)",
|
package/src/Core/get-user.js
CHANGED
package/src/Core/is-disabled.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
validateCustomProperties as rt,
|
|
8
8
|
validateCustomString as nt,
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
|
-
import { LOG_CUSTOM_EVENT_STRING as
|
|
10
|
+
import { LOG_CUSTOM_EVENT_STRING as it } from "../common/constants.js";
|
|
11
11
|
export function logCustomEvent(t, e) {
|
|
12
12
|
if (!r.rr()) return !1;
|
|
13
13
|
if (null == t || t.length <= 0)
|
|
@@ -20,7 +20,7 @@ export function logCustomEvent(t, e) {
|
|
|
20
20
|
if (!nt(t, "log custom event", "the event name")) return !1;
|
|
21
21
|
const [o, n] = rt(
|
|
22
22
|
e,
|
|
23
|
-
|
|
23
|
+
it,
|
|
24
24
|
"eventProperties",
|
|
25
25
|
`log custom event "${t}"`,
|
|
26
26
|
"event",
|
|
@@ -29,7 +29,7 @@ export function logCustomEvent(t, e) {
|
|
|
29
29
|
const i = r.v();
|
|
30
30
|
if (i && i.ge(t))
|
|
31
31
|
return N.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1;
|
|
32
|
-
const s = c.
|
|
32
|
+
const s = c.cs(d.CustomEvent, { n: t, p: n });
|
|
33
33
|
if (s.ss) {
|
|
34
34
|
N.info(`Logged custom event "${t}".`);
|
|
35
35
|
for (const o of s.fe) ot.m().ue(et.ve, [t, e], o);
|
package/src/Core/log-purchase.js
CHANGED
|
@@ -230,7 +230,7 @@ export function logPurchase(e, o, i, n, t) {
|
|
|
230
230
|
const g = r.v();
|
|
231
231
|
if (g && g.Dr(e))
|
|
232
232
|
return N.info(`Purchase "${e}" is blocklisted, ignoring.`), !1;
|
|
233
|
-
const P = c.
|
|
233
|
+
const P = c.cs(d.Pr, { pid: e, c: i, p: s, q: D, pr: a });
|
|
234
234
|
if (P.ss) {
|
|
235
235
|
N.info(`Logged ${D} purchase${D > 1 ? "s" : ""} of "${e}" for ${i} ${s}.`);
|
|
236
236
|
for (const r of P.fe) ot.m().ue(et.Rr, [e, t], r);
|
package/src/Core/open-session.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import { logger as N, IndexedDBAdapter as
|
|
2
|
+
import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
|
|
3
3
|
import et from "../triggers/models/trigger-events.js";
|
|
4
4
|
import { TriggersProviderFactory as ot } from "../triggers/triggers-provider-factory.js";
|
|
5
5
|
export function openSession() {
|
|
@@ -7,19 +7,19 @@ export function openSession() {
|
|
|
7
7
|
const i = r.nn();
|
|
8
8
|
if (!i) return;
|
|
9
9
|
i.openSession();
|
|
10
|
-
const t =
|
|
11
|
-
o = new
|
|
12
|
-
o.
|
|
10
|
+
const t = tt._s.Xs,
|
|
11
|
+
o = new tt(t, N);
|
|
12
|
+
o.cr(t.Ks.jr, (r, n) => {
|
|
13
13
|
const e = n.lastClick,
|
|
14
14
|
s = n.trackingString;
|
|
15
15
|
N.info(`Firing push click trigger from ${s} push click at ${e}`);
|
|
16
|
-
const c = i.
|
|
16
|
+
const c = i.lr(e, s),
|
|
17
17
|
g = function () {
|
|
18
|
-
ot.m().ue(et.
|
|
18
|
+
ot.m().ue(et.hr, [s], c);
|
|
19
19
|
};
|
|
20
|
-
i.
|
|
20
|
+
i.br(g, g), o.me(t.Ks.jr, r);
|
|
21
21
|
}),
|
|
22
|
-
o.
|
|
23
|
-
i.
|
|
22
|
+
o.Gs(t.Ks.kr, function (r) {
|
|
23
|
+
i.vr(r);
|
|
24
24
|
});
|
|
25
25
|
}
|
package/src/Core/wipe-data.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import { keys as y } from "../util/code-utils.js";
|
|
3
|
-
import { logger as N, IndexedDBAdapter as
|
|
3
|
+
import { logger as N, IndexedDBAdapter as tt } from "../../shared-lib/index.js";
|
|
4
4
|
import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../common/constants.js";
|
|
5
5
|
export function wipeData() {
|
|
6
6
|
const o = r.j();
|
|
7
7
|
if (null == o) return void N.warn(p);
|
|
8
8
|
o.clearData();
|
|
9
|
-
const t = y(
|
|
9
|
+
const t = y(tt._s);
|
|
10
10
|
for (let o = 0; o < t.length; o++) {
|
|
11
11
|
const n = t[o],
|
|
12
|
-
r =
|
|
13
|
-
new
|
|
12
|
+
r = tt._s[n];
|
|
13
|
+
new tt(r, N).clearData();
|
|
14
14
|
}
|
|
15
|
-
if (r.rr()) for (const o of r.
|
|
15
|
+
if (r.rr()) for (const o of r.ar()) o.clearData(!0);
|
|
16
16
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { logger as N } from "../../shared-lib/index.js";
|
|
2
2
|
import FeatureFlag from "./feature-flag.js";
|
|
3
3
|
export function newFeatureFlagFromJson(e) {
|
|
4
|
-
if (e[FeatureFlag.li.Et] && "boolean" == typeof e[FeatureFlag.li.
|
|
4
|
+
if (e[FeatureFlag.li.Et] && "boolean" == typeof e[FeatureFlag.li.pe])
|
|
5
5
|
return new FeatureFlag(
|
|
6
6
|
e[FeatureFlag.li.Et],
|
|
7
|
-
e[FeatureFlag.li.le],
|
|
8
7
|
e[FeatureFlag.li.pe],
|
|
9
8
|
e[FeatureFlag.li.Fe],
|
|
9
|
+
e[FeatureFlag.li.be],
|
|
10
10
|
);
|
|
11
11
|
N.info(`Unable to create feature flag from ${JSON.stringify(e, null, 2)}`);
|
|
12
12
|
}
|
|
13
13
|
export function newFeatureFlagFromSerializedValue(e) {
|
|
14
|
-
if (e[FeatureFlag.qt.Et] && "boolean" == typeof e[FeatureFlag.qt.
|
|
14
|
+
if (e[FeatureFlag.qt.Et] && "boolean" == typeof e[FeatureFlag.qt.pe])
|
|
15
15
|
return new FeatureFlag(
|
|
16
16
|
e[FeatureFlag.qt.Et],
|
|
17
|
-
e[FeatureFlag.qt.le],
|
|
18
17
|
e[FeatureFlag.qt.pe],
|
|
19
18
|
e[FeatureFlag.qt.Fe],
|
|
19
|
+
e[FeatureFlag.qt.be],
|
|
20
20
|
);
|
|
21
21
|
N.info(
|
|
22
22
|
`Unable to deserialize feature flag from ${JSON.stringify(e, null, 2)}`,
|
|
@@ -15,30 +15,30 @@ export default class FeatureFlag {
|
|
|
15
15
|
return null == i ? (this.ye(t), null) : e(i) ? i.value : (this.Pe(r), null);
|
|
16
16
|
}
|
|
17
17
|
getStringProperty(t) {
|
|
18
|
-
return this.he(t, this.
|
|
18
|
+
return this.he(t, this.Ie, "string");
|
|
19
19
|
}
|
|
20
20
|
getNumberProperty(t) {
|
|
21
|
-
return this.he(t, this.
|
|
21
|
+
return this.he(t, this.Te, "number");
|
|
22
22
|
}
|
|
23
23
|
getBooleanProperty(t) {
|
|
24
|
-
return this.he(t, this.
|
|
24
|
+
return this.he(t, this.Ee, "boolean");
|
|
25
25
|
}
|
|
26
26
|
getImageProperty(t) {
|
|
27
|
-
return this.he(t, this.
|
|
27
|
+
return this.he(t, this.Ne, "image");
|
|
28
28
|
}
|
|
29
29
|
getJsonProperty(t) {
|
|
30
|
-
return this.he(t, this.
|
|
30
|
+
return this.he(t, this.Re, "jsonobject");
|
|
31
31
|
}
|
|
32
32
|
getTimestampProperty(t) {
|
|
33
|
-
return this.he(t, this.
|
|
33
|
+
return this.he(t, this.je, "datetime");
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
bs() {
|
|
36
36
|
const t = {};
|
|
37
37
|
return (
|
|
38
38
|
(t[FeatureFlag.qt.Et] = this.id),
|
|
39
|
-
(t[FeatureFlag.qt.
|
|
40
|
-
(t[FeatureFlag.qt.
|
|
41
|
-
(t[FeatureFlag.qt.
|
|
39
|
+
(t[FeatureFlag.qt.pe] = this.enabled),
|
|
40
|
+
(t[FeatureFlag.qt.Fe] = this.properties),
|
|
41
|
+
(t[FeatureFlag.qt.be] = this.trackingString),
|
|
42
42
|
t
|
|
43
43
|
);
|
|
44
44
|
}
|
|
@@ -48,28 +48,28 @@ export default class FeatureFlag {
|
|
|
48
48
|
ye(t) {
|
|
49
49
|
N.info(`${t} not found in feature flag properties.`);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
Ie(t) {
|
|
52
52
|
return "string" === t.type && "string" == typeof t.value;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
Te(t) {
|
|
55
55
|
return "number" === t.type && "number" == typeof t.value;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
Ee(t) {
|
|
58
58
|
return "boolean" === t.type && "boolean" == typeof t.value;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
Ne(t) {
|
|
61
61
|
return "image" === t.type && "string" == typeof t.value;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
Re(t) {
|
|
64
64
|
return (
|
|
65
65
|
"jsonobject" === t.type &&
|
|
66
66
|
"object" == typeof t.value &&
|
|
67
67
|
t.value.constructor == Object
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
je(t) {
|
|
71
71
|
return "datetime" === t.type && "number" == typeof t.value;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
(FeatureFlag.qt = { Et: "id",
|
|
75
|
-
(FeatureFlag.li = { Et: "id",
|
|
74
|
+
(FeatureFlag.qt = { Et: "id", pe: "e", Fe: "pr", be: "fts" }),
|
|
75
|
+
(FeatureFlag.li = { Et: "id", pe: "enabled", Fe: "properties", be: "fts" });
|
|
@@ -6,174 +6,177 @@ import u from "../managers/subscription-manager.js";
|
|
|
6
6
|
import { randomInclusive as a } from "../util/math.js";
|
|
7
7
|
import l from "../util/net.js";
|
|
8
8
|
import {
|
|
9
|
-
newFeatureFlagFromJson as
|
|
10
|
-
newFeatureFlagFromSerializedValue as
|
|
9
|
+
newFeatureFlagFromJson as st,
|
|
10
|
+
newFeatureFlagFromSerializedValue as ht,
|
|
11
11
|
} from "./feature-flag-factory.js";
|
|
12
12
|
import h from "../util/request-header-utils.js";
|
|
13
13
|
export default class tr extends s {
|
|
14
|
-
constructor(t, s,
|
|
14
|
+
constructor(t, s, e, i) {
|
|
15
15
|
super(),
|
|
16
16
|
(this.B = t),
|
|
17
17
|
(this.S = s),
|
|
18
|
-
(this.C =
|
|
19
|
-
(this.T =
|
|
20
|
-
(this.
|
|
21
|
-
(this.
|
|
18
|
+
(this.C = e),
|
|
19
|
+
(this.T = i),
|
|
20
|
+
(this.we = []),
|
|
21
|
+
(this.Ce = 0),
|
|
22
22
|
(this.B = t),
|
|
23
23
|
(this.S = s),
|
|
24
|
-
(this.C =
|
|
25
|
-
(this.T =
|
|
26
|
-
(this.
|
|
27
|
-
(this.
|
|
24
|
+
(this.C = e),
|
|
25
|
+
(this.T = i),
|
|
26
|
+
(this.De = null),
|
|
27
|
+
(this.Se = new u()),
|
|
28
28
|
(this.R = 10),
|
|
29
29
|
(this.I = null),
|
|
30
30
|
(this.q = null),
|
|
31
|
-
r.N(this.
|
|
31
|
+
r.N(this.Se);
|
|
32
32
|
}
|
|
33
33
|
U(t) {
|
|
34
34
|
var s;
|
|
35
35
|
if (
|
|
36
|
-
(null === (s = this.B) || void 0 === s ? void 0 : s.
|
|
36
|
+
(null === (s = this.B) || void 0 === s ? void 0 : s.qe()) &&
|
|
37
37
|
null != t &&
|
|
38
38
|
t.feature_flags
|
|
39
39
|
) {
|
|
40
|
-
this.
|
|
40
|
+
this.we = [];
|
|
41
41
|
for (const s of t.feature_flags) {
|
|
42
|
-
const t =
|
|
43
|
-
t && this.
|
|
42
|
+
const t = st(s);
|
|
43
|
+
t && this.we.push(t);
|
|
44
44
|
}
|
|
45
|
-
(this.
|
|
45
|
+
(this.Ce = new Date().getTime()), this.xe(), this.Se.X(this.we);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
ze() {
|
|
49
49
|
let s = {};
|
|
50
|
-
this.C && (s = this.C.
|
|
51
|
-
const
|
|
50
|
+
this.C && (s = this.C.vs(t.gs.$e));
|
|
51
|
+
const e = {};
|
|
52
52
|
for (const t in s) {
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const i = ht(s[t]);
|
|
54
|
+
i && (e[i.id] = i);
|
|
55
55
|
}
|
|
56
|
-
return
|
|
56
|
+
return e;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
ke() {
|
|
59
59
|
var s;
|
|
60
60
|
return (
|
|
61
|
-
(null === (s = this.C) || void 0 === s ? void 0 : s.
|
|
61
|
+
(null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.Be)) || {}
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
this.C && this.C.
|
|
64
|
+
Me(s) {
|
|
65
|
+
this.C && this.C.Bs(t.gs.Be, s);
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
return this.
|
|
67
|
+
qs(t) {
|
|
68
|
+
return this.Se.Fs(t);
|
|
69
69
|
}
|
|
70
|
-
refreshFeatureFlags(t, s,
|
|
70
|
+
refreshFeatureFlags(t, s, e = !1, i = !0) {
|
|
71
71
|
const r = () => {
|
|
72
|
-
"function" == typeof s && s(), this.
|
|
72
|
+
"function" == typeof s && s(), this.Se.X(this.we);
|
|
73
73
|
};
|
|
74
|
-
if (!this.
|
|
74
|
+
if (!this.Ue(e))
|
|
75
75
|
return (
|
|
76
|
-
!this.
|
|
76
|
+
!this.De &&
|
|
77
77
|
this.B &&
|
|
78
|
-
(this.
|
|
78
|
+
(this.De = this.B.Xe(() => {
|
|
79
79
|
this.refreshFeatureFlags(t, s);
|
|
80
80
|
})),
|
|
81
81
|
void r()
|
|
82
82
|
);
|
|
83
83
|
const o = this.S;
|
|
84
84
|
if (!o) return void r();
|
|
85
|
-
|
|
85
|
+
i && this.G();
|
|
86
86
|
const n = o.H({}, !0),
|
|
87
|
-
u = o.J(n, h.O.
|
|
87
|
+
u = o.J(n, h.O._e);
|
|
88
88
|
let f = !1;
|
|
89
89
|
o.V(
|
|
90
90
|
n,
|
|
91
|
-
(
|
|
92
|
-
|
|
91
|
+
(i = -1) => {
|
|
92
|
+
const o = this.S;
|
|
93
|
+
if (!o) return void r();
|
|
93
94
|
const c = new Date().valueOf();
|
|
94
|
-
h.W(this.C, h.O.
|
|
95
|
-
-1 !==
|
|
95
|
+
h.W(this.C, h.O._e, c),
|
|
96
|
+
-1 !== i && u.push(["X-Braze-Req-Tokens-Remaining", i.toString()]),
|
|
96
97
|
l.Y({
|
|
97
|
-
url: `${
|
|
98
|
+
url: `${o.Z()}/feature_flags/sync`,
|
|
98
99
|
headers: u,
|
|
99
100
|
data: n,
|
|
100
101
|
ss: (s) => {
|
|
101
|
-
if (!
|
|
102
|
-
|
|
103
|
-
this.U(s),
|
|
104
|
-
(f = !1),
|
|
105
|
-
h.ns(this.C, h.O.De, 1),
|
|
106
|
-
"function" == typeof t && t();
|
|
102
|
+
if (!o.ts(n, s, u)) return (f = !0), void r();
|
|
103
|
+
o.es(), this.U(s), (f = !1), "function" == typeof t && t();
|
|
107
104
|
},
|
|
108
105
|
error: (t) => {
|
|
109
|
-
|
|
106
|
+
o.ns(t, "retrieving feature flags"), (f = !0), r();
|
|
110
107
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
let
|
|
115
|
-
(null ==
|
|
116
|
-
|
|
108
|
+
rs: (i, r) => {
|
|
109
|
+
let n;
|
|
110
|
+
if (f) {
|
|
111
|
+
let t = this.I;
|
|
112
|
+
(null == t || t < 1e3 * this.R) && (t = 1e3 * this.R),
|
|
113
|
+
(n = Math.min(3e5, a(1e3 * this.R, 3 * t)));
|
|
117
114
|
}
|
|
115
|
+
o.os(
|
|
116
|
+
r,
|
|
117
|
+
() => {
|
|
118
|
+
this.refreshFeatureFlags(t, s, e, !0);
|
|
119
|
+
},
|
|
120
|
+
h.O._e,
|
|
121
|
+
(t) => this.hs(t),
|
|
122
|
+
() => this.G(),
|
|
123
|
+
n,
|
|
124
|
+
);
|
|
118
125
|
},
|
|
119
126
|
});
|
|
120
127
|
},
|
|
121
|
-
h.O.
|
|
128
|
+
h.O._e,
|
|
122
129
|
s,
|
|
123
130
|
);
|
|
124
131
|
}
|
|
125
132
|
G() {
|
|
126
133
|
null != this.q && (clearTimeout(this.q), (this.q = null));
|
|
127
134
|
}
|
|
128
|
-
|
|
129
|
-
this.G(),
|
|
130
|
-
(this.q = window.setTimeout(() => {
|
|
131
|
-
this.refreshFeatureFlags(s, i, e);
|
|
132
|
-
}, t)),
|
|
133
|
-
(this.I = t);
|
|
135
|
+
hs(t) {
|
|
136
|
+
this.G(), (this.q = t);
|
|
134
137
|
}
|
|
135
|
-
|
|
138
|
+
Ue(t) {
|
|
136
139
|
if (!this.B) return !1;
|
|
137
140
|
if (!t) {
|
|
138
|
-
const t = this.B.
|
|
141
|
+
const t = this.B.Ae();
|
|
139
142
|
if (null == t) return !1;
|
|
140
143
|
let s = !1;
|
|
141
144
|
if (!isNaN(t)) {
|
|
142
145
|
if (-1 === t) return N.info("Feature flag refreshes not allowed"), !1;
|
|
143
|
-
s = new Date().getTime() >= (this.
|
|
146
|
+
s = new Date().getTime() >= (this.Ce || 0) + 1e3 * t;
|
|
144
147
|
}
|
|
145
148
|
if (!s)
|
|
146
149
|
return (
|
|
147
150
|
N.info(`Feature flag refreshes were rate limited to ${t} seconds`), !1
|
|
148
151
|
);
|
|
149
152
|
}
|
|
150
|
-
return this.B.
|
|
153
|
+
return this.B.qe();
|
|
151
154
|
}
|
|
152
|
-
|
|
155
|
+
Ge() {
|
|
153
156
|
var s;
|
|
154
157
|
return (
|
|
155
|
-
(null === (s = this.C) || void 0 === s ? void 0 : s.
|
|
158
|
+
(null === (s = this.C) || void 0 === s ? void 0 : s.vs(t.gs.He)) || null
|
|
156
159
|
);
|
|
157
160
|
}
|
|
158
|
-
|
|
159
|
-
var s,
|
|
161
|
+
Je() {
|
|
162
|
+
var s, e;
|
|
160
163
|
null === (s = this.C) ||
|
|
161
164
|
void 0 === s ||
|
|
162
|
-
s.
|
|
165
|
+
s.Bs(t.gs.He, null === (e = this.T) || void 0 === e ? void 0 : e.Ss());
|
|
163
166
|
}
|
|
164
|
-
|
|
167
|
+
Ke() {
|
|
165
168
|
var t;
|
|
166
169
|
const s = null === (t = this.T) || void 0 === t ? void 0 : t.Ss(),
|
|
167
|
-
|
|
168
|
-
return null ==
|
|
170
|
+
e = this.Ge();
|
|
171
|
+
return null == e || s === e;
|
|
169
172
|
}
|
|
170
|
-
|
|
173
|
+
xe() {
|
|
171
174
|
if (!this.C) return;
|
|
172
175
|
const s = {};
|
|
173
|
-
for (const t of this.
|
|
174
|
-
const
|
|
175
|
-
s[t.id] =
|
|
176
|
+
for (const t of this.we) {
|
|
177
|
+
const e = t.bs();
|
|
178
|
+
s[t.id] = e;
|
|
176
179
|
}
|
|
177
|
-
this.C.
|
|
180
|
+
this.C.Bs(t.gs.$e, s), this.C.Bs(t.gs.Le, this.Ce), this.Je();
|
|
178
181
|
}
|
|
179
182
|
}
|