@braze/web-sdk 5.0.1 → 5.1.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 +10 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +29 -29
- package/shared-lib/guid.js +3 -3
- package/shared-lib/index.js +6 -0
- package/shared-lib/indexed-db-adapter.js +70 -70
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +21 -21
- package/src/Card/card-manager.js +43 -45
- package/src/Card/display/card-display.js +60 -60
- package/src/Card/log-card-click.js +4 -4
- package/src/Card/log-card-dismissal.js +2 -3
- package/src/Card/log-card-impressions.js +7 -7
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +73 -73
- 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 +68 -68
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +255 -245
- package/src/ContentCards/content-cards.js +2 -2
- 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 +6 -6
- package/src/ContentCards/ui/hide-content-cards.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +24 -24
- package/src/ContentCards/ui/toggle-content-cards.js +1 -1
- package/src/Core/add-sdk-metadata.js +21 -19
- package/src/Core/change-user.js +10 -10
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +11 -11
- package/src/Core/enable-sdk.js +7 -7
- package/src/Core/get-device-id.js +6 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +41 -41
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +15 -15
- package/src/Core/log-purchase.js +31 -37
- package/src/Core/open-session.js +12 -12
- package/src/Core/remove-all-subscriptions.js +1 -1
- package/src/Core/remove-subscription.js +1 -1
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -4
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +9 -9
- package/src/FeatureFlags/feature-flag-factory.js +12 -12
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +3 -2
- package/src/FeatureFlags/feature-flags-provider.js +108 -80
- package/src/FeatureFlags/get-all-feature-flags.js +5 -5
- package/src/FeatureFlags/get-feature-flag.js +6 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +15 -13
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +7 -4
- package/src/Feed/feed-provider-factory.js +2 -2
- package/src/Feed/feed-provider.js +44 -44
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +4 -4
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/hide-feed.js +1 -1
- package/src/Feed/ui/show-feed.js +28 -28
- package/src/Feed/ui/toggle-feed.js +1 -1
- package/src/InAppMessage/defer-in-app-message.js +5 -5
- package/src/InAppMessage/display/html-message-to-html.js +54 -54
- package/src/InAppMessage/display/in-app-message-to-html.js +79 -79
- package/src/InAppMessage/display/modal-utils.js +8 -8
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +49 -49
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +143 -138
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/full-screen-message.js +33 -33
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +6 -6
- package/src/InAppMessage/models/in-app-message.js +99 -99
- package/src/InAppMessage/models/modal-message.js +32 -32
- package/src/InAppMessage/models/slide-up-message.js +28 -28
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +81 -81
- package/src/Push/is-push-blocked.js +1 -1
- package/src/Push/is-push-permission-granted.js +1 -1
- package/src/Push/is-push-supported.js +1 -1
- package/src/Push/push-manager-factory.js +5 -5
- package/src/Push/push-manager.js +176 -173
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +29 -29
- package/src/User/user.js +72 -74
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -0
- package/src/common/event-logger.js +21 -18
- package/src/common/feed-display.js +44 -44
- package/src/l10n/l10n-manager-factory.js +3 -3
- package/src/l10n/l10n-manager.js +7 -7
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +188 -190
- package/src/managers/device-manager.js +28 -28
- package/src/managers/network-manager.js +189 -138
- package/src/managers/server-config-manager.js +69 -53
- package/src/managers/session-manager.js +34 -30
- package/src/managers/storage-manager-factory.js +16 -16
- package/src/managers/storage-manager.js +178 -163
- package/src/managers/subscription-manager.js +12 -12
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +4 -4
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +34 -14
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +32 -23
- package/src/request-controller.js +186 -179
- package/src/triggers/models/custom-event-data.js +7 -7
- package/src/triggers/models/custom-event-property-data.js +10 -10
- package/src/triggers/models/filter-set.js +13 -13
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +10 -10
- package/src/triggers/models/push-click-data.js +7 -7
- package/src/triggers/models/trigger-condition.js +57 -59
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +38 -38
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +127 -130
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +35 -35
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +8 -8
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +4 -4
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +18 -18
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +18 -18
- package/src/util/request-header-utils.js +39 -37
- package/src/util/string-utils.js +10 -10
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +37 -39
- package/src/util/window-utils.js +3 -3
- package/shared-lib/braze-shared-lib.js +0 -8
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
2
|
import g from "./content-cards-provider-factory.js";
|
|
3
3
|
export function subscribeToContentCardsUpdates(r) {
|
|
4
|
-
if (!e.
|
|
5
|
-
const t = g.
|
|
6
|
-
n = t.
|
|
7
|
-
if (!t.
|
|
4
|
+
if (!e.X()) return;
|
|
5
|
+
const t = g.rr(),
|
|
6
|
+
n = t.ei(r);
|
|
7
|
+
if (!t.ps()) {
|
|
8
8
|
const r = e.cr();
|
|
9
9
|
if (r) {
|
|
10
|
-
const n = r.
|
|
11
|
-
t.
|
|
10
|
+
const n = r.mr(() => {
|
|
11
|
+
t.Fs();
|
|
12
12
|
});
|
|
13
13
|
n && t.vs(n);
|
|
14
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "../../managers/braze-instance.js";
|
|
2
2
|
import { destroyFeedHtml as z } from "../../common/feed-display.js";
|
|
3
3
|
export function hideContentCards(n) {
|
|
4
|
-
if (!e.
|
|
4
|
+
if (!e.X()) return;
|
|
5
5
|
const o = document.querySelectorAll(".ab-feed");
|
|
6
6
|
for (let e = 0; e < o.length; e++)
|
|
7
7
|
(null == n || (null != n && o[e].parentNode === n)) && z(o[e]);
|
|
@@ -7,31 +7,31 @@ import {
|
|
|
7
7
|
feedToHtml as I,
|
|
8
8
|
LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE as M,
|
|
9
9
|
refreshFeed as $,
|
|
10
|
-
registerFeedSubscriptionId as
|
|
11
|
-
updateFeedCards as
|
|
10
|
+
registerFeedSubscriptionId as B,
|
|
11
|
+
updateFeedCards as F,
|
|
12
12
|
} from "../../common/feed-display.js";
|
|
13
|
-
import { setCardHeight as
|
|
14
|
-
import { setupFeedUI as
|
|
15
|
-
import r from "../../../shared-lib/
|
|
13
|
+
import { setCardHeight as G } from "../../Card/display/card-display.js";
|
|
14
|
+
import { setupFeedUI as H } from "../../ui/js/index.js";
|
|
15
|
+
import { logger as r } from "../../../shared-lib/index.js";
|
|
16
16
|
export function showContentCards(n, t) {
|
|
17
|
-
if (!e.
|
|
18
|
-
|
|
17
|
+
if (!e.X()) return;
|
|
18
|
+
H();
|
|
19
19
|
let o = !1;
|
|
20
20
|
null == n && ((n = document.body), (o = !0));
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
"function" == typeof t &&
|
|
24
|
-
const s = I(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(null ==
|
|
28
|
-
new Date().valueOf() -
|
|
29
|
-
(null ==
|
|
30
|
-
(r.
|
|
31
|
-
`Cached content cards were older than max TTL of ${ContentCards.
|
|
21
|
+
const i = e.nn(L.tn) || e.nn(L.en) || !1,
|
|
22
|
+
a = g.rr().ks(!1);
|
|
23
|
+
"function" == typeof t && F(a, t(a.cards.slice()), a.lastUpdated, null, i);
|
|
24
|
+
const s = I(a, i, o),
|
|
25
|
+
f = g.rr(),
|
|
26
|
+
l = f.fs();
|
|
27
|
+
(null == a.lastUpdated ||
|
|
28
|
+
new Date().valueOf() - a.lastUpdated.valueOf() > ContentCards.ur) &&
|
|
29
|
+
(null == l || new Date().valueOf() - l > ContentCards.ur) &&
|
|
30
|
+
(r.info(
|
|
31
|
+
`Cached content cards were older than max TTL of ${ContentCards.ur} ms, requesting an update from the server.`,
|
|
32
32
|
),
|
|
33
|
-
$(
|
|
34
|
-
|
|
33
|
+
$(a, s),
|
|
34
|
+
f.ds(new Date().valueOf()));
|
|
35
35
|
const c = new Date().valueOf(),
|
|
36
36
|
u = subscribeToContentCardsUpdates(function (n) {
|
|
37
37
|
const e = s.querySelectorAll(".ab-refresh-button")[0];
|
|
@@ -49,9 +49,9 @@ export function showContentCards(n, t) {
|
|
|
49
49
|
}
|
|
50
50
|
let o = n.cards;
|
|
51
51
|
"function" == typeof t && (o = t(o.slice())),
|
|
52
|
-
|
|
52
|
+
F(a, o, n.lastUpdated, s, i);
|
|
53
53
|
});
|
|
54
|
-
|
|
54
|
+
B(u, s);
|
|
55
55
|
const d = function (n) {
|
|
56
56
|
const t = n.querySelectorAll(".ab-feed");
|
|
57
57
|
let e = null;
|
|
@@ -63,8 +63,8 @@ export function showContentCards(n, t) {
|
|
|
63
63
|
s.className = s.className.replace("ab-hide", "ab-show");
|
|
64
64
|
}, 0),
|
|
65
65
|
o && s.focus(),
|
|
66
|
-
q(
|
|
67
|
-
|
|
66
|
+
q(a, s),
|
|
67
|
+
G(a.cards, n);
|
|
68
68
|
};
|
|
69
69
|
var m;
|
|
70
70
|
null != n
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "../../managers/braze-instance.js";
|
|
2
2
|
import { hideContentCards, showContentCards } from "../index.js";
|
|
3
3
|
export function toggleContentCards(n, o) {
|
|
4
|
-
e.
|
|
4
|
+
e.X() &&
|
|
5
5
|
(document.querySelectorAll(".ab-feed").length > 0
|
|
6
6
|
? hideContentCards()
|
|
7
7
|
: showContentCards(n, o));
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import K 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 j,
|
|
5
|
+
validateValueIsFromEnum as J,
|
|
6
6
|
} from "../util/code-utils.js";
|
|
7
|
-
import r from "../../shared-lib/
|
|
7
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
8
8
|
export function addSdkMetadata(a) {
|
|
9
|
-
if (!K.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
if (!K.X()) return;
|
|
10
|
+
const t = K.nr();
|
|
11
|
+
if (t) {
|
|
12
|
+
if (!j(a))
|
|
13
|
+
return (
|
|
14
|
+
r.error("Cannot set SDK metadata because metadata is not an array."), !1
|
|
15
|
+
);
|
|
16
|
+
for (const t of a)
|
|
17
|
+
if (
|
|
18
|
+
!J(
|
|
19
|
+
BrazeSdkMetadata,
|
|
20
|
+
t,
|
|
21
|
+
"sdkMetadata contained an invalid value.",
|
|
22
|
+
"BrazeSdkMetadata",
|
|
23
|
+
)
|
|
21
24
|
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return t && t.addSdkMetadata(a), !0;
|
|
25
|
+
return !1;
|
|
26
|
+
return t.addSdkMetadata(a), !0;
|
|
27
|
+
}
|
|
26
28
|
}
|
package/src/Core/change-user.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import { getByteLength as
|
|
3
|
-
import r from "../../shared-lib/
|
|
2
|
+
import { getByteLength as O } from "../util/string-utils.js";
|
|
3
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
4
4
|
import { User } from "../User/index.js";
|
|
5
|
-
import { validateStandardString as
|
|
5
|
+
import { validateStandardString as P } from "../util/validation-utils.js";
|
|
6
6
|
export function changeUser(i, t) {
|
|
7
|
-
if (!e.
|
|
7
|
+
if (!e.X()) return;
|
|
8
8
|
if (null == i || 0 === i.length || i != i)
|
|
9
|
-
return void r.
|
|
10
|
-
if (
|
|
11
|
-
return void r.
|
|
9
|
+
return void r.error("changeUser requires a non-empty userId.");
|
|
10
|
+
if (O(i) > User.lr)
|
|
11
|
+
return void r.error(
|
|
12
12
|
`Rejected user id "${i}" because it is longer than ${User.lr} bytes.`,
|
|
13
13
|
);
|
|
14
|
-
if (null != t && !
|
|
15
|
-
const
|
|
16
|
-
|
|
14
|
+
if (null != t && !P(t, "set signature for new user", "signature")) return;
|
|
15
|
+
const n = e.cr();
|
|
16
|
+
n && n.changeUser(i.toString(), e.gr(), t);
|
|
17
17
|
}
|
package/src/Core/destroy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import r from "../../shared-lib/
|
|
2
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
3
3
|
export function destroy() {
|
|
4
|
-
r.
|
|
4
|
+
r.info("Destroying Braze instance"), e.destroy(!0);
|
|
5
5
|
}
|
package/src/Core/disable-sdk.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import r from "../../shared-lib/
|
|
3
|
-
import
|
|
2
|
+
import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
3
|
+
import Q, { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
4
4
|
export function disableSDK() {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const s = new
|
|
8
|
-
|
|
9
|
-
s.store(
|
|
10
|
-
const
|
|
11
|
-
new
|
|
12
|
-
r.
|
|
5
|
+
const n = e.cr();
|
|
6
|
+
n && n.requestImmediateDataFlush();
|
|
7
|
+
const s = new Q.ee(null, !0),
|
|
8
|
+
a = "This-cookie-will-expire-in-" + s.ne();
|
|
9
|
+
s.store(o.se, a);
|
|
10
|
+
const i = A.Yt.Qt;
|
|
11
|
+
new A(i, r).setItem(i.ss.ae, i.ie, !0),
|
|
12
|
+
r.info("disableSDK was called"),
|
|
13
13
|
e.destroy(!1),
|
|
14
|
-
e.
|
|
14
|
+
e.oe(!0);
|
|
15
15
|
}
|
package/src/Core/enable-sdk.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import r from "../../shared-lib/
|
|
3
|
-
import
|
|
2
|
+
import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
3
|
+
import Q, { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
4
4
|
export function enableSDK() {
|
|
5
|
-
new
|
|
6
|
-
const a =
|
|
7
|
-
new
|
|
8
|
-
r.
|
|
5
|
+
new Q.ee(null, !0).remove(o.se);
|
|
6
|
+
const a = A.Yt.Qt;
|
|
7
|
+
new A(a, r).re(a.ss.ae, a.ie),
|
|
8
|
+
r.info("enableSDK was called"),
|
|
9
9
|
e.destroy(!1),
|
|
10
|
-
e.
|
|
10
|
+
e.oe(!1);
|
|
11
11
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import r from "../../shared-lib/
|
|
2
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
3
3
|
export function getDeviceId(t) {
|
|
4
|
-
if (!e.
|
|
4
|
+
if (!e.X()) return;
|
|
5
5
|
const i = e.te();
|
|
6
6
|
if (!i) return;
|
|
7
|
-
const
|
|
8
|
-
if ("function" != typeof t) return
|
|
9
|
-
r.
|
|
7
|
+
const n = i.ce().id;
|
|
8
|
+
if ("function" != typeof t) return n;
|
|
9
|
+
r.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
|
-
t(
|
|
12
|
+
t(n);
|
|
13
13
|
}
|
package/src/Core/get-user.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import r from "../../shared-lib/
|
|
2
|
-
import { BRAZE_MUST_BE_INITIALIZED_ERROR as
|
|
1
|
+
import { logger as r } from "../../shared-lib/index.js";
|
|
2
|
+
import { BRAZE_MUST_BE_INITIALIZED_ERROR as _ } from "../common/constants.js";
|
|
3
3
|
import e from "../managers/braze-instance.js";
|
|
4
4
|
import {
|
|
5
|
-
BRAZE_ACTIONS as
|
|
6
|
-
getDecodedBrazeAction as
|
|
5
|
+
BRAZE_ACTIONS as V,
|
|
6
|
+
getDecodedBrazeAction as W,
|
|
7
7
|
} from "../util/braze-actions.js";
|
|
8
|
-
import
|
|
9
|
-
import { OperatingSystems as
|
|
8
|
+
import X from "../util/browser-detector.js";
|
|
9
|
+
import { OperatingSystems as Y } from "../util/device-constants.js";
|
|
10
10
|
import {
|
|
11
|
-
BRAZE_ACTION_URI_REGEX as
|
|
12
|
-
isValidBrazeActionJson as
|
|
11
|
+
BRAZE_ACTION_URI_REGEX as Z,
|
|
12
|
+
isValidBrazeActionJson as oo,
|
|
13
13
|
} from "../util/validation-utils.js";
|
|
14
|
-
import { WindowUtils as
|
|
15
|
-
import { getUser as
|
|
14
|
+
import { WindowUtils as eo } from "../util/window-utils.js";
|
|
15
|
+
import { getUser as ro } from "./get-user.js";
|
|
16
16
|
export function _handleBrazeAction(o, s, t) {
|
|
17
|
-
if (e.
|
|
18
|
-
if (
|
|
19
|
-
const s =
|
|
17
|
+
if (e.X())
|
|
18
|
+
if (Z.test(o)) {
|
|
19
|
+
const s = W(o);
|
|
20
20
|
if (!s) return;
|
|
21
21
|
const t = (o) => {
|
|
22
|
-
if (!
|
|
23
|
-
return void r.
|
|
22
|
+
if (!oo(o))
|
|
23
|
+
return void r.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 s =
|
|
31
|
-
i =
|
|
32
|
-
n =
|
|
30
|
+
const s = V.properties.type,
|
|
31
|
+
i = V.properties.oo,
|
|
32
|
+
n = V.properties.eo,
|
|
33
33
|
a = o[s];
|
|
34
|
-
if (a ===
|
|
34
|
+
if (a === V.types.ro) {
|
|
35
35
|
const e = o[i];
|
|
36
36
|
for (const o of e) t(o);
|
|
37
37
|
} else {
|
|
38
38
|
const s = o[n];
|
|
39
39
|
let t, i;
|
|
40
40
|
switch (a) {
|
|
41
|
-
case
|
|
41
|
+
case V.types.logCustomEvent:
|
|
42
42
|
import("./log-custom-event.js").then(
|
|
43
43
|
({ logCustomEvent: logCustomEvent }) => {
|
|
44
|
-
e.
|
|
44
|
+
e.so()
|
|
45
45
|
? ((i = Array.prototype.slice.call(s)),
|
|
46
46
|
logCustomEvent(...i))
|
|
47
|
-
: r.
|
|
47
|
+
: r.error(_);
|
|
48
48
|
},
|
|
49
49
|
);
|
|
50
50
|
break;
|
|
51
|
-
case
|
|
51
|
+
case V.types.requestPushPermission:
|
|
52
52
|
import("../Push/request-push-permission.js").then(
|
|
53
53
|
({ requestPushPermission: requestPushPermission }) => {
|
|
54
|
-
e.
|
|
55
|
-
? "Safari" ===
|
|
54
|
+
e.so()
|
|
55
|
+
? "Safari" === X.browser && X.OS === Y.io
|
|
56
56
|
? window.navigator.standalone && requestPushPermission()
|
|
57
57
|
: requestPushPermission()
|
|
58
|
-
: r.
|
|
58
|
+
: r.error(_);
|
|
59
59
|
},
|
|
60
60
|
);
|
|
61
61
|
break;
|
|
62
|
-
case
|
|
63
|
-
case
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
case
|
|
67
|
-
case
|
|
68
|
-
case
|
|
69
|
-
if (((t =
|
|
62
|
+
case V.types.setEmailNotificationSubscriptionType:
|
|
63
|
+
case V.types.setPushNotificationSubscriptionType:
|
|
64
|
+
case V.types.setCustomUserAttribute:
|
|
65
|
+
case V.types.addToSubscriptionGroup:
|
|
66
|
+
case V.types.removeFromSubscriptionGroup:
|
|
67
|
+
case V.types.addToCustomAttributeArray:
|
|
68
|
+
case V.types.removeFromCustomAttributeArray:
|
|
69
|
+
if (((t = ro()), t)) {
|
|
70
70
|
t[a](...Array.prototype.slice.call(s));
|
|
71
71
|
}
|
|
72
72
|
break;
|
|
73
|
-
case
|
|
74
|
-
case
|
|
75
|
-
(i = Array.prototype.slice.call(s)),
|
|
73
|
+
case V.types.no:
|
|
74
|
+
case V.types.ao:
|
|
75
|
+
(i = Array.prototype.slice.call(s)), eo.openUri(...i);
|
|
76
76
|
break;
|
|
77
77
|
default:
|
|
78
|
-
r.
|
|
78
|
+
r.info(`Ignoring unknown Braze Action: ${a}`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
t(s);
|
|
83
|
-
} else
|
|
83
|
+
} else eo.openUri(o, s, t);
|
|
84
84
|
}
|
|
85
|
-
export function handleBrazeAction(
|
|
86
|
-
_handleBrazeAction(
|
|
85
|
+
export function handleBrazeAction(o, e) {
|
|
86
|
+
_handleBrazeAction(o, e);
|
|
87
87
|
}
|
package/src/Core/is-disabled.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
2
|
import s from "../common/event-logger.js";
|
|
3
|
-
import r from "../../shared-lib/
|
|
3
|
+
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
4
4
|
import tt from "../triggers/models/trigger-events.js";
|
|
5
5
|
import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
|
|
6
6
|
import {
|
|
7
|
-
validateCustomProperties as
|
|
8
|
-
validateCustomString as
|
|
7
|
+
validateCustomProperties as ot,
|
|
8
|
+
validateCustomString as rt,
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
10
|
import { LOG_CUSTOM_EVENT_STRING as nt } from "../common/constants.js";
|
|
11
11
|
export function logCustomEvent(t, o) {
|
|
12
|
-
if (!e.
|
|
12
|
+
if (!e.X()) return !1;
|
|
13
13
|
if (null == t || t.length <= 0)
|
|
14
14
|
return (
|
|
15
|
-
r.
|
|
15
|
+
r.error(
|
|
16
16
|
`logCustomEvent requires a non-empty eventName, got "${t}". Ignoring event.`,
|
|
17
17
|
),
|
|
18
18
|
!1
|
|
19
19
|
);
|
|
20
|
-
if (!
|
|
21
|
-
const [n,
|
|
20
|
+
if (!rt(t, "log custom event", "the event name")) return !1;
|
|
21
|
+
const [n, m] = ot(
|
|
22
22
|
o,
|
|
23
23
|
nt,
|
|
24
24
|
"eventProperties",
|
|
@@ -26,13 +26,13 @@ export function logCustomEvent(t, o) {
|
|
|
26
26
|
"event",
|
|
27
27
|
);
|
|
28
28
|
if (!n) return !1;
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
return r.
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
r.
|
|
35
|
-
for (const e of
|
|
29
|
+
const g = e.ir();
|
|
30
|
+
if (g && g.me(t))
|
|
31
|
+
return r.info(`Custom Event "${t}" is blocklisted, ignoring.`), !1;
|
|
32
|
+
const f = s.q(i.CustomEvent, { n: t, p: m });
|
|
33
|
+
if (f.L) {
|
|
34
|
+
r.info(`Logged custom event "${t}".`);
|
|
35
|
+
for (const e of f.ge) et.rr().fe(tt.ue, [t, o], e);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return f.L;
|
|
38
38
|
}
|
package/src/Core/log-purchase.js
CHANGED
|
@@ -1,46 +1,44 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
2
|
import { MAX_PURCHASE_QUANTITY as rr } from "../common/constants.js";
|
|
3
|
-
import r from "../../shared-lib/
|
|
3
|
+
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
4
4
|
import tt from "../triggers/models/trigger-events.js";
|
|
5
5
|
import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
|
|
6
6
|
import {
|
|
7
|
-
validateCustomProperties as
|
|
8
|
-
validateCustomString as
|
|
7
|
+
validateCustomProperties as ot,
|
|
8
|
+
validateCustomString as rt,
|
|
9
9
|
} from "../util/validation-utils.js";
|
|
10
10
|
import s from "../common/event-logger.js";
|
|
11
|
-
export function logPurchase(o,
|
|
12
|
-
if (!e.
|
|
11
|
+
export function logPurchase(o, n, t, D, u) {
|
|
12
|
+
if (!e.X()) return !1;
|
|
13
13
|
if (
|
|
14
|
-
(null ==
|
|
14
|
+
(null == t && (t = "USD"), null == D && (D = 1), null == o || o.length <= 0)
|
|
15
15
|
)
|
|
16
16
|
return (
|
|
17
|
-
r.
|
|
17
|
+
r.error(
|
|
18
18
|
`logPurchase requires a non-empty productId, got "${o}", ignoring.`,
|
|
19
19
|
),
|
|
20
20
|
!1
|
|
21
21
|
);
|
|
22
|
-
if (!
|
|
23
|
-
if (null ==
|
|
22
|
+
if (!rt(o, "log purchase", "the purchase name")) return !1;
|
|
23
|
+
if (null == n || isNaN(parseFloat(n.toString())))
|
|
24
24
|
return (
|
|
25
|
-
r.
|
|
25
|
+
r.error(`logPurchase requires a numeric price, got ${n}, ignoring.`), !1
|
|
26
26
|
);
|
|
27
|
-
const a = parseFloat(
|
|
28
|
-
if (null ==
|
|
27
|
+
const a = parseFloat(n.toString()).toFixed(2);
|
|
28
|
+
if (null == D || isNaN(parseInt(D.toString())))
|
|
29
29
|
return (
|
|
30
|
-
r.
|
|
31
|
-
`logPurchase requires an integer quantity, got ${t}, ignoring.`,
|
|
32
|
-
),
|
|
30
|
+
r.error(`logPurchase requires an integer quantity, got ${D}, ignoring.`),
|
|
33
31
|
!1
|
|
34
32
|
);
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
33
|
+
const g = parseInt(D.toString());
|
|
34
|
+
if (g < 1 || g > rr)
|
|
37
35
|
return (
|
|
38
|
-
r.
|
|
39
|
-
`logPurchase requires a quantity >1 and <${rr}, got ${
|
|
36
|
+
r.error(
|
|
37
|
+
`logPurchase requires a quantity >1 and <${rr}, got ${g}, ignoring.`,
|
|
40
38
|
),
|
|
41
39
|
!1
|
|
42
40
|
);
|
|
43
|
-
|
|
41
|
+
t = null != t ? t.toUpperCase() : t;
|
|
44
42
|
if (
|
|
45
43
|
-1 ===
|
|
46
44
|
[
|
|
@@ -215,31 +213,27 @@ export function logPurchase(o, i, n, t, D) {
|
|
|
215
213
|
"ZMK",
|
|
216
214
|
"ZMW",
|
|
217
215
|
"ZWL",
|
|
218
|
-
].indexOf(
|
|
216
|
+
].indexOf(t)
|
|
219
217
|
)
|
|
220
218
|
return (
|
|
221
|
-
r.
|
|
222
|
-
`logPurchase requires a valid currencyCode, got ${n}, ignoring.`,
|
|
223
|
-
),
|
|
219
|
+
r.error(`logPurchase requires a valid currencyCode, got ${t}, ignoring.`),
|
|
224
220
|
!1
|
|
225
221
|
);
|
|
226
|
-
const [
|
|
227
|
-
|
|
222
|
+
const [P, R] = ot(
|
|
223
|
+
u,
|
|
228
224
|
"logPurchase",
|
|
229
225
|
"purchaseProperties",
|
|
230
226
|
`log purchase "${o}"`,
|
|
231
227
|
"purchase",
|
|
232
228
|
);
|
|
233
|
-
if (!
|
|
234
|
-
const
|
|
235
|
-
if (
|
|
236
|
-
return r.
|
|
237
|
-
const
|
|
238
|
-
if (
|
|
239
|
-
r.
|
|
240
|
-
|
|
241
|
-
);
|
|
242
|
-
for (const r of c.ve) et.er().be(tt.Rr, [o, D], r);
|
|
229
|
+
if (!P) return !1;
|
|
230
|
+
const c = e.ir();
|
|
231
|
+
if (c && c.Dr(o))
|
|
232
|
+
return r.info(`Purchase "${o}" is blocklisted, ignoring.`), !1;
|
|
233
|
+
const l = s.q(i.Pr, { pid: o, c: t, p: a, q: g, pr: R });
|
|
234
|
+
if (l.L) {
|
|
235
|
+
r.info(`Logged ${g} purchase${g > 1 ? "s" : ""} of "${o}" for ${t} ${a}.`);
|
|
236
|
+
for (const r of l.ge) et.rr().fe(tt.Rr, [o, u], r);
|
|
243
237
|
}
|
|
244
|
-
return
|
|
238
|
+
return l.L;
|
|
245
239
|
}
|
package/src/Core/open-session.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import r from "../../shared-lib/
|
|
2
|
+
import { logger as r, IndexedDBAdapter as A } from "../../shared-lib/index.js";
|
|
3
3
|
import tt from "../triggers/models/trigger-events.js";
|
|
4
4
|
import { TriggersProviderFactory as et } from "../triggers/triggers-provider-factory.js";
|
|
5
5
|
export function openSession() {
|
|
6
|
-
if (!e.
|
|
6
|
+
if (!e.X()) return;
|
|
7
7
|
const i = e.cr();
|
|
8
8
|
if (!i) return;
|
|
9
9
|
i.openSession();
|
|
10
|
-
const t =
|
|
11
|
-
o = new
|
|
12
|
-
o.
|
|
13
|
-
const
|
|
14
|
-
c =
|
|
15
|
-
r.
|
|
16
|
-
const g = i.
|
|
10
|
+
const t = A.Yt.Qt,
|
|
11
|
+
o = new A(t, r);
|
|
12
|
+
o.jr(t.ss.hr, (n, e) => {
|
|
13
|
+
const s = e.lastClick,
|
|
14
|
+
c = e.trackingString;
|
|
15
|
+
r.info(`Firing push click trigger from ${c} push click at ${s}`);
|
|
16
|
+
const g = i.kr(s, c),
|
|
17
17
|
f = function () {
|
|
18
|
-
et.
|
|
18
|
+
et.rr().fe(tt.vr, [c], g);
|
|
19
19
|
};
|
|
20
|
-
i.$r(f, f), o.
|
|
20
|
+
i.$r(f, f), o.re(t.ss.hr, n);
|
|
21
21
|
}),
|
|
22
|
-
o.
|
|
22
|
+
o.Zt(t.ss.wr, function (r) {
|
|
23
23
|
i.yr(r);
|
|
24
24
|
});
|
|
25
25
|
}
|