@braze/web-sdk 5.3.1 → 5.4.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 +20 -4
- package/package.json +1 -1
- package/shared-lib/event-types.js +10 -10
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +9 -8
- package/src/Card/display/card-display.js +59 -58
- package/src/Core/index.js +1 -0
- package/src/Core/is-initialized.js +4 -0
- package/src/InAppMessage/display/html-message-display-utils.js +172 -0
- package/src/InAppMessage/display/html-message-to-html.js +54 -219
- package/src/InAppMessage/display/in-app-message-to-html.js +78 -76
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +56 -56
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +2 -2
- package/src/InAppMessage/models/html-message.js +2 -2
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +26 -26
- package/src/InAppMessage/models/modal-message.js +2 -2
- package/src/InAppMessage/models/slide-up-message.js +4 -4
- 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 +47 -45
- package/src/InAppMessage/utils/in-app-message-utils.js +1 -18
- 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 +2 -1
- package/src/Push/push-manager.js +80 -92
- package/src/Push/utils/push-utils.js +12 -12
- package/src/User/user-manager.js +3 -3
- package/src/User/user.js +19 -19
- package/src/common/event-logger.js +4 -4
- package/src/common/feed-display.js +25 -24
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +15 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +54 -52
- package/src/managers/device-manager.js +19 -19
- package/src/managers/network-manager.js +100 -100
- package/src/managers/server-config-manager.js +7 -7
- package/src/managers/session-manager.js +4 -4
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +18 -18
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +10 -10
- package/src/models/device.js +3 -3
- package/src/models/server-config.js +7 -7
- package/src/request-controller.js +77 -77
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +3 -3
- package/src/triggers/models/filter.js +9 -9
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- 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 +3 -3
- package/src/triggers/models/trigger-condition.js +39 -39
- package/src/triggers/models/trigger.js +12 -12
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +15 -15
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +1 -1
- package/src/ui/js/iam-css.js +1 -1
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +3 -3
- package/src/util/component-utils.js +15 -14
- package/src/util/date-utils.js +2 -2
- package/src/util/dom-utils.js +3 -3
- package/src/util/net.js +2 -2
- package/src/util/request-header-utils.js +8 -8
- package/src/util/user-agent-parser.js +3 -3
- package/src/util/validation-utils.js +17 -17
- 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 v5.
|
|
2
|
+
* Type definitions for @braze/web-sdk v5.4.0
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2024 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
|
@@ -2138,7 +2138,7 @@ export function openSession(): void;
|
|
|
2138
2138
|
* - Create a `service-worker.js` file with the content below and place it in the root directory of your website:
|
|
2139
2139
|
*
|
|
2140
2140
|
* ```
|
|
2141
|
-
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2141
|
+
* self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.4/service-worker.js');
|
|
2142
2142
|
* ```
|
|
2143
2143
|
*
|
|
2144
2144
|
* For more details, see [Our Product Documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration).
|
|
@@ -2408,7 +2408,7 @@ export function subscribeToFeatureFlagsUpdates(
|
|
|
2408
2408
|
export function getAllFeatureFlags(): FeatureFlag[];
|
|
2409
2409
|
|
|
2410
2410
|
/**
|
|
2411
|
-
* Logs impression for a given feature flag.
|
|
2411
|
+
* Logs impression for a given feature flag. This is limited to one impression per session per feature flag ID.
|
|
2412
2412
|
*
|
|
2413
2413
|
* @param featureFlagId - ID of the feature flag that has received the impression.
|
|
2414
2414
|
*
|
|
@@ -2418,6 +2418,11 @@ export function logFeatureFlagImpression(
|
|
|
2418
2418
|
featureFlagId: string,
|
|
2419
2419
|
): boolean | undefined;
|
|
2420
2420
|
|
|
2421
|
+
/**
|
|
2422
|
+
* Getter method to determine if the Braze SDK has been initialized.
|
|
2423
|
+
*/
|
|
2424
|
+
export function isInitialized(): boolean;
|
|
2425
|
+
|
|
2421
2426
|
/**
|
|
2422
2427
|
* Supported initialization options
|
|
2423
2428
|
*
|
|
@@ -2513,7 +2518,7 @@ export type InitializationOptions = {
|
|
|
2513
2518
|
* lifecycle of, set this option to true and the Braze SDK will not register or unregister a service worker. If you set this
|
|
2514
2519
|
* option to true, in order for push to function correctly you must register the service worker yourself BEFORE calling
|
|
2515
2520
|
* `requestPushPermission`, and ensure that it contains Braze's service worker code, either with
|
|
2516
|
-
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.
|
|
2521
|
+
* `self.importScripts('https://js.appboycdn.com/web-sdk-develop/5.4/service-worker.js');` or by including the content
|
|
2517
2522
|
* of that file directly. When this option is true, the `serviceWorkerLocation` option is irrelevant and is ignored.
|
|
2518
2523
|
*/
|
|
2519
2524
|
manageServiceWorkerExternally?: boolean;
|
|
@@ -2570,6 +2575,17 @@ export type InitializationOptions = {
|
|
|
2570
2575
|
* default with a value of your own.
|
|
2571
2576
|
*/
|
|
2572
2577
|
deviceId?: string;
|
|
2578
|
+
/**
|
|
2579
|
+
* By default, Braze will register service worker with scope as the directory where the service worker script is located.
|
|
2580
|
+
*
|
|
2581
|
+
* Provide a value for this option to override that with a different scope. If you are using Service-Worker-Allowed header to specify scope,
|
|
2582
|
+
* ensure that the value provided here either matches the value returned by the header or is a subdirectory of it.
|
|
2583
|
+
*
|
|
2584
|
+
* For example, if the scope is '/path/to/subdirectory/' and the header is set to '/', the registration will succeed. However, if the scope is '/' and the
|
|
2585
|
+
* header is set to '/path/to/subdirectory/', the registration will fail because the provided scope ('/') is not under the maximum scope allowed
|
|
2586
|
+
* by Service-Worker-Allowed: '/path/to/subdirectory/'.
|
|
2587
|
+
*/
|
|
2588
|
+
serviceWorkerScope?: string;
|
|
2573
2589
|
};
|
|
2574
2590
|
|
|
2575
2591
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const i = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
4
|
+
Eu: "pc",
|
|
5
5
|
vc: "ca",
|
|
6
|
-
|
|
6
|
+
Ka: "i",
|
|
7
7
|
qs: "ie",
|
|
8
8
|
M: "cci",
|
|
9
9
|
R: "ccic",
|
|
@@ -11,23 +11,23 @@ const i = {
|
|
|
11
11
|
F: "ccd",
|
|
12
12
|
ql: "ss",
|
|
13
13
|
xl: "se",
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Gi: "si",
|
|
15
|
+
$i: "sc",
|
|
16
|
+
Ei: "sbc",
|
|
17
17
|
Cc: "sfe",
|
|
18
18
|
mo: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Bu: "lr",
|
|
20
|
+
_u: "uae",
|
|
21
21
|
O: "ci",
|
|
22
22
|
$: "cc",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Wu: "lcaa",
|
|
24
|
+
Ku: "lcar",
|
|
25
25
|
On: "inc",
|
|
26
26
|
Ln: "add",
|
|
27
27
|
Rn: "rem",
|
|
28
28
|
$n: "set",
|
|
29
29
|
Bn: "ncam",
|
|
30
|
-
|
|
30
|
+
Gu: "sgu",
|
|
31
31
|
Fr: "ffi",
|
|
32
32
|
},
|
|
33
33
|
or = { Ar: "feed_displayed", Ec: "content_cards_displayed" };
|
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const r = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
26
|
if (r.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v5.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v5.4.0)";
|
|
28
28
|
null != r.vd ? r.vd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
32
|
if (r.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v5.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v5.4.0)";
|
|
34
34
|
null != r.vd ? r.vd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -2,17 +2,17 @@ export default {
|
|
|
2
2
|
Eo: "allowCrawlerActivity",
|
|
3
3
|
_o: "baseUrl",
|
|
4
4
|
Io: "noCookies",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
So: "devicePropertyAllowlist",
|
|
6
|
+
ka: "disablePushTokenMaintenance",
|
|
7
|
+
Ao: "enableLogging",
|
|
8
8
|
No: "enableSdkAuthentication",
|
|
9
|
-
|
|
9
|
+
_a: "manageServiceWorkerExternally",
|
|
10
10
|
Oo: "minimumIntervalBetweenTriggerActionsInSeconds",
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Ro: "sessionTimeoutInSeconds",
|
|
12
|
+
Po: "appVersion",
|
|
13
13
|
Lo: "appVersionNumber",
|
|
14
14
|
wa: "serviceWorkerLocation",
|
|
15
|
-
|
|
15
|
+
Ma: "safariWebsitePushId",
|
|
16
16
|
zn: "localization",
|
|
17
17
|
bo: "contentSecurityNonce",
|
|
18
18
|
Do: "allowUserSuppliedJavascript",
|
|
@@ -22,6 +22,7 @@ export default {
|
|
|
22
22
|
Lh: "requireExplicitInAppMessageDismissal",
|
|
23
23
|
Mo: "doNotLoadFontAwesome",
|
|
24
24
|
Uo: "deviceId",
|
|
25
|
-
|
|
25
|
+
ya: "serviceWorkerScope",
|
|
26
|
+
Wo: "sdkFlavor",
|
|
26
27
|
tn: "openCardsInNewTab",
|
|
27
28
|
};
|
|
@@ -41,98 +41,99 @@ export function setCardHeight(t, o) {
|
|
|
41
41
|
t && (a.style.height = `${t}px`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
export function cardToHtml(t, logCardClick, o) {
|
|
45
|
-
const
|
|
46
|
-
(
|
|
44
|
+
export function cardToHtml(t, logCardClick, o, e = "ltr") {
|
|
45
|
+
const a = document.createElement("div");
|
|
46
|
+
(a.dir = e),
|
|
47
|
+
(a.className = "ab-card ab-effect-card " + t._),
|
|
47
48
|
t.id &&
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
t.url && "" !== t.url && ((
|
|
54
|
-
const
|
|
49
|
+
(a.setAttribute("data-ab-card-id", t.id), a.setAttribute("id", t.id)),
|
|
50
|
+
a.setAttribute("role", "article"),
|
|
51
|
+
a.setAttribute("tabindex", "0");
|
|
52
|
+
let n = "",
|
|
53
|
+
i = !1;
|
|
54
|
+
t.url && "" !== t.url && ((n = t.url), (i = !0));
|
|
55
|
+
const r = (e) => (markCardAsRead(a), i && (logCardClick(t), u(n, o, e)), !1);
|
|
55
56
|
if (t.pinned) {
|
|
56
57
|
const t = document.createElement("div");
|
|
57
58
|
t.className = "ab-pinned-indicator";
|
|
58
59
|
const o = document.createElement("i");
|
|
59
|
-
(o.className = "fa fa-star"), t.appendChild(o),
|
|
60
|
+
(o.className = "fa fa-star"), t.appendChild(o), a.appendChild(t);
|
|
60
61
|
}
|
|
61
62
|
if (t.imageUrl && "" !== t.imageUrl) {
|
|
62
63
|
const o = document.createElement("div");
|
|
63
|
-
o.className = "ab-image-area";
|
|
64
|
-
const
|
|
64
|
+
(o.dir = e), (o.className = "ab-image-area");
|
|
65
|
+
const d = document.createElement("img");
|
|
65
66
|
if (
|
|
66
|
-
(
|
|
67
|
-
(
|
|
68
|
-
|
|
67
|
+
(d.setAttribute("src", t.imageUrl),
|
|
68
|
+
(d.onload = () => {
|
|
69
|
+
a.style.height = "auto";
|
|
69
70
|
}),
|
|
70
|
-
_setImageAltText(t,
|
|
71
|
-
o.appendChild(
|
|
72
|
-
(
|
|
73
|
-
|
|
71
|
+
_setImageAltText(t, d),
|
|
72
|
+
o.appendChild(d),
|
|
73
|
+
(a.className += " with-image"),
|
|
74
|
+
i && !t.S)
|
|
74
75
|
) {
|
|
75
76
|
const t = document.createElement("a");
|
|
76
|
-
t.setAttribute("href",
|
|
77
|
-
(t.onclick =
|
|
77
|
+
t.setAttribute("href", n),
|
|
78
|
+
(t.onclick = r),
|
|
78
79
|
t.appendChild(o),
|
|
79
|
-
|
|
80
|
-
} else
|
|
80
|
+
a.appendChild(t);
|
|
81
|
+
} else a.appendChild(o);
|
|
81
82
|
}
|
|
82
|
-
const
|
|
83
|
-
if (((
|
|
83
|
+
const s = document.createElement("div");
|
|
84
|
+
if (((s.className = "ab-card-body"), (s.dir = e), t.dismissible)) {
|
|
84
85
|
t.logCardDismissal = () => logCardDismissal(t);
|
|
85
|
-
const o = d("Dismiss Card", void 0, t.dismissCard.bind(t));
|
|
86
|
-
|
|
87
|
-
c(
|
|
88
|
-
(
|
|
86
|
+
const o = d("Dismiss Card", void 0, t.dismissCard.bind(t), e);
|
|
87
|
+
a.appendChild(o),
|
|
88
|
+
c(s, m.U, (t) => {
|
|
89
|
+
(a.className += " ab-swiped-left"), o.onclick(t);
|
|
89
90
|
}),
|
|
90
|
-
c(
|
|
91
|
-
(
|
|
91
|
+
c(s, m.V, (t) => {
|
|
92
|
+
(a.className += " ab-swiped-right"), o.onclick(t);
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
if ((t.title && "" !== t.title && ((
|
|
95
|
+
let l = "",
|
|
96
|
+
b = !1;
|
|
97
|
+
if ((t.title && "" !== t.title && ((l = t.title), (b = !0)), b)) {
|
|
97
98
|
const t = document.createElement("h1");
|
|
98
99
|
if (
|
|
99
100
|
((t.className = "ab-title"),
|
|
100
101
|
(t.id = p.W()),
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
a.setAttribute("aria-labelledby", t.id),
|
|
103
|
+
i)
|
|
103
104
|
) {
|
|
104
105
|
const o = document.createElement("a");
|
|
105
|
-
o.setAttribute("href",
|
|
106
|
-
(o.onclick =
|
|
107
|
-
o.appendChild(document.createTextNode(
|
|
106
|
+
o.setAttribute("href", n),
|
|
107
|
+
(o.onclick = r),
|
|
108
|
+
o.appendChild(document.createTextNode(l)),
|
|
108
109
|
t.appendChild(o);
|
|
109
|
-
} else t.appendChild(document.createTextNode(
|
|
110
|
-
|
|
110
|
+
} else t.appendChild(document.createTextNode(l));
|
|
111
|
+
s.appendChild(t);
|
|
111
112
|
}
|
|
112
|
-
const
|
|
113
|
+
const f = document.createElement("div");
|
|
113
114
|
if (
|
|
114
|
-
((
|
|
115
|
-
(
|
|
116
|
-
|
|
117
|
-
t.description &&
|
|
118
|
-
|
|
115
|
+
((f.className = b ? "ab-description" : "ab-description ab-no-title"),
|
|
116
|
+
(f.id = p.W()),
|
|
117
|
+
a.setAttribute("aria-describedby", f.id),
|
|
118
|
+
t.description && f.appendChild(document.createTextNode(t.description)),
|
|
119
|
+
i)
|
|
119
120
|
) {
|
|
120
121
|
const o = document.createElement("div");
|
|
121
122
|
o.className = "ab-url-area";
|
|
122
123
|
const e = document.createElement("a");
|
|
123
|
-
e.setAttribute("href",
|
|
124
|
+
e.setAttribute("href", n),
|
|
124
125
|
t.linkText && e.appendChild(document.createTextNode(t.linkText)),
|
|
125
|
-
(e.onclick =
|
|
126
|
+
(e.onclick = r),
|
|
126
127
|
o.appendChild(e),
|
|
127
|
-
|
|
128
|
+
f.appendChild(o);
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
-
const
|
|
130
|
+
s.appendChild(f), a.appendChild(s);
|
|
131
|
+
const x = document.createElement("div");
|
|
131
132
|
return (
|
|
132
|
-
(
|
|
133
|
-
t.viewed && (
|
|
134
|
-
|
|
135
|
-
(t.T =
|
|
136
|
-
|
|
133
|
+
(x.className = "ab-unread-indicator"),
|
|
134
|
+
t.viewed && (x.className += " read"),
|
|
135
|
+
a.appendChild(x),
|
|
136
|
+
(t.T = a),
|
|
137
|
+
a
|
|
137
138
|
);
|
|
138
139
|
}
|
package/src/Core/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { getDeviceId } from "./get-device-id.js";
|
|
|
9
9
|
export { getUser } from "./get-user.js";
|
|
10
10
|
export { initialize } from "./initialize.js";
|
|
11
11
|
export { isDisabled } from "./is-disabled.js";
|
|
12
|
+
export { isInitialized } from "./is-initialized.js";
|
|
12
13
|
export { logCustomEvent } from "./log-custom-event.js";
|
|
13
14
|
export { logPurchase } from "./log-purchase.js";
|
|
14
15
|
export { openSession } from "./open-session.js";
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { getUser as ro } from "../../Core/get-user.js";
|
|
2
|
+
import { keys as to } from "../../util/code-utils.js";
|
|
3
|
+
import { parseQueryStringKeyValues as ut } from "../../util/url-utils.js";
|
|
4
|
+
import { WindowUtils as eo } from "../../util/window-utils.js";
|
|
5
|
+
import { logInAppMessageHtmlClick } from "../log-in-app-message-html-click.js";
|
|
6
|
+
import InAppMessage from "../models/in-app-message.js";
|
|
7
|
+
import e from "../../managers/braze-instance.js";
|
|
8
|
+
import { logger as r } from "../../../shared-lib/index.js";
|
|
9
|
+
import { BRAZE_MUST_BE_INITIALIZED_ERROR as _ } from "../../common/constants.js";
|
|
10
|
+
export const buildHtmlClickHandler = (t, r, e, o) => {
|
|
11
|
+
const s = e.getAttribute("href"),
|
|
12
|
+
n = e.onclick;
|
|
13
|
+
return (i) => {
|
|
14
|
+
if (null != n && "function" == typeof n && !1 === n.bind(e)(i)) return;
|
|
15
|
+
let u = ut(s).abButtonId;
|
|
16
|
+
if (
|
|
17
|
+
((null != u && "" !== u) || (u = e.getAttribute("id") || void 0),
|
|
18
|
+
null != s && "" !== s && 0 !== s.indexOf("#"))
|
|
19
|
+
) {
|
|
20
|
+
const n =
|
|
21
|
+
"blank" ===
|
|
22
|
+
(e.getAttribute("target") || "").toLowerCase().replace("_", ""),
|
|
23
|
+
c = o || t.openTarget === InAppMessage.OpenTarget.BLANK || n,
|
|
24
|
+
a = () => {
|
|
25
|
+
logInAppMessageHtmlClick(t, u, s), eo.openUri(s, c, i);
|
|
26
|
+
};
|
|
27
|
+
c ? a() : t.Cr(r, a);
|
|
28
|
+
} else logInAppMessageHtmlClick(t, u, s || void 0);
|
|
29
|
+
return i.stopPropagation(), !1;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export const applyNonceToDynamicallyCreatedTags = (t, r, e) => {
|
|
33
|
+
const o = `([\\w]+)\\s*=\\s*document.createElement\\(['"]${e}['"]\\)`,
|
|
34
|
+
s = t.match(new RegExp(o));
|
|
35
|
+
if (s) {
|
|
36
|
+
const e = `${s[1]}.setAttribute("nonce", "${r}")`;
|
|
37
|
+
return `${t.slice(0, s.index + s[0].length)};${e};${t.slice(
|
|
38
|
+
s.index + s[0].length,
|
|
39
|
+
)}`;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
export const buildBrazeBridge = (t, o, s) => {
|
|
44
|
+
const n = {
|
|
45
|
+
closeMessage: function () {
|
|
46
|
+
t.Cr(o);
|
|
47
|
+
},
|
|
48
|
+
logClick: function () {
|
|
49
|
+
logInAppMessageHtmlClick(t, ...arguments);
|
|
50
|
+
},
|
|
51
|
+
display: {},
|
|
52
|
+
web: {},
|
|
53
|
+
},
|
|
54
|
+
requestPushPermission = function () {
|
|
55
|
+
return function () {
|
|
56
|
+
const t = arguments;
|
|
57
|
+
import("../../Push/request-push-permission.js").then((o) => {
|
|
58
|
+
e.so()
|
|
59
|
+
? o.requestPushPermission(...Array.prototype.slice.call(t))
|
|
60
|
+
: r.error(_);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
i = {
|
|
65
|
+
requestImmediateDataFlush: function () {
|
|
66
|
+
const t = arguments;
|
|
67
|
+
import("../../Core/request-immediate-data-flush.js").then(
|
|
68
|
+
({ requestImmediateDataFlush: requestImmediateDataFlush }) => {
|
|
69
|
+
e.so()
|
|
70
|
+
? requestImmediateDataFlush(...Array.prototype.slice.call(t))
|
|
71
|
+
: r.error(_);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
logCustomEvent: function () {
|
|
76
|
+
const t = arguments;
|
|
77
|
+
import("../../Core/log-custom-event.js").then(
|
|
78
|
+
({ logCustomEvent: logCustomEvent }) => {
|
|
79
|
+
if (!e.so()) return void r.error(_);
|
|
80
|
+
logCustomEvent(...Array.prototype.slice.call(t));
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
logPurchase: function () {
|
|
85
|
+
const t = arguments;
|
|
86
|
+
import("../../Core/log-purchase.js").then(
|
|
87
|
+
({ logPurchase: logPurchase }) => {
|
|
88
|
+
if (!e.so()) return void r.error(_);
|
|
89
|
+
logPurchase(...Array.prototype.slice.call(t));
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
unregisterPush: function () {
|
|
94
|
+
const t = arguments;
|
|
95
|
+
import("../../Push/unregister-push.js").then(
|
|
96
|
+
({ unregisterPush: unregisterPush }) => {
|
|
97
|
+
e.so()
|
|
98
|
+
? unregisterPush(...Array.prototype.slice.call(t))
|
|
99
|
+
: r.error(_);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
requestPushPermission: requestPushPermission(),
|
|
104
|
+
changeUser: function () {
|
|
105
|
+
const t = arguments;
|
|
106
|
+
import("../../Core/change-user.js").then(
|
|
107
|
+
({ changeUser: changeUser }) => {
|
|
108
|
+
if (!e.so()) return void r.error(_);
|
|
109
|
+
changeUser(...Array.prototype.slice.call(t));
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
u = function (t) {
|
|
115
|
+
return function () {
|
|
116
|
+
i[t](...Array.prototype.slice.call(arguments));
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
for (const t of to(i)) n[t] = u(t);
|
|
120
|
+
const c = [
|
|
121
|
+
"setFirstName",
|
|
122
|
+
"setLastName",
|
|
123
|
+
"setEmail",
|
|
124
|
+
"setGender",
|
|
125
|
+
"setDateOfBirth",
|
|
126
|
+
"setCountry",
|
|
127
|
+
"setHomeCity",
|
|
128
|
+
"setEmailNotificationSubscriptionType",
|
|
129
|
+
"setLanguage",
|
|
130
|
+
"addAlias",
|
|
131
|
+
"setPushNotificationSubscriptionType",
|
|
132
|
+
"setPhoneNumber",
|
|
133
|
+
"setCustomUserAttribute",
|
|
134
|
+
"addToCustomAttributeArray",
|
|
135
|
+
"removeFromCustomAttributeArray",
|
|
136
|
+
"incrementCustomUserAttribute",
|
|
137
|
+
"setCustomLocationAttribute",
|
|
138
|
+
"addToSubscriptionGroup",
|
|
139
|
+
"removeFromSubscriptionGroup",
|
|
140
|
+
],
|
|
141
|
+
a = function (t) {
|
|
142
|
+
return function () {
|
|
143
|
+
const r = ro();
|
|
144
|
+
r && r[t](...Array.prototype.slice.call(arguments));
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
m = {};
|
|
148
|
+
for (let t = 0; t < c.length; t++) m[c[t]] = a(c[t]);
|
|
149
|
+
n.getUser = function () {
|
|
150
|
+
return m;
|
|
151
|
+
};
|
|
152
|
+
const l = { showFeed: s },
|
|
153
|
+
f = function (r) {
|
|
154
|
+
return function () {
|
|
155
|
+
const e = arguments;
|
|
156
|
+
t.Cr(o, function () {
|
|
157
|
+
l[r](...Array.prototype.slice.call(e));
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
p = n.display;
|
|
162
|
+
for (const t of to(l)) p[t] = f(t);
|
|
163
|
+
const d = { registerAppboyPushMessages: requestPushPermission() },
|
|
164
|
+
g = function (t) {
|
|
165
|
+
return function () {
|
|
166
|
+
d[t](...Array.prototype.slice.call(arguments));
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
h = n.web;
|
|
170
|
+
for (const t of to(d)) h[t] = g(t);
|
|
171
|
+
return n;
|
|
172
|
+
};
|