@braze/web-sdk 5.1.1 → 5.3.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 +65 -10
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +20 -20
- package/shared-lib/indexed-db-adapter.js +52 -52
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +22 -21
- package/src/ContentCards/content-cards-provider.js +107 -135
- 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 +2 -2
- package/src/ContentCards/ui/show-content-cards.js +1 -1
- package/src/FeatureFlags/feature-flag.js +41 -30
- package/src/FeatureFlags/feature-flags-provider.js +88 -84
- package/src/FeatureFlags/get-all-feature-flags.js +2 -2
- package/src/FeatureFlags/get-feature-flag.js +2 -2
- package/src/FeatureFlags/log-feature-flag-impression.js +3 -3
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +24 -24
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.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 +1 -1
- package/src/InAppMessage/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +45 -42
- package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
- 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 +23 -21
- package/src/InAppMessage/in-app-message-manager.js +95 -112
- 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 +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/control-message.js +4 -2
- package/src/InAppMessage/models/full-screen-message.js +14 -11
- package/src/InAppMessage/models/html-message.js +11 -9
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +127 -120
- package/src/InAppMessage/models/modal-message.js +14 -11
- package/src/InAppMessage/models/slide-up-message.js +46 -21
- 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 +37 -43
- package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
- package/src/Push/push-manager-factory.js +4 -4
- package/src/Push/push-manager.js +118 -110
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +19 -19
- package/src/common/base-feed.js +1 -1
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +0 -2
- package/src/common/event-logger.js +2 -2
- package/src/common/feed-display.js +12 -12
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +119 -112
- package/src/managers/device-manager.js +19 -19
- package/src/managers/network-manager.js +215 -165
- package/src/managers/server-config-manager.js +46 -50
- package/src/managers/session-manager.js +21 -21
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +128 -125
- package/src/managers/utils.js +6 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +19 -11
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +34 -20
- package/src/models/push-token.js +4 -4
- package/src/models/server-config.js +24 -24
- package/src/request-controller.js +134 -124
- package/src/triggers/models/filter-set.js +2 -2
- package/src/triggers/models/filter.js +56 -56
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +30 -30
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +2 -2
- package/src/triggers/triggers-provider.js +84 -95
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/load-font-awesome.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 +25 -24
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +2 -2
- package/src/util/dom-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -37
- package/src/util/user-agent-parser.js +8 -8
- package/src/util/validation-utils.js +2 -0
- package/src/util/window-utils.js +3 -3
|
@@ -13,21 +13,21 @@ import ModalMessage from "../models/modal-message.js";
|
|
|
13
13
|
import SlideUpMessage from "../models/slide-up-message.js";
|
|
14
14
|
import { logInAppMessageClick } from "../log-in-app-message-click.js";
|
|
15
15
|
import { _handleBrazeAction as u } from "../../Core/handle-braze-action.js";
|
|
16
|
-
import
|
|
16
|
+
import at from "./html-message-to-html.js";
|
|
17
17
|
import le from "./modal-utils.js";
|
|
18
18
|
import { logger as r, Guid as p } from "../../../shared-lib/index.js";
|
|
19
19
|
export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
20
|
-
if (((e.
|
|
21
|
-
return
|
|
20
|
+
if (((e.ke = document.activeElement), e instanceof HtmlMessage))
|
|
21
|
+
return at(e, o, a, n, s, i);
|
|
22
22
|
const b = (function (e, o, a, t, n, s, i = document.body) {
|
|
23
23
|
let m = null;
|
|
24
24
|
const l = document.createElement("div");
|
|
25
25
|
(l.className = "ab-in-app-message ab-start-hidden ab-background"),
|
|
26
26
|
s && (l.style.zIndex = (s + 1).toString()),
|
|
27
|
-
e.
|
|
27
|
+
e.ze() &&
|
|
28
28
|
((l.className += " ab-modal-interactions"),
|
|
29
29
|
l.setAttribute("tabindex", "-1")),
|
|
30
|
-
e.
|
|
30
|
+
e.Ce() ||
|
|
31
31
|
((l.style.color = ie(e.textColor)),
|
|
32
32
|
(l.style.backgroundColor = ie(e.backgroundColor)),
|
|
33
33
|
ne(e.backgroundColor) && (l.className += " ab-no-shadow"));
|
|
@@ -37,7 +37,7 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
37
37
|
document.querySelectorAll(".ab-iam-img-loading").length > 0
|
|
38
38
|
? t(
|
|
39
39
|
`Cannot show in-app message ${e.message} because another message is being shown.`,
|
|
40
|
-
InAppMessage.
|
|
40
|
+
InAppMessage.Be.Le,
|
|
41
41
|
)
|
|
42
42
|
: a(l));
|
|
43
43
|
},
|
|
@@ -63,7 +63,7 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
63
63
|
(e.clickAction !== InAppMessage.ClickAction.NONE &&
|
|
64
64
|
(l.className += " ab-clickable"),
|
|
65
65
|
(l.onclick = (a) => (
|
|
66
|
-
e.
|
|
66
|
+
e.Ae(l, () => {
|
|
67
67
|
logInAppMessageClick(e),
|
|
68
68
|
e.clickAction === InAppMessage.ClickAction.URI
|
|
69
69
|
? u(
|
|
@@ -78,15 +78,15 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
78
78
|
)));
|
|
79
79
|
const g = d(
|
|
80
80
|
"Close Message",
|
|
81
|
-
e.
|
|
81
|
+
e.Ce() ? void 0 : ie(e.closeButtonColor),
|
|
82
82
|
() => {
|
|
83
|
-
e.
|
|
83
|
+
e.Ae(l);
|
|
84
84
|
},
|
|
85
85
|
);
|
|
86
86
|
l.appendChild(g), s && (g.style.zIndex = (s + 2).toString());
|
|
87
87
|
const f = document.createElement("div");
|
|
88
88
|
f.className = "ab-message-text";
|
|
89
|
-
const h = (e.messageAlignment || e
|
|
89
|
+
const h = (e.messageAlignment || e.De).toLowerCase();
|
|
90
90
|
f.className += " " + h + "-aligned";
|
|
91
91
|
let j = !1;
|
|
92
92
|
const w = document.createElement("div");
|
|
@@ -97,13 +97,13 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
97
97
|
(o.style.backgroundImage = "url(" + e.imageUrl + ")"),
|
|
98
98
|
o.setAttribute("role", "img"),
|
|
99
99
|
o.setAttribute("aria-label", "Modal Image"),
|
|
100
|
-
e.
|
|
100
|
+
e.Ge(o),
|
|
101
101
|
w.appendChild(o);
|
|
102
102
|
} else {
|
|
103
103
|
const o = document.createElement("img");
|
|
104
104
|
if (
|
|
105
105
|
(o.setAttribute("src", e.imageUrl),
|
|
106
|
-
e.
|
|
106
|
+
e.Ge(o),
|
|
107
107
|
0 === document.querySelectorAll(".ab-iam-img-loading").length)
|
|
108
108
|
) {
|
|
109
109
|
j = !0;
|
|
@@ -126,7 +126,7 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
126
126
|
w.className += " ab-icon-area";
|
|
127
127
|
const o = document.createElement("span");
|
|
128
128
|
(o.className = "ab-icon"),
|
|
129
|
-
e.
|
|
129
|
+
e.Ce() ||
|
|
130
130
|
((o.style.backgroundColor = ie(e.iconBackgroundColor)),
|
|
131
131
|
(o.style.color = ie(e.iconColor)));
|
|
132
132
|
const a = document.createElement("i");
|
|
@@ -140,23 +140,23 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
140
140
|
}
|
|
141
141
|
if ((oe(f, "touchstart"), e.header && e.header.length > 0)) {
|
|
142
142
|
const o = document.createElement("h1");
|
|
143
|
-
(o.className = "ab-message-header"), (e.
|
|
143
|
+
(o.className = "ab-message-header"), (e.He = p.W()), (o.id = e.He);
|
|
144
144
|
const a = (
|
|
145
145
|
e.headerAlignment || InAppMessage.TextAlignment.CENTER
|
|
146
146
|
).toLowerCase();
|
|
147
147
|
(o.className += " " + a + "-aligned"),
|
|
148
|
-
e.
|
|
148
|
+
e.Ce() || (o.style.color = ie(e.headerTextColor)),
|
|
149
149
|
o.appendChild(document.createTextNode(e.header)),
|
|
150
150
|
f.appendChild(o);
|
|
151
151
|
}
|
|
152
|
-
return f.appendChild(e.
|
|
152
|
+
return f.appendChild(e.Je()), l.appendChild(f), j || c(), (e.Me = l), l;
|
|
153
153
|
})(e, o, a, t, n, s, l);
|
|
154
154
|
if (e instanceof FullScreenMessage || e instanceof ModalMessage) {
|
|
155
155
|
const a = e instanceof FullScreenMessage ? "ab-fullscreen" : "ab-modal";
|
|
156
156
|
(b.className += ` ${a} ab-centered`),
|
|
157
|
-
le.
|
|
158
|
-
le.
|
|
159
|
-
le.
|
|
157
|
+
le.Ke(e, o, b, n),
|
|
158
|
+
le.Oe(b),
|
|
159
|
+
le.Qe(e.He, b);
|
|
160
160
|
} else if (e instanceof SlideUpMessage) {
|
|
161
161
|
b.className += " ab-slideup";
|
|
162
162
|
const o = b.getElementsByClassName("ab-close-button")[0];
|
|
@@ -164,7 +164,7 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
164
164
|
const a = ae(
|
|
165
165
|
"0 0 11.38 19.44",
|
|
166
166
|
"M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",
|
|
167
|
-
e.
|
|
167
|
+
e.Ce() ? void 0 : ie(e.closeButtonColor),
|
|
168
168
|
);
|
|
169
169
|
a.setAttribute("class", "ab-chevron"), o.appendChild(a);
|
|
170
170
|
}
|
|
@@ -178,8 +178,8 @@ export default function ce(e, o, a, t, n, s, i, l = document.body) {
|
|
|
178
178
|
null != o && null != o.onclick && o.onclick(e);
|
|
179
179
|
}),
|
|
180
180
|
e.slideFrom === InAppMessage.SlideFrom.TOP
|
|
181
|
-
? ((a = m.
|
|
182
|
-
: ((a = m.
|
|
181
|
+
? ((a = m.Re), (t = " ab-swiped-up"))
|
|
182
|
+
: ((a = m.Se), (t = " ab-swiped-down")),
|
|
183
183
|
c(b, a, (e) => {
|
|
184
184
|
(b.className += t), null != o && null != o.onclick && o.onclick(e);
|
|
185
185
|
});
|
|
@@ -3,9 +3,9 @@ import { _handleBrazeAction as u } from "../../Core/handle-braze-action.js";
|
|
|
3
3
|
import { logInAppMessageButtonClick } from "../log-in-app-message-button-click.js";
|
|
4
4
|
import { toRgba as ie } from "../../util/color-utils.js";
|
|
5
5
|
import { addPassiveEventListener as oe } from "../../util/dom-utils.js";
|
|
6
|
-
import { KeyCodes as
|
|
6
|
+
import { KeyCodes as lt } from "../../util/key-codes.js";
|
|
7
7
|
const le = {
|
|
8
|
-
|
|
8
|
+
Oe: (t) => {
|
|
9
9
|
const o = t.querySelectorAll(
|
|
10
10
|
".ab-close-button, .ab-message-text, .ab-message-button",
|
|
11
11
|
);
|
|
@@ -16,7 +16,7 @@ const le = {
|
|
|
16
16
|
s = o[o.length - 1];
|
|
17
17
|
t.addEventListener("keydown", (o) => {
|
|
18
18
|
const a = document.activeElement;
|
|
19
|
-
o.keyCode ===
|
|
19
|
+
o.keyCode === lt.lo &&
|
|
20
20
|
(o.shiftKey || (a !== s && a !== t)
|
|
21
21
|
? !o.shiftKey ||
|
|
22
22
|
(a !== e && a !== t) ||
|
|
@@ -25,20 +25,20 @@ const le = {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
Qe: (t, o) => {
|
|
29
29
|
o.setAttribute("role", "dialog"),
|
|
30
30
|
o.setAttribute("aria-modal", "true"),
|
|
31
31
|
o.setAttribute("aria-label", "Modal Message"),
|
|
32
32
|
t && o.setAttribute("aria-labelledby", t);
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
Ke: (t, o, e, s) => {
|
|
35
35
|
if (t.buttons && t.buttons.length > 0) {
|
|
36
36
|
const a = document.createElement("div");
|
|
37
37
|
(a.className = "ab-message-buttons"), e.appendChild(a);
|
|
38
38
|
const l = e.getElementsByClassName("ab-message-text")[0];
|
|
39
39
|
null != l && (l.className += " ab-with-buttons");
|
|
40
40
|
const n = (a) => (l) => (
|
|
41
|
-
t.
|
|
41
|
+
t.Ae(e, () => {
|
|
42
42
|
logInAppMessageButtonClick(a, t),
|
|
43
43
|
a.clickAction === InAppMessage.ClickAction.URI
|
|
44
44
|
? u(
|
|
@@ -60,7 +60,7 @@ const le = {
|
|
|
60
60
|
let l = e.text;
|
|
61
61
|
"" === e.text && (l = " "),
|
|
62
62
|
s.appendChild(document.createTextNode(l)),
|
|
63
|
-
t.
|
|
63
|
+
t.Ce() ||
|
|
64
64
|
((s.style.backgroundColor = ie(e.backgroundColor)),
|
|
65
65
|
(s.style.color = ie(e.textColor)),
|
|
66
66
|
(s.style.borderColor = ie(e.borderColor))),
|
|
@@ -13,8 +13,8 @@ export function newInAppMessageFromJson(e) {
|
|
|
13
13
|
null != o && (o = o.toUpperCase());
|
|
14
14
|
const s = e.message,
|
|
15
15
|
n = e.text_align_message,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
t = e.slide_from,
|
|
17
|
+
m = e.extras,
|
|
18
18
|
l = e.trigger_id,
|
|
19
19
|
i = e.click_action,
|
|
20
20
|
f = e.uri,
|
|
@@ -41,18 +41,17 @@ export function newInAppMessageFromJson(e) {
|
|
|
41
41
|
z = e.orientation,
|
|
42
42
|
J = e.animate_in,
|
|
43
43
|
S = e.animate_out;
|
|
44
|
-
let q,
|
|
45
|
-
B = e.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
q = new ModalMessage(
|
|
44
|
+
let q = e.html_id,
|
|
45
|
+
B = e.css;
|
|
46
|
+
(null != q && "" !== q && null != B && "" !== B) ||
|
|
47
|
+
((q = void 0), (B = void 0));
|
|
48
|
+
const C = e.message_extras;
|
|
49
|
+
let D;
|
|
50
|
+
if (o === ModalMessage.it || o === InAppMessage.qe.Ve)
|
|
51
|
+
D = new ModalMessage(
|
|
53
52
|
s,
|
|
54
53
|
n,
|
|
55
|
-
|
|
54
|
+
m,
|
|
56
55
|
l,
|
|
57
56
|
i,
|
|
58
57
|
f,
|
|
@@ -75,14 +74,15 @@ export function newInAppMessageFromJson(e) {
|
|
|
75
74
|
F,
|
|
76
75
|
M,
|
|
77
76
|
y,
|
|
77
|
+
q,
|
|
78
78
|
B,
|
|
79
79
|
C,
|
|
80
80
|
);
|
|
81
81
|
else if (o === FullScreenMessage.it)
|
|
82
|
-
|
|
82
|
+
D = new FullScreenMessage(
|
|
83
83
|
s,
|
|
84
84
|
n,
|
|
85
|
-
|
|
85
|
+
m,
|
|
86
86
|
l,
|
|
87
87
|
i,
|
|
88
88
|
f,
|
|
@@ -106,15 +106,16 @@ export function newInAppMessageFromJson(e) {
|
|
|
106
106
|
M,
|
|
107
107
|
y,
|
|
108
108
|
z,
|
|
109
|
+
q,
|
|
109
110
|
B,
|
|
110
111
|
C,
|
|
111
112
|
);
|
|
112
113
|
else if (o === SlideUpMessage.it)
|
|
113
|
-
|
|
114
|
+
D = new SlideUpMessage(
|
|
114
115
|
s,
|
|
115
116
|
n,
|
|
116
|
-
m,
|
|
117
117
|
t,
|
|
118
|
+
m,
|
|
118
119
|
l,
|
|
119
120
|
i,
|
|
120
121
|
f,
|
|
@@ -130,23 +131,24 @@ export function newInAppMessageFromJson(e) {
|
|
|
130
131
|
v,
|
|
131
132
|
J,
|
|
132
133
|
S,
|
|
134
|
+
q,
|
|
133
135
|
B,
|
|
134
136
|
C,
|
|
135
137
|
);
|
|
136
138
|
else {
|
|
137
139
|
if (
|
|
138
140
|
o !== HtmlMessage.it &&
|
|
139
|
-
o !== InAppMessage.
|
|
140
|
-
o !== InAppMessage.
|
|
141
|
+
o !== InAppMessage.qe.$e &&
|
|
142
|
+
o !== InAppMessage.qe.We
|
|
141
143
|
)
|
|
142
144
|
return void r.error("Ignoring message with unknown type " + o);
|
|
143
145
|
{
|
|
144
146
|
const o = e.message_fields;
|
|
145
|
-
(
|
|
146
|
-
(
|
|
147
|
+
(D = new HtmlMessage(s, m, l, u, a, J, S, F, q, B, o, C)),
|
|
148
|
+
(D.trusted = e.trusted || !1);
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
|
-
return (
|
|
151
|
+
return (D.we = o), D;
|
|
150
152
|
}
|
|
151
153
|
export function buttonsFromSerializedInAppMessage(e) {
|
|
152
154
|
const o = [];
|
|
@@ -5,73 +5,58 @@ import HtmlMessage from "./models/html-message.js";
|
|
|
5
5
|
import InAppMessage from "./models/in-app-message.js";
|
|
6
6
|
import InAppMessageButton from "./models/in-app-message-button.js";
|
|
7
7
|
import s from "../common/event-logger.js";
|
|
8
|
-
import { newInAppMessageFromJson as
|
|
9
|
-
import { randomInclusive as
|
|
8
|
+
import { newInAppMessageFromJson as pt } from "./in-app-message-factory.js";
|
|
9
|
+
import { randomInclusive as U } from "../util/math.js";
|
|
10
10
|
import t from "../models/request-result.js";
|
|
11
11
|
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
12
12
|
import T from "../managers/subscription-manager.js";
|
|
13
|
-
import
|
|
14
|
-
import { validateValueIsFromEnum as J } from "../util/code-utils.js";
|
|
13
|
+
import mt from "../triggers/models/trigger.js";
|
|
15
14
|
import { BRAZE_ACTION_URI_REGEX as Z } from "../util/validation-utils.js";
|
|
16
15
|
import {
|
|
17
|
-
containsPushPrimerBrazeAction as
|
|
18
|
-
containsUnknownBrazeAction as
|
|
16
|
+
containsPushPrimerBrazeAction as gt,
|
|
17
|
+
containsUnknownBrazeAction as ft,
|
|
19
18
|
getDecodedBrazeAction as W,
|
|
20
|
-
ineligibleBrazeActionURLErrorMessage as
|
|
21
|
-
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as
|
|
19
|
+
ineligibleBrazeActionURLErrorMessage as dt,
|
|
20
|
+
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as jt,
|
|
22
21
|
} from "../util/braze-actions.js";
|
|
23
22
|
import vt from "../Push/utils/push-utils.js";
|
|
24
|
-
import
|
|
23
|
+
import D from "../util/request-header-utils.js";
|
|
25
24
|
import { STORAGE_KEYS as o } from "../managers/storage-manager.js";
|
|
26
25
|
import { FullScreenMessage, ModalMessage, SlideUpMessage } from "./index.js";
|
|
27
26
|
export default class aa {
|
|
28
27
|
constructor(t, s, i, r) {
|
|
29
28
|
(this.qt = t),
|
|
30
|
-
(this.
|
|
29
|
+
(this.ri = s),
|
|
31
30
|
(this.u = i),
|
|
32
31
|
(this.wt = r),
|
|
33
32
|
(this.qt = t),
|
|
34
|
-
(this.
|
|
33
|
+
(this.ri = s),
|
|
35
34
|
(this.u = i),
|
|
36
35
|
(this.wt = r),
|
|
37
36
|
(this._e = new T()),
|
|
38
37
|
e.$t(this._e),
|
|
39
|
-
(this.
|
|
40
|
-
(this.
|
|
41
|
-
(this.
|
|
38
|
+
(this.Xe = 1e3),
|
|
39
|
+
(this.Ye = 6e4),
|
|
40
|
+
(this.Ze = null);
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
Mi() {
|
|
44
43
|
return this._e;
|
|
45
44
|
}
|
|
46
|
-
|
|
45
|
+
_i(t) {
|
|
47
46
|
return this._e.It(t);
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
return this.
|
|
48
|
+
Pi() {
|
|
49
|
+
return this.Ze;
|
|
51
50
|
}
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
}
|
|
55
|
-
Ve(e, r) {
|
|
56
|
-
if (!e) return new t();
|
|
57
|
-
if (
|
|
58
|
-
!J(
|
|
59
|
-
InAppMessage.Me,
|
|
60
|
-
r,
|
|
61
|
-
`${r} is not a valid in-app message display failure`,
|
|
62
|
-
"InAppMessage.DisplayFailures",
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
return new t();
|
|
66
|
-
const n = { trigger_ids: [e], error_code: r };
|
|
67
|
-
return s.q(i.We, n);
|
|
51
|
+
$i(t) {
|
|
52
|
+
this.Ze = t;
|
|
68
53
|
}
|
|
69
54
|
q(e, n, o, a) {
|
|
70
55
|
const l = new t();
|
|
71
56
|
let u;
|
|
72
57
|
if (e instanceof ControlMessage) u = { trigger_ids: [e.triggerId] };
|
|
73
58
|
else {
|
|
74
|
-
if (n === i.
|
|
59
|
+
if (n === i.Ei || (e instanceof HtmlMessage && n === i.Gi)) {
|
|
75
60
|
if (!e.p(a))
|
|
76
61
|
return (
|
|
77
62
|
r.info(
|
|
@@ -79,7 +64,7 @@ export default class aa {
|
|
|
79
64
|
),
|
|
80
65
|
l
|
|
81
66
|
);
|
|
82
|
-
} else if (n === i.
|
|
67
|
+
} else if (n === i.Oi) {
|
|
83
68
|
if (!e.K())
|
|
84
69
|
return (
|
|
85
70
|
r.info(
|
|
@@ -88,11 +73,15 @@ export default class aa {
|
|
|
88
73
|
l
|
|
89
74
|
);
|
|
90
75
|
}
|
|
91
|
-
u = this.
|
|
76
|
+
u = this.Xi(e);
|
|
92
77
|
}
|
|
93
|
-
return null == u
|
|
78
|
+
return null == u
|
|
79
|
+
? l
|
|
80
|
+
: (e.messageExtras && (u.message_extras = e.messageExtras),
|
|
81
|
+
null != o && (u.bid = o),
|
|
82
|
+
s.q(n, u));
|
|
94
83
|
}
|
|
95
|
-
|
|
84
|
+
Hi(e, n) {
|
|
96
85
|
const o = new t();
|
|
97
86
|
if (!e.p())
|
|
98
87
|
return (
|
|
@@ -101,32 +90,32 @@ export default class aa {
|
|
|
101
90
|
),
|
|
102
91
|
o
|
|
103
92
|
);
|
|
104
|
-
const a = this.
|
|
93
|
+
const a = this.Xi(n);
|
|
105
94
|
return null == a
|
|
106
95
|
? o
|
|
107
|
-
: e.id === InAppMessageButton.
|
|
96
|
+
: e.id === InAppMessageButton.Ji
|
|
108
97
|
? (r.info(
|
|
109
98
|
"This in-app message button does not have a tracking id. Not logging event to Braze servers.",
|
|
110
99
|
),
|
|
111
100
|
o)
|
|
112
|
-
: (null != e.id && (a.bid = e.id), s.q(i.
|
|
101
|
+
: (null != e.id && (a.bid = e.id), s.q(i.Gi, a));
|
|
113
102
|
}
|
|
114
|
-
|
|
103
|
+
Ki(t) {
|
|
115
104
|
const e = t.messageFields;
|
|
116
105
|
return (null != e && e.is_push_primer) || !1;
|
|
117
106
|
}
|
|
118
|
-
|
|
107
|
+
Li(t) {
|
|
119
108
|
if (!(t instanceof InAppMessage)) return;
|
|
120
109
|
const e = (t) => {
|
|
121
110
|
if (!t) return;
|
|
122
111
|
const e = W(t);
|
|
123
|
-
return
|
|
124
|
-
?
|
|
125
|
-
:
|
|
126
|
-
?
|
|
112
|
+
return ft(e)
|
|
113
|
+
? dt(jt.Qi, "In-App Message")
|
|
114
|
+
: gt(e) && !vt.Vi()
|
|
115
|
+
? dt(jt.Wi, "In-App Message")
|
|
127
116
|
: void 0;
|
|
128
117
|
};
|
|
129
|
-
if (this.
|
|
118
|
+
if (this.Ki(t) && !vt.Vi())
|
|
130
119
|
return "In-App Message contains a push prompt, but is not eligible for a push prompt. Ignoring.";
|
|
131
120
|
const s = t.buttons || [];
|
|
132
121
|
let i;
|
|
@@ -144,66 +133,60 @@ export default class aa {
|
|
|
144
133
|
? e(t.uri)
|
|
145
134
|
: void 0;
|
|
146
135
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
136
|
+
Yi(t, e, s, i) {
|
|
137
|
+
const n = this.qt;
|
|
138
|
+
if (!n) return;
|
|
139
|
+
const o = n.Zi(!1, !1),
|
|
140
|
+
a = n.Js(o);
|
|
141
|
+
(a.template = { trigger_id: t.triggerId, trigger_event_type: e }),
|
|
142
|
+
null != s && (a.template.data = s.Ir());
|
|
143
|
+
const l = n.$s(a, D.Ps.Mr);
|
|
144
|
+
n.Xs(
|
|
145
|
+
a,
|
|
146
|
+
(n = -1) => {
|
|
147
|
+
if (!this.qt) return;
|
|
148
|
+
const o = new Date().valueOf();
|
|
149
|
+
D._s(this.u, D.Ps.Mr, o),
|
|
150
|
+
-1 !== n && l.push(["X-Braze-Req-Tokens-Remaining", n.toString()]),
|
|
151
|
+
C.Gs({
|
|
152
|
+
url: `${this.qt.Hs()}/template/`,
|
|
153
|
+
data: a,
|
|
154
|
+
headers: l,
|
|
163
155
|
L: (e) => {
|
|
164
|
-
if ((
|
|
165
|
-
return (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
);
|
|
169
|
-
if ((this.qt.Xs(), null == e || null == e.templated_message))
|
|
170
|
-
return void this.Ve(t.triggerId, InAppMessage.Me.Or);
|
|
156
|
+
if ((D.Qs(this.u, D.Ps.Mr, 1), !this.qt.Ks(a, e, l)))
|
|
157
|
+
return void ("function" == typeof t.Tr && t.Tr());
|
|
158
|
+
if ((this.qt.Os(), null == e || null == e.templated_message))
|
|
159
|
+
return;
|
|
171
160
|
const s = e.templated_message;
|
|
172
|
-
if (s.type !==
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return void this.Ve(t.triggerId, InAppMessage.Me.Lr);
|
|
177
|
-
const n = this.Wi(i);
|
|
161
|
+
if (s.type !== mt._r.Br) return;
|
|
162
|
+
const i = pt(s.data);
|
|
163
|
+
if (null == i) return;
|
|
164
|
+
const n = this.Li(i);
|
|
178
165
|
if (n)
|
|
179
|
-
return r.error(n), void ("function" == typeof t.
|
|
180
|
-
"function" == typeof t.
|
|
181
|
-
? t.Qr(i)
|
|
182
|
-
: this.Ve(t.triggerId, InAppMessage.Me.Or);
|
|
166
|
+
return r.error(n), void ("function" == typeof t.Tr && t.Tr());
|
|
167
|
+
"function" == typeof t.Er && t.Er(i);
|
|
183
168
|
},
|
|
184
169
|
error: (r) => {
|
|
185
170
|
let n = `getting user personalization for message ${t.triggerId}`;
|
|
186
|
-
if (new Date().valueOf() - t.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const r = Math.min(t.Vr, this.Oe),
|
|
191
|
-
o = this.Ne;
|
|
171
|
+
if (new Date().valueOf() - t.Gr < t.Nr) {
|
|
172
|
+
D.Ys(this.u, D.Ps.Mr);
|
|
173
|
+
const r = Math.min(t.Nr, this.Ye),
|
|
174
|
+
o = this.Xe;
|
|
192
175
|
null == i && (i = o);
|
|
193
|
-
const a = Math.min(r,
|
|
176
|
+
const a = Math.min(r, U(o, 3 * i));
|
|
194
177
|
(n += `. Retrying in ${a} ms`),
|
|
195
178
|
setTimeout(() => {
|
|
196
|
-
this.
|
|
179
|
+
this.Yi(t, e, s, a);
|
|
197
180
|
}, a);
|
|
198
181
|
}
|
|
199
|
-
this.qt.
|
|
182
|
+
this.qt.Vs(r, n);
|
|
200
183
|
},
|
|
201
|
-
})
|
|
184
|
+
});
|
|
202
185
|
},
|
|
203
|
-
|
|
186
|
+
D.Ps.Mr,
|
|
204
187
|
);
|
|
205
188
|
}
|
|
206
|
-
|
|
189
|
+
Xi(t) {
|
|
207
190
|
if (null == t.triggerId)
|
|
208
191
|
return (
|
|
209
192
|
r.info(
|
|
@@ -214,40 +197,40 @@ export default class aa {
|
|
|
214
197
|
const e = {};
|
|
215
198
|
return null != t.triggerId && (e.trigger_ids = [t.triggerId]), e;
|
|
216
199
|
}
|
|
217
|
-
|
|
200
|
+
je(t) {
|
|
218
201
|
return (
|
|
219
202
|
!!this.u &&
|
|
220
203
|
!(
|
|
221
204
|
!(t && t instanceof InAppMessage && t.constructor !== InAppMessage) ||
|
|
222
205
|
t instanceof ControlMessage
|
|
223
206
|
) &&
|
|
224
|
-
this.u.k(o.C.
|
|
207
|
+
this.u.k(o.C.Cr, t.Y())
|
|
225
208
|
);
|
|
226
209
|
}
|
|
227
|
-
|
|
210
|
+
Ue() {
|
|
228
211
|
if (!this.u) return null;
|
|
229
|
-
const t = this.u.j(o.C.
|
|
212
|
+
const t = this.u.j(o.C.Cr);
|
|
230
213
|
if (!t) return null;
|
|
231
214
|
let e;
|
|
232
215
|
switch (t.type) {
|
|
233
|
-
case InAppMessage.
|
|
234
|
-
e = FullScreenMessage.
|
|
216
|
+
case InAppMessage.qe.Or:
|
|
217
|
+
e = FullScreenMessage.Xr(t);
|
|
235
218
|
break;
|
|
236
|
-
case InAppMessage.
|
|
237
|
-
case InAppMessage.
|
|
238
|
-
case InAppMessage.
|
|
239
|
-
e = HtmlMessage.
|
|
219
|
+
case InAppMessage.qe.Hr:
|
|
220
|
+
case InAppMessage.qe.$e:
|
|
221
|
+
case InAppMessage.qe.We:
|
|
222
|
+
e = HtmlMessage.Xr(t);
|
|
240
223
|
break;
|
|
241
|
-
case InAppMessage.
|
|
242
|
-
case InAppMessage.
|
|
243
|
-
e = ModalMessage.
|
|
224
|
+
case InAppMessage.qe.Jr:
|
|
225
|
+
case InAppMessage.qe.Ve:
|
|
226
|
+
e = ModalMessage.Xr(t);
|
|
244
227
|
break;
|
|
245
|
-
case InAppMessage.
|
|
246
|
-
e = SlideUpMessage.
|
|
228
|
+
case InAppMessage.qe.Kr:
|
|
229
|
+
e = SlideUpMessage.Xr(t);
|
|
247
230
|
}
|
|
248
|
-
return e && this.
|
|
231
|
+
return e && this.Lr(), e;
|
|
249
232
|
}
|
|
250
|
-
|
|
251
|
-
this.u && this.u.
|
|
233
|
+
Lr() {
|
|
234
|
+
this.u && this.u.ti(o.C.Cr);
|
|
252
235
|
}
|
|
253
236
|
}
|
|
@@ -12,11 +12,11 @@ export function logInAppMessageButtonClick(o, t) {
|
|
|
12
12
|
if (!(o instanceof InAppMessageButton))
|
|
13
13
|
return r.error("button must be an InAppMessageButton object"), !1;
|
|
14
14
|
if (!(t instanceof InAppMessage)) return r.error(sr), !1;
|
|
15
|
-
const n = se.m().
|
|
15
|
+
const n = se.m().Hi(o, t);
|
|
16
16
|
if (n.L)
|
|
17
17
|
for (let r = 0; r < n.ge.length; r++)
|
|
18
18
|
et.rr().fe(
|
|
19
|
-
tt.
|
|
19
|
+
tt.Qr,
|
|
20
20
|
[
|
|
21
21
|
t.triggerId,
|
|
22
22
|
null === (s = o.id) || void 0 === s ? void 0 : s.toString(),
|
|
@@ -9,11 +9,11 @@ import { TriggersProviderFactory as et } from "../triggers/triggers-provider-fac
|
|
|
9
9
|
export function logInAppMessageClick(o) {
|
|
10
10
|
if (!e.X()) return !1;
|
|
11
11
|
if (!(o instanceof InAppMessage)) return r.error(sr), !1;
|
|
12
|
-
const s = se.m().q(o, i.
|
|
12
|
+
const s = se.m().q(o, i.Ei);
|
|
13
13
|
if (s) {
|
|
14
|
-
o.
|
|
14
|
+
o.Ur() || logInAppMessageImpression(o);
|
|
15
15
|
for (let r = 0; r < s.ge.length; r++)
|
|
16
|
-
et.rr().fe(tt.
|
|
16
|
+
et.rr().fe(tt.Qr, [o.triggerId], s.ge[r]);
|
|
17
17
|
}
|
|
18
18
|
return s.L;
|
|
19
19
|
}
|