@braze/web-sdk 5.4.0 → 5.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/index.d.ts +109 -7
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +33 -31
- package/shared-lib/guid.js +3 -3
- package/shared-lib/indexed-db-adapter.js +20 -20
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +24 -24
- package/src/Banner/banner-factory.js +14 -0
- package/src/Banner/banner-provider-factory.js +19 -0
- package/src/Banner/banner-provider.js +198 -0
- package/src/Banner/banner.js +30 -0
- package/src/Banner/display/banner-to-html.js +57 -0
- package/src/Banner/display/destroy-banner-html.js +7 -0
- package/src/Banner/display/detect-banner-impressions.js +28 -0
- package/src/Banner/get-all-banners.js +13 -0
- package/src/Banner/get-banner.js +19 -0
- package/src/Banner/index.js +7 -0
- package/src/Banner/log-banner-click.js +22 -0
- package/src/Banner/log-banner-impressions.js +31 -0
- package/src/Banner/request-banners-refresh.js +35 -0
- package/src/Banner/subscribe-to-banners-updates.js +23 -0
- package/src/Banner/types.js +1 -0
- package/src/Banner/ui/insert-banner.js +24 -0
- package/src/Card/card-manager-factory.js +10 -10
- package/src/Card/card-manager.js +64 -58
- package/src/Card/display/card-display.js +77 -91
- package/src/Card/log-card-click.js +6 -6
- package/src/Card/log-card-dismissal.js +6 -5
- package/src/Card/log-card-impressions.js +11 -11
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +111 -105
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +19 -19
- package/src/Card/util/card-factory.js +58 -58
- package/src/ContentCards/content-cards-provider-factory.js +14 -14
- package/src/ContentCards/content-cards-provider.js +260 -262
- package/src/ContentCards/content-cards.js +5 -5
- package/src/ContentCards/get-cached-content-cards.js +3 -3
- package/src/ContentCards/request-content-cards-refresh.js +4 -4
- package/src/ContentCards/subscribe-to-content-cards-updates.js +13 -13
- package/src/ContentCards/ui/hide-content-cards.js +7 -7
- package/src/ContentCards/ui/show-content-cards.js +52 -52
- package/src/ContentCards/ui/toggle-content-cards.js +4 -4
- package/src/Core/add-sdk-metadata.js +9 -9
- package/src/Core/change-user.js +14 -14
- package/src/Core/destroy.js +3 -3
- package/src/Core/disable-sdk.js +13 -13
- package/src/Core/enable-sdk.js +9 -9
- package/src/Core/get-device-id.js +10 -10
- package/src/Core/get-user.js +2 -2
- package/src/Core/handle-braze-action.js +53 -53
- package/src/Core/initialize.js +2 -2
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/is-initialized.js +2 -2
- package/src/Core/log-custom-event.js +24 -24
- package/src/Core/log-purchase.js +38 -38
- package/src/Core/open-session.js +18 -18
- package/src/Core/remove-all-subscriptions.js +2 -2
- package/src/Core/remove-subscription.js +3 -3
- package/src/Core/request-immediate-data-flush.js +5 -5
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +6 -6
- package/src/Core/subscribe-to-sdk-authentication-failures.js +5 -5
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +10 -10
- package/src/FeatureFlags/feature-flag-factory.js +13 -13
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +13 -14
- package/src/FeatureFlags/feature-flags-provider.js +118 -116
- package/src/FeatureFlags/get-all-feature-flags.js +10 -10
- package/src/FeatureFlags/get-feature-flag.js +9 -9
- package/src/FeatureFlags/log-feature-flag-impression.js +18 -18
- package/src/FeatureFlags/refresh-feature-flags.js +6 -6
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +9 -9
- package/src/Feed/feed-provider-factory.js +12 -12
- package/src/Feed/feed-provider.js +59 -59
- package/src/Feed/feed.js +4 -4
- package/src/Feed/get-cached-feed.js +3 -3
- package/src/Feed/log-feed-displayed.js +5 -5
- package/src/Feed/request-feed-refresh.js +3 -3
- package/src/Feed/subscribe-to-feed-updates.js +4 -4
- package/src/Feed/ui/hide-feed.js +5 -5
- package/src/Feed/ui/show-feed.js +53 -53
- package/src/Feed/ui/toggle-feed.js +4 -4
- package/src/InAppMessage/defer-in-app-message.js +9 -9
- package/src/InAppMessage/display/html-message-display-utils.js +18 -164
- package/src/InAppMessage/display/html-message-to-html.js +55 -62
- package/src/InAppMessage/display/in-app-message-to-html.js +74 -74
- package/src/InAppMessage/display/modal-utils.js +17 -17
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +61 -61
- package/src/InAppMessage/in-app-message-manager-factory.js +9 -9
- package/src/InAppMessage/in-app-message-manager.js +158 -156
- package/src/InAppMessage/log-in-app-message-button-click.js +16 -16
- package/src/InAppMessage/log-in-app-message-click.js +11 -11
- package/src/InAppMessage/log-in-app-message-html-click.js +15 -15
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/control-message.js +15 -8
- package/src/InAppMessage/models/full-screen-message.js +34 -34
- package/src/InAppMessage/models/html-message.js +23 -23
- package/src/InAppMessage/models/in-app-message-button.js +10 -10
- package/src/InAppMessage/models/in-app-message.js +155 -155
- package/src/InAppMessage/models/modal-message.js +33 -33
- package/src/InAppMessage/models/slide-up-message.js +35 -35
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +3 -3
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +6 -6
- package/src/InAppMessage/ui/show-in-app-message.js +103 -103
- 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 +25 -25
- package/src/Push/push-manager.js +176 -176
- package/src/Push/request-push-permission.js +8 -8
- package/src/Push/unregister-push.js +4 -4
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +38 -38
- package/src/User/user.js +95 -92
- package/src/common/base-feed.js +9 -9
- package/src/common/base-provider.js +2 -2
- package/src/common/constants.js +1 -0
- package/src/common/detect-impression.js +18 -0
- package/src/common/event-logger.js +22 -22
- package/src/common/feed-display.js +53 -53
- package/src/index.js +1 -0
- package/src/l10n/l10n-manager-factory.js +15 -15
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +38 -38
- package/src/managers/braze-instance.js +212 -212
- package/src/managers/device-manager.js +30 -30
- package/src/managers/network-manager.js +231 -232
- package/src/managers/server-config-manager.js +99 -83
- package/src/managers/session-manager.js +46 -50
- package/src/managers/storage-manager-factory.js +13 -13
- package/src/managers/storage-manager.js +182 -180
- package/src/managers/subscription-manager.js +12 -12
- package/src/managers/utils.js +4 -4
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +9 -9
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +15 -15
- package/src/models/push-token.js +10 -10
- package/src/models/request-result.js +4 -4
- package/src/models/server-config.js +38 -34
- package/src/request-controller.js +228 -228
- 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 +10 -10
- package/src/triggers/models/filter.js +66 -66
- package/src/triggers/models/in-app-message-click-data.js +10 -10
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +6 -6
- package/src/triggers/models/push-click-data.js +5 -5
- package/src/triggers/models/trigger-condition.js +46 -46
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +33 -33
- package/src/triggers/triggers-provider-factory.js +16 -16
- package/src/triggers/triggers-provider.js +156 -154
- package/src/ui/js/attach-css.js +7 -7
- package/src/ui/js/banner-css.js +11 -0
- package/src/ui/js/feed-css.js +4 -4
- package/src/ui/js/iam-css.js +4 -4
- package/src/ui/js/index.js +1 -0
- package/src/ui/js/load-font-awesome.js +8 -8
- package/src/util/base-device-parser.js +9 -9
- package/src/util/braze-actions.js +32 -32
- package/src/util/browser-detector.js +27 -27
- package/src/util/client-hints-parser.js +9 -9
- package/src/util/code-utils.js +5 -5
- package/src/util/component-utils.js +5 -5
- package/src/util/deprecation-utils.js +3 -3
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +13 -13
- package/src/util/html-display-utils.js +158 -0
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +21 -21
- package/src/util/request-header-utils.js +31 -30
- package/src/util/string-utils.js +2 -2
- package/src/util/user-agent-parser.js +9 -9
- package/src/util/validation-utils.js +89 -85
- package/src/util/window-utils.js +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import rr from "../common/base-feed.js";
|
|
2
2
|
import { logCardClick, logCardImpressions } from "../Card/index.js";
|
|
3
3
|
import { requestContentCardsRefresh } from "./request-content-cards-refresh.js";
|
|
4
|
-
export default class ContentCards extends
|
|
4
|
+
export default class ContentCards extends rr {
|
|
5
5
|
constructor(r, e) {
|
|
6
6
|
super(r, e);
|
|
7
7
|
}
|
|
@@ -14,11 +14,11 @@ export default class ContentCards extends x {
|
|
|
14
14
|
logCardClick(r) {
|
|
15
15
|
return logCardClick(r, !0);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
dr() {
|
|
18
18
|
requestContentCardsRefresh();
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
ur() {
|
|
21
21
|
return !0;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
ContentCards.
|
|
24
|
+
ContentCards.ar = 6e4;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import W from "./content-cards-provider-factory.js";
|
|
2
|
+
import r from "../managers/braze-instance.js";
|
|
3
3
|
export function getCachedContentCards() {
|
|
4
|
-
if (
|
|
4
|
+
if (r.rr()) return W.m().ki(!1);
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export function requestContentCardsRefresh(
|
|
4
|
-
if (
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import W from "./content-cards-provider-factory.js";
|
|
3
|
+
export function requestContentCardsRefresh(e, t) {
|
|
4
|
+
if (r.rr()) return W.m().zi(e, t);
|
|
5
5
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export function subscribeToContentCardsUpdates(
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
if (!
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
const
|
|
11
|
-
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import W from "./content-cards-provider-factory.js";
|
|
3
|
+
export function subscribeToContentCardsUpdates(t) {
|
|
4
|
+
if (!r.rr()) return;
|
|
5
|
+
const n = W.m(),
|
|
6
|
+
o = n.Fs(t);
|
|
7
|
+
if (!n.Ts()) {
|
|
8
|
+
const t = r.nn();
|
|
9
|
+
if (t) {
|
|
10
|
+
const r = t.rn(() => {
|
|
11
|
+
n.zi();
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
r && n.Rs(r);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return o;
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { destroyFeedHtml as
|
|
3
|
-
export function hideContentCards(
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
6
|
-
for (let
|
|
7
|
-
(null ==
|
|
1
|
+
import r from "../../managers/braze-instance.js";
|
|
2
|
+
import { destroyFeedHtml as ee } from "../../common/feed-display.js";
|
|
3
|
+
export function hideContentCards(e) {
|
|
4
|
+
if (!r.rr()) return;
|
|
5
|
+
const n = document.querySelectorAll(".ab-feed");
|
|
6
|
+
for (let o = 0; o < n.length; o++)
|
|
7
|
+
(null == e || (null != e && n[o].parentNode === e)) && ee(n[o]);
|
|
8
8
|
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r, { OPTIONS as z } from "../../managers/braze-instance.js";
|
|
2
2
|
import { ContentCards, subscribeToContentCardsUpdates } from "../index.js";
|
|
3
|
-
import
|
|
3
|
+
import W from "../content-cards-provider-factory.js";
|
|
4
4
|
import {
|
|
5
|
-
destroyFeedHtml as
|
|
6
|
-
detectFeedImpressions as
|
|
7
|
-
feedToHtml as
|
|
8
|
-
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as
|
|
9
|
-
refreshFeed as
|
|
10
|
-
registerFeedSubscriptionId as
|
|
11
|
-
updateFeedCards as
|
|
5
|
+
destroyFeedHtml as ee,
|
|
6
|
+
detectFeedImpressions as nn,
|
|
7
|
+
feedToHtml as tn,
|
|
8
|
+
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as en,
|
|
9
|
+
refreshFeed as on,
|
|
10
|
+
registerFeedSubscriptionId as rn,
|
|
11
|
+
updateFeedCards as an,
|
|
12
12
|
} from "../../common/feed-display.js";
|
|
13
|
-
import { setCardHeight as
|
|
14
|
-
import { setupFeedUI as
|
|
15
|
-
import { logger as
|
|
13
|
+
import { setCardHeight as sn } from "../../Card/display/card-display.js";
|
|
14
|
+
import { setupFeedUI as fn } from "../../ui/js/index.js";
|
|
15
|
+
import { logger as N } from "../../../shared-lib/index.js";
|
|
16
16
|
export function showContentCards(n, t) {
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
null == n && ((n = document.body), (
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
"function" == typeof t &&
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(null ==
|
|
28
|
-
new Date().valueOf() -
|
|
29
|
-
(null ==
|
|
30
|
-
(
|
|
31
|
-
`Cached content cards were older than max TTL of ${ContentCards.
|
|
17
|
+
if (!r.rr()) return;
|
|
18
|
+
fn();
|
|
19
|
+
let e = !1;
|
|
20
|
+
null == n && ((n = document.body), (e = !0));
|
|
21
|
+
const o = r.sr(z.tn) || r.sr(z.en) || !1,
|
|
22
|
+
i = W.m().ki(!1);
|
|
23
|
+
"function" == typeof t && an(i, t(i.cards.slice()), i.lastUpdated, null, o);
|
|
24
|
+
const a = tn(i, o, e),
|
|
25
|
+
s = W.m(),
|
|
26
|
+
f = s.pi();
|
|
27
|
+
(null == i.lastUpdated ||
|
|
28
|
+
new Date().valueOf() - i.lastUpdated.valueOf() > ContentCards.ar) &&
|
|
29
|
+
(null == f || new Date().valueOf() - f > ContentCards.ar) &&
|
|
30
|
+
(N.info(
|
|
31
|
+
`Cached content cards were older than max TTL of ${ContentCards.ar} ms, requesting an update from the server.`,
|
|
32
32
|
),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const e =
|
|
33
|
+
on(i, a),
|
|
34
|
+
s.vi(new Date().valueOf()));
|
|
35
|
+
const l = new Date().valueOf(),
|
|
36
|
+
c = subscribeToContentCardsUpdates(function (n) {
|
|
37
|
+
const e = a.querySelectorAll(".ab-refresh-button")[0];
|
|
38
38
|
if (null != e) {
|
|
39
39
|
let n = 500,
|
|
40
|
-
t = (n -= new Date().valueOf() -
|
|
41
|
-
const o =
|
|
40
|
+
t = (n -= new Date().valueOf() - l);
|
|
41
|
+
const o = a.getAttribute(en);
|
|
42
42
|
o && ((t = parseInt(o)), isNaN(t) || (n -= new Date().valueOf() - t)),
|
|
43
43
|
setTimeout(
|
|
44
44
|
function () {
|
|
@@ -47,31 +47,31 @@ export function showContentCards(n, t) {
|
|
|
47
47
|
Math.max(n, 0),
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
-
let
|
|
51
|
-
"function" == typeof t && (
|
|
52
|
-
|
|
50
|
+
let r = n.cards;
|
|
51
|
+
"function" == typeof t && (r = t(r.slice())),
|
|
52
|
+
an(i, r, n.lastUpdated, a, o);
|
|
53
53
|
});
|
|
54
|
-
|
|
55
|
-
const
|
|
54
|
+
rn(c, a);
|
|
55
|
+
const u = function (n) {
|
|
56
56
|
const t = n.querySelectorAll(".ab-feed");
|
|
57
|
-
let
|
|
58
|
-
for (let
|
|
59
|
-
null !=
|
|
60
|
-
? (
|
|
61
|
-
: n.appendChild(
|
|
57
|
+
let o = null;
|
|
58
|
+
for (let e = 0; e < t.length; e++) t[e].parentNode === n && (o = t[e]);
|
|
59
|
+
null != o
|
|
60
|
+
? (ee(o), null != o.parentNode && o.parentNode.replaceChild(a, o))
|
|
61
|
+
: n.appendChild(a),
|
|
62
62
|
setTimeout(function () {
|
|
63
|
-
|
|
63
|
+
a.className = a.className.replace("ab-hide", "ab-show");
|
|
64
64
|
}, 0),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
e && a.focus(),
|
|
66
|
+
nn(i, a),
|
|
67
|
+
sn(i.cards, n);
|
|
68
68
|
};
|
|
69
|
-
var
|
|
69
|
+
var d;
|
|
70
70
|
null != n
|
|
71
|
-
?
|
|
71
|
+
? u(n)
|
|
72
72
|
: (window.onload =
|
|
73
|
-
((
|
|
73
|
+
((d = window.onload),
|
|
74
74
|
function () {
|
|
75
|
-
"function" == typeof
|
|
75
|
+
"function" == typeof d && d(new Event("oldLoad")), u(document.body);
|
|
76
76
|
}));
|
|
77
77
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from "../../managers/braze-instance.js";
|
|
2
2
|
import { hideContentCards, showContentCards } from "../index.js";
|
|
3
|
-
export function toggleContentCards(
|
|
4
|
-
|
|
3
|
+
export function toggleContentCards(e, n) {
|
|
4
|
+
r.rr() &&
|
|
5
5
|
(document.querySelectorAll(".ab-feed").length > 0
|
|
6
6
|
? hideContentCards()
|
|
7
|
-
: showContentCards(
|
|
7
|
+
: showContentCards(e, n));
|
|
8
8
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import aa from "../managers/braze-instance.js";
|
|
2
2
|
import BrazeSdkMetadata from "./braze-sdk-metadata.js";
|
|
3
3
|
import {
|
|
4
|
-
isArray as
|
|
5
|
-
validateValueIsFromEnum as
|
|
4
|
+
isArray as w,
|
|
5
|
+
validateValueIsFromEnum as ta,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
|
-
import { logger as
|
|
7
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
8
8
|
export function addSdkMetadata(a) {
|
|
9
|
-
if (!
|
|
10
|
-
const t =
|
|
9
|
+
if (!aa.rr()) return;
|
|
10
|
+
const t = aa.g();
|
|
11
11
|
if (t) {
|
|
12
|
-
if (!
|
|
12
|
+
if (!w(a))
|
|
13
13
|
return (
|
|
14
|
-
|
|
14
|
+
N.error("Cannot set SDK metadata because metadata is not an array."), !1
|
|
15
15
|
);
|
|
16
16
|
for (const t of a)
|
|
17
17
|
if (
|
|
18
|
-
!
|
|
18
|
+
!ta(
|
|
19
19
|
BrazeSdkMetadata,
|
|
20
20
|
t,
|
|
21
21
|
"sdkMetadata contained an invalid value.",
|
package/src/Core/change-user.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getByteLength as
|
|
3
|
-
import { logger as
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { getByteLength as er } from "../util/string-utils.js";
|
|
3
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
4
4
|
import { User } from "../User/index.js";
|
|
5
|
-
import { validateStandardString as
|
|
6
|
-
export function changeUser(
|
|
7
|
-
if (!
|
|
8
|
-
if (null ==
|
|
9
|
-
return void
|
|
10
|
-
if (
|
|
11
|
-
return void
|
|
12
|
-
`Rejected user id "${
|
|
5
|
+
import { validateStandardString as ir } from "../util/validation-utils.js";
|
|
6
|
+
export function changeUser(e, i) {
|
|
7
|
+
if (!r.rr()) return;
|
|
8
|
+
if (null == e || 0 === e.length || e != e)
|
|
9
|
+
return void N.error("changeUser requires a non-empty userId.");
|
|
10
|
+
if (er(e) > User.mr)
|
|
11
|
+
return void N.error(
|
|
12
|
+
`Rejected user id "${e}" because it is longer than ${User.mr} bytes.`,
|
|
13
13
|
);
|
|
14
|
-
if (null !=
|
|
15
|
-
const
|
|
16
|
-
|
|
14
|
+
if (null != i && !ir(i, "set signature for new user", "signature")) return;
|
|
15
|
+
const t = r.nn();
|
|
16
|
+
t && t.changeUser(e.toString(), r.lr(), i);
|
|
17
17
|
}
|
package/src/Core/destroy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { logger as
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
3
3
|
export function destroy() {
|
|
4
|
-
|
|
4
|
+
N.info("Destroying Braze instance"), r.destroy(!0);
|
|
5
5
|
}
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { logger as
|
|
3
|
-
import
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
|
|
3
|
+
import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
|
|
4
4
|
export function disableSDK() {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
new
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
const e = r.nn();
|
|
6
|
+
e && e.requestImmediateDataFlush();
|
|
7
|
+
const n = new ne.ne(null, !0),
|
|
8
|
+
s = "This-cookie-will-expire-in-" + n.se();
|
|
9
|
+
n.store(t.ae, s);
|
|
10
|
+
const a = it.Gs._s;
|
|
11
|
+
new it(a, N).setItem(a.Os.ie, a.oe, !0),
|
|
12
|
+
N.info("disableSDK was called"),
|
|
13
|
+
r.destroy(!1),
|
|
14
|
+
r.re(!0);
|
|
15
15
|
}
|
package/src/Core/enable-sdk.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { logger as
|
|
3
|
-
import
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { logger as N, IndexedDBAdapter as it } from "../../shared-lib/index.js";
|
|
3
|
+
import ne, { STORAGE_KEYS as t } from "../managers/storage-manager.js";
|
|
4
4
|
export function enableSDK() {
|
|
5
|
-
new
|
|
6
|
-
const
|
|
7
|
-
new
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
new ne.ne(null, !0).remove(t.ae);
|
|
6
|
+
const e = it.Gs._s;
|
|
7
|
+
new it(e, N).me(e.Os.ie, e.oe),
|
|
8
|
+
N.info("enableSDK was called"),
|
|
9
|
+
r.destroy(!1),
|
|
10
|
+
r.re(!1);
|
|
11
11
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { logger as
|
|
3
|
-
export function getDeviceId(
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
7
|
-
const
|
|
8
|
-
if ("function" != typeof
|
|
9
|
-
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
3
|
+
export function getDeviceId(e) {
|
|
4
|
+
if (!r.rr()) return;
|
|
5
|
+
const t = r.te();
|
|
6
|
+
if (!t) return;
|
|
7
|
+
const i = t.ce().id;
|
|
8
|
+
if ("function" != typeof e) return i;
|
|
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()`)",
|
|
11
11
|
),
|
|
12
|
-
|
|
12
|
+
e(i);
|
|
13
13
|
}
|
package/src/Core/get-user.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { logger as
|
|
2
|
-
import { BRAZE_MUST_BE_INITIALIZED_ERROR as
|
|
3
|
-
import
|
|
1
|
+
import { logger as N } from "../../shared-lib/index.js";
|
|
2
|
+
import { BRAZE_MUST_BE_INITIALIZED_ERROR as p } from "../common/constants.js";
|
|
3
|
+
import r from "../managers/braze-instance.js";
|
|
4
4
|
import {
|
|
5
|
-
BRAZE_ACTIONS as
|
|
6
|
-
getDecodedBrazeAction as
|
|
5
|
+
BRAZE_ACTIONS as oo,
|
|
6
|
+
getDecodedBrazeAction as eo,
|
|
7
7
|
} from "../util/braze-actions.js";
|
|
8
|
-
import
|
|
9
|
-
import { OperatingSystems as
|
|
8
|
+
import ro from "../util/browser-detector.js";
|
|
9
|
+
import { OperatingSystems as so } from "../util/device-constants.js";
|
|
10
10
|
import {
|
|
11
|
-
BRAZE_ACTION_URI_REGEX as
|
|
12
|
-
isValidBrazeActionJson as
|
|
11
|
+
BRAZE_ACTION_URI_REGEX as to,
|
|
12
|
+
isValidBrazeActionJson as io,
|
|
13
13
|
} from "../util/validation-utils.js";
|
|
14
|
-
import { WindowUtils as
|
|
15
|
-
import { getUser as
|
|
16
|
-
export function _handleBrazeAction(o,
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
return void
|
|
14
|
+
import { WindowUtils as no } from "../util/window-utils.js";
|
|
15
|
+
import { getUser as ao } from "./get-user.js";
|
|
16
|
+
export function _handleBrazeAction(o, e, s) {
|
|
17
|
+
if (r.rr())
|
|
18
|
+
if (to.test(o)) {
|
|
19
|
+
const e = eo(o);
|
|
20
|
+
if (!e) return;
|
|
21
|
+
const s = (o) => {
|
|
22
|
+
if (!io(o))
|
|
23
|
+
return void N.error(
|
|
24
24
|
`Decoded Braze Action json is invalid: ${JSON.stringify(
|
|
25
25
|
o,
|
|
26
26
|
null,
|
|
27
27
|
2,
|
|
28
28
|
)}`,
|
|
29
29
|
);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
const e = o[
|
|
36
|
-
for (const o of e)
|
|
30
|
+
const e = oo.properties.type,
|
|
31
|
+
t = oo.properties.eo,
|
|
32
|
+
i = oo.properties.so,
|
|
33
|
+
n = o[e];
|
|
34
|
+
if (n === oo.types.io) {
|
|
35
|
+
const e = o[t];
|
|
36
|
+
for (const o of e) s(o);
|
|
37
37
|
} else {
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
switch (
|
|
41
|
-
case
|
|
38
|
+
const e = o[i];
|
|
39
|
+
let s, t;
|
|
40
|
+
switch (n) {
|
|
41
|
+
case oo.types.logCustomEvent:
|
|
42
42
|
import("./log-custom-event.js").then(
|
|
43
43
|
({ logCustomEvent: logCustomEvent }) => {
|
|
44
|
-
|
|
45
|
-
? ((
|
|
46
|
-
logCustomEvent(...
|
|
47
|
-
:
|
|
44
|
+
r.nt()
|
|
45
|
+
? ((t = Array.prototype.slice.call(e)),
|
|
46
|
+
logCustomEvent(...t))
|
|
47
|
+
: N.error(p);
|
|
48
48
|
},
|
|
49
49
|
);
|
|
50
50
|
break;
|
|
51
|
-
case
|
|
51
|
+
case oo.types.requestPushPermission:
|
|
52
52
|
import("../Push/request-push-permission.js").then(
|
|
53
53
|
({ requestPushPermission: requestPushPermission }) => {
|
|
54
|
-
|
|
55
|
-
? "Safari" ===
|
|
54
|
+
r.nt()
|
|
55
|
+
? "Safari" === ro.browser && ro.OS === so.ao
|
|
56
56
|
? window.navigator.standalone && requestPushPermission()
|
|
57
57
|
: requestPushPermission()
|
|
58
|
-
:
|
|
58
|
+
: N.error(p);
|
|
59
59
|
},
|
|
60
60
|
);
|
|
61
61
|
break;
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case
|
|
67
|
-
case
|
|
68
|
-
case
|
|
69
|
-
if (((
|
|
70
|
-
|
|
62
|
+
case oo.types.setEmailNotificationSubscriptionType:
|
|
63
|
+
case oo.types.setPushNotificationSubscriptionType:
|
|
64
|
+
case oo.types.setCustomUserAttribute:
|
|
65
|
+
case oo.types.addToSubscriptionGroup:
|
|
66
|
+
case oo.types.removeFromSubscriptionGroup:
|
|
67
|
+
case oo.types.addToCustomAttributeArray:
|
|
68
|
+
case oo.types.removeFromCustomAttributeArray:
|
|
69
|
+
if (((s = ao()), s)) {
|
|
70
|
+
s[n](...Array.prototype.slice.call(e));
|
|
71
71
|
}
|
|
72
72
|
break;
|
|
73
|
-
case
|
|
74
|
-
case
|
|
75
|
-
(
|
|
73
|
+
case oo.types.co:
|
|
74
|
+
case oo.types.mo:
|
|
75
|
+
(t = Array.prototype.slice.call(e)), no.openUri(...t);
|
|
76
76
|
break;
|
|
77
77
|
default:
|
|
78
|
-
|
|
78
|
+
N.info(`Ignoring unknown Braze Action: ${n}`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
} else
|
|
82
|
+
s(e);
|
|
83
|
+
} else no.openUri(o, e, s);
|
|
84
84
|
}
|
|
85
85
|
export function handleBrazeAction(o, e) {
|
|
86
86
|
_handleBrazeAction(o, e);
|
package/src/Core/initialize.js
CHANGED
package/src/Core/is-disabled.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { logger as
|
|
4
|
-
import
|
|
5
|
-
import { TriggersProviderFactory as
|
|
1
|
+
import r from "../managers/braze-instance.js";
|
|
2
|
+
import c from "../common/event-logger.js";
|
|
3
|
+
import { logger as N, EventTypes as d } from "../../shared-lib/index.js";
|
|
4
|
+
import et from "../triggers/models/trigger-events.js";
|
|
5
|
+
import { TriggersProviderFactory as ot } from "../triggers/triggers-provider-factory.js";
|
|
6
6
|
import {
|
|
7
|
-
validateCustomProperties as
|
|
8
|
-
validateCustomString as
|
|
7
|
+
validateCustomProperties as rt,
|
|
8
|
+
validateCustomString as nt,
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
|
-
import { LOG_CUSTOM_EVENT_STRING as
|
|
11
|
-
export function logCustomEvent(t,
|
|
12
|
-
if (!
|
|
10
|
+
import { LOG_CUSTOM_EVENT_STRING as mt } from "../common/constants.js";
|
|
11
|
+
export function logCustomEvent(t, e) {
|
|
12
|
+
if (!r.rr()) return !1;
|
|
13
13
|
if (null == t || t.length <= 0)
|
|
14
14
|
return (
|
|
15
|
-
|
|
15
|
+
N.error(
|
|
16
16
|
`logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`,
|
|
17
17
|
),
|
|
18
18
|
!1
|
|
19
19
|
);
|
|
20
|
-
if (!
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (!nt(t, "log custom event", "the event name")) return !1;
|
|
21
|
+
const [o, n] = rt(
|
|
22
|
+
e,
|
|
23
|
+
mt,
|
|
24
24
|
"eventProperties",
|
|
25
25
|
`log custom event "${t}"`,
|
|
26
26
|
"event",
|
|
27
27
|
);
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
return
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
for (const
|
|
28
|
+
if (!o) return !1;
|
|
29
|
+
const i = r.v();
|
|
30
|
+
if (i && i.ge(t))
|
|
31
|
+
return N.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1;
|
|
32
|
+
const s = c.ds(d.CustomEvent, { n: t, p: n });
|
|
33
|
+
if (s.ss) {
|
|
34
|
+
N.info(`Logged custom event "${t}".`);
|
|
35
|
+
for (const o of s.fe) ot.m().ue(et.ve, [t, e], o);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return s.ss;
|
|
38
38
|
}
|