@braze/web-sdk 6.11.0 → 6.12.1
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 +36 -5
- package/package.json +1 -1
- package/shared-lib/event-types.js +4 -4
- package/shared-lib/indexed-db-adapter.js +51 -51
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +9 -9
- package/src/DUST/dust-config-store.js +89 -0
- package/src/DUST/dust-connection-core.js +7 -21
- package/src/DUST/dust-message-dedup.js +33 -0
- package/src/DUST/dust-provider.js +367 -397
- package/src/DUST/dust-tab-identity.js +30 -0
- package/src/DUST/index.js +7 -9
- package/src/DUST/subscribe-to-dust.js +5 -5
- package/src/FeatureFlags/feature-flag-factory.js +4 -4
- package/src/FeatureFlags/feature-flag.js +5 -5
- package/src/FeatureFlags/feature-flags-provider-factory.js +8 -1
- package/src/FeatureFlags/feature-flags-provider.js +74 -74
- 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 +1 -1
- package/src/InAppMessage/defer-in-app-message.js +2 -2
- package/src/InAppMessage/display/get-animation-effect.js +1 -1
- package/src/InAppMessage/display/html-message-display-utils.js +4 -4
- package/src/InAppMessage/display/html-message-to-html.js +10 -10
- package/src/InAppMessage/display/in-app-message-to-html.js +42 -42
- package/src/InAppMessage/display/modal-utils.js +14 -14
- package/src/InAppMessage/get-deferred-in-app-message.js +2 -2
- package/src/InAppMessage/in-app-message-factory.js +6 -6
- package/src/InAppMessage/in-app-message-manager-factory.js +5 -5
- package/src/InAppMessage/in-app-message-manager.js +73 -73
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-html-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-impression.js +2 -2
- package/src/InAppMessage/models/full-screen-message.js +9 -9
- package/src/InAppMessage/models/html-message.js +4 -4
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +52 -52
- package/src/InAppMessage/models/modal-message.js +7 -7
- package/src/InAppMessage/models/slide-up-message.js +11 -11
- 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 +5 -5
- package/src/InAppMessage/ui/show-in-app-message.js +40 -37
- 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 +6 -6
- package/src/Push/push-manager.js +14 -14
- package/src/Push/unregister-push-token-on-server.js +3 -3
- package/src/Push/utils/push-utils.js +10 -10
- package/src/User/user.js +19 -19
- package/src/common/content-cards-display.js +21 -21
- package/src/common/event-logger.js +2 -2
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +5 -5
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +41 -41
- package/src/managers/device-manager.js +22 -22
- package/src/managers/network-manager.js +108 -108
- package/src/managers/server-config-manager.js +83 -83
- package/src/managers/session-manager.js +6 -6
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +127 -125
- package/src/managers/subscription-manager.js +1 -1
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +7 -7
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +3 -3
- package/src/models/push-token.js +3 -3
- package/src/models/server-config.js +31 -31
- package/src/request-controller.js +39 -39
- package/src/triggers/models/filter.js +58 -58
- package/src/triggers/models/in-app-message-click-data.js +4 -4
- package/src/triggers/models/push-click-data.js +2 -2
- package/src/triggers/models/trigger-condition.js +35 -35
- package/src/triggers/models/trigger.js +37 -37
- package/src/triggers/triggers-provider-factory.js +3 -3
- package/src/triggers/triggers-provider.js +50 -50
- package/src/types.js +2 -2
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +2 -2
- package/src/ui/js/iam-css.js +2 -2
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +2 -2
- package/src/util/browser-detector.js +15 -15
- package/src/util/client-hints-parser.js +5 -5
- package/src/util/component-utils.js +4 -4
- package/src/util/dom-utils.js +5 -5
- package/src/util/ecommerce-event-validation.js +77 -48
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +20 -20
- package/src/util/string-utils.js +5 -0
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +4 -4
- package/src/util/window-utils.js +2 -2
- package/src/DUST/dust-shared-worker-code.js +0 -2
- package/src/DUST/dust-shared-worker-impl.js +0 -234
- package/src/DUST/dust-worker-bridge.js +0 -151
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addPassiveEventListener as F,
|
|
3
|
-
buildSvg as
|
|
3
|
+
buildSvg as oe,
|
|
4
4
|
detectSwipe as O,
|
|
5
5
|
DIRECTIONS as P,
|
|
6
6
|
} from "../../util/dom-utils.js";
|
|
7
7
|
import { createCloseButton as T } from "../../util/component-utils.js";
|
|
8
|
-
import { isTransparent as
|
|
8
|
+
import { isTransparent as te, toRgba as ae } from "../../util/color-utils.js";
|
|
9
9
|
import FullScreenMessage from "../models/full-screen-message.js";
|
|
10
10
|
import HtmlMessage from "../models/html-message.js";
|
|
11
11
|
import ModalMessage from "../models/modal-message.js";
|
|
12
12
|
import SlideUpMessage from "../models/slide-up-message.js";
|
|
13
13
|
import { logInAppMessageClick } from "../log-in-app-message-click.js";
|
|
14
14
|
import { _handleBrazeAction as Q } from "../../Core/handle-braze-action.js";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
15
|
+
import jt from "./html-message-to-html.js";
|
|
16
|
+
import ie from "./modal-utils.js";
|
|
17
17
|
import { Guid as V } from "../../../shared-lib/index.js";
|
|
18
|
-
import { KeyCodes as
|
|
18
|
+
import { KeyCodes as le } from "../../util/key-codes.js";
|
|
19
19
|
import {
|
|
20
|
-
IamClickAction as
|
|
21
|
-
IamCropType as
|
|
22
|
-
IamImageStyle as
|
|
23
|
-
IamOpenTarget as
|
|
24
|
-
IamOrientation as
|
|
25
|
-
IamSlideFrom as
|
|
26
|
-
IamTextAlignment as
|
|
20
|
+
IamClickAction as ce,
|
|
21
|
+
IamCropType as de,
|
|
22
|
+
IamImageStyle as ue,
|
|
23
|
+
IamOpenTarget as dt,
|
|
24
|
+
IamOrientation as be,
|
|
25
|
+
IamSlideFrom as fe,
|
|
26
|
+
IamTextAlignment as pe,
|
|
27
27
|
} from "../constants.js";
|
|
28
|
-
export default function
|
|
28
|
+
export default function ge(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
29
29
|
if (((e.$o = document.activeElement), e instanceof HtmlMessage))
|
|
30
|
-
return
|
|
30
|
+
return jt(e, o, a, n, i);
|
|
31
31
|
const l = (function (e, o, t, a, n, i = document.body, s = "ltr") {
|
|
32
32
|
let m = null;
|
|
33
33
|
const l = document.createElement("div");
|
|
@@ -38,9 +38,9 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
38
38
|
((l.className += " ab-modal-interactions"),
|
|
39
39
|
l.setAttribute("tabindex", "-1")),
|
|
40
40
|
e.Mo() ||
|
|
41
|
-
((l.style.color =
|
|
42
|
-
(l.style.backgroundColor =
|
|
43
|
-
|
|
41
|
+
((l.style.color = ae(e.textColor)),
|
|
42
|
+
(l.style.backgroundColor = ae(e.backgroundColor)),
|
|
43
|
+
te(e.backgroundColor) && (l.className += " ab-no-shadow"));
|
|
44
44
|
const c = () => {
|
|
45
45
|
-1 !== l.className.indexOf("ab-start-hidden") &&
|
|
46
46
|
((l.className = l.className.replace("ab-start-hidden", "")),
|
|
@@ -68,28 +68,28 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
if (
|
|
71
|
-
(e.imageStyle ===
|
|
72
|
-
e.orientation ===
|
|
71
|
+
(e.imageStyle === ue.GRAPHIC && (l.className += " graphic"),
|
|
72
|
+
e.orientation === be.LANDSCAPE && (l.className += " landscape"),
|
|
73
73
|
null != e.buttons && 0 === e.buttons.length)
|
|
74
74
|
) {
|
|
75
|
-
e.clickAction !==
|
|
75
|
+
e.clickAction !== ce.NONE && (l.className += " ab-clickable");
|
|
76
76
|
const o = (o) => (
|
|
77
77
|
e.tl(l, () => {
|
|
78
78
|
logInAppMessageClick(e),
|
|
79
|
-
e.clickAction ===
|
|
80
|
-
Q(e.uri || "", a || e.openTarget ===
|
|
79
|
+
e.clickAction === ce.URI &&
|
|
80
|
+
Q(e.uri || "", a || e.openTarget === dt.BLANK, o);
|
|
81
81
|
}),
|
|
82
82
|
o.stopPropagation(),
|
|
83
83
|
!1
|
|
84
84
|
);
|
|
85
85
|
(l.onclick = o),
|
|
86
86
|
l.addEventListener("keydown", (e) => {
|
|
87
|
-
if (e.keyCode ===
|
|
87
|
+
if (e.keyCode === le.Lo || e.keyCode === le.To) return o(e);
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
const d = T(
|
|
91
91
|
"Close Message",
|
|
92
|
-
e.Mo() ? void 0 :
|
|
92
|
+
e.Mo() ? void 0 : ae(e.closeButtonColor),
|
|
93
93
|
() => {
|
|
94
94
|
e.tl(l);
|
|
95
95
|
},
|
|
@@ -100,7 +100,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
100
100
|
(u.className = "ab-message-text"),
|
|
101
101
|
(u.dir = s),
|
|
102
102
|
u.setAttribute("role", "article");
|
|
103
|
-
const b = (e.messageAlignment || e.
|
|
103
|
+
const b = (e.messageAlignment || e.qo).toLowerCase();
|
|
104
104
|
u.className += " " + b + "-aligned";
|
|
105
105
|
let f = !1;
|
|
106
106
|
const p = document.createElement("div");
|
|
@@ -108,7 +108,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
108
108
|
const o = document.createElement("img");
|
|
109
109
|
if (
|
|
110
110
|
(o.setAttribute("src", e.imageUrl),
|
|
111
|
-
e.
|
|
111
|
+
e.Ao(o),
|
|
112
112
|
0 === document.querySelectorAll(".ab-iam-img-loading").length)
|
|
113
113
|
) {
|
|
114
114
|
f = !0;
|
|
@@ -124,7 +124,7 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
124
124
|
r(!1);
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
if (e.cropType ===
|
|
127
|
+
if (e.cropType === de.CENTER_CROP) {
|
|
128
128
|
const e = document.createElement("div");
|
|
129
129
|
(e.className = "ab-center-cropped-img"),
|
|
130
130
|
e.appendChild(o),
|
|
@@ -136,8 +136,8 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
136
136
|
const o = document.createElement("span");
|
|
137
137
|
(o.className = "ab-icon"),
|
|
138
138
|
e.Mo() ||
|
|
139
|
-
((o.style.backgroundColor =
|
|
140
|
-
(o.style.color =
|
|
139
|
+
((o.style.backgroundColor = ae(e.iconBackgroundColor)),
|
|
140
|
+
(o.style.color = ae(e.iconColor)));
|
|
141
141
|
const t = document.createElement("i");
|
|
142
142
|
(t.className = "fa"),
|
|
143
143
|
t.appendChild(document.createTextNode(e.icon)),
|
|
@@ -149,32 +149,32 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
149
149
|
}
|
|
150
150
|
if ((F(u, "touchstart"), e.header && e.header.length > 0)) {
|
|
151
151
|
const o = document.createElement("h1");
|
|
152
|
-
(o.className = "ab-message-header"), (e.
|
|
153
|
-
const t = (e.headerAlignment ||
|
|
152
|
+
(o.className = "ab-message-header"), (e.Do = V.de()), (o.id = e.Do);
|
|
153
|
+
const t = (e.headerAlignment || pe.CENTER).toLowerCase();
|
|
154
154
|
(o.className += " " + t + "-aligned"),
|
|
155
|
-
e.Mo() || (o.style.color =
|
|
155
|
+
e.Mo() || (o.style.color = ae(e.headerTextColor)),
|
|
156
156
|
o.appendChild(document.createTextNode(e.header)),
|
|
157
157
|
u.appendChild(o);
|
|
158
158
|
}
|
|
159
|
-
const g = e.
|
|
160
|
-
return u.appendChild(g), l.appendChild(u), f || c(), (e.
|
|
159
|
+
const g = e.Eo();
|
|
160
|
+
return u.appendChild(g), l.appendChild(u), f || c(), (e.Bo = l), l;
|
|
161
161
|
})(e, o, t, a, n, s, m);
|
|
162
162
|
if (e instanceof FullScreenMessage || e instanceof ModalMessage) {
|
|
163
163
|
const o = e instanceof FullScreenMessage ? "ab-fullscreen" : "ab-modal";
|
|
164
164
|
(l.className += ` ${o} ab-centered`),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
ie.Go(e, l, a),
|
|
166
|
+
ie.Ho(l),
|
|
167
|
+
ie.Io(e.Do, l);
|
|
168
168
|
} else if (e instanceof SlideUpMessage) {
|
|
169
169
|
(l.className += " ab-slideup"),
|
|
170
170
|
l.setAttribute("tabindex", "0"),
|
|
171
171
|
l.setAttribute("role", "alert");
|
|
172
172
|
const o = l.getElementsByClassName("ab-close-button")[0];
|
|
173
173
|
if (null != o) {
|
|
174
|
-
const t =
|
|
174
|
+
const t = oe(
|
|
175
175
|
"0 0 11.38 19.44",
|
|
176
176
|
"M11.38 9.72l-9.33 9.72L0 17.3l7.27-7.58L0 2.14 2.05 0l9.33 9.72z",
|
|
177
|
-
e.Mo() ? void 0 :
|
|
177
|
+
e.Mo() ? void 0 : ae(e.closeButtonColor),
|
|
178
178
|
);
|
|
179
179
|
t.setAttribute("class", `ab-chevron ${m}`), o.appendChild(t);
|
|
180
180
|
}
|
|
@@ -187,9 +187,9 @@ export default function Fe(e, o, t, a, n, i, s = document.body, m = "ltr") {
|
|
|
187
187
|
(l.className += " ab-swiped-right"),
|
|
188
188
|
null != o && null != o.onclick && o.onclick(e);
|
|
189
189
|
}),
|
|
190
|
-
e.slideFrom ===
|
|
191
|
-
? ((t = P.
|
|
192
|
-
: ((t = P.
|
|
190
|
+
e.slideFrom === fe.TOP
|
|
191
|
+
? ((t = P.Jo), (a = " ab-swiped-up"))
|
|
192
|
+
: ((t = P.Ko), (a = " ab-swiped-down")),
|
|
193
193
|
O(l, t, (e) => {
|
|
194
194
|
(l.className += a), null != o && null != o.onclick && o.onclick(e);
|
|
195
195
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { _handleBrazeAction as Q } from "../../Core/handle-braze-action.js";
|
|
2
2
|
import { logInAppMessageButtonClick } from "../log-in-app-message-button-click.js";
|
|
3
|
-
import { toRgba as
|
|
3
|
+
import { toRgba as ae } from "../../util/color-utils.js";
|
|
4
4
|
import { addPassiveEventListener as F } from "../../util/dom-utils.js";
|
|
5
|
-
import { KeyCodes as
|
|
6
|
-
import { IamClickAction as
|
|
7
|
-
const
|
|
8
|
-
|
|
5
|
+
import { KeyCodes as le } from "../../util/key-codes.js";
|
|
6
|
+
import { IamClickAction as ce, IamOpenTarget as dt } from "../constants.js";
|
|
7
|
+
const ie = {
|
|
8
|
+
Ho: (t) => {
|
|
9
9
|
const o = t.querySelectorAll(".ab-close-button, .ab-message-button");
|
|
10
10
|
let e;
|
|
11
11
|
for (let t = 0; t < o.length; t++) (e = o[t]), (e.tabIndex = 0);
|
|
@@ -14,7 +14,7 @@ const xe = {
|
|
|
14
14
|
s = o[o.length - 1];
|
|
15
15
|
t.addEventListener("keydown", (o) => {
|
|
16
16
|
const a = document.activeElement;
|
|
17
|
-
o.keyCode ===
|
|
17
|
+
o.keyCode === le.No &&
|
|
18
18
|
(o.shiftKey || (a !== s && a !== t)
|
|
19
19
|
? !o.shiftKey ||
|
|
20
20
|
(a !== e && a !== t) ||
|
|
@@ -23,14 +23,14 @@ const xe = {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
Io: (t, o) => {
|
|
27
27
|
o.setAttribute("role", "dialog"),
|
|
28
28
|
o.setAttribute("aria-modal", "true"),
|
|
29
29
|
t
|
|
30
30
|
? o.setAttribute("aria-labelledby", t)
|
|
31
31
|
: o.setAttribute("aria-label", "Modal Message");
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
Go: (t, o, e) => {
|
|
34
34
|
if (t.buttons && t.buttons.length > 0) {
|
|
35
35
|
const s = document.createElement("div");
|
|
36
36
|
(s.className = "ab-message-buttons"), o.appendChild(s);
|
|
@@ -39,8 +39,8 @@ const xe = {
|
|
|
39
39
|
const l = (s) => (a) => (
|
|
40
40
|
t.tl(o, () => {
|
|
41
41
|
logInAppMessageButtonClick(s, t),
|
|
42
|
-
s.clickAction ===
|
|
43
|
-
Q(s.uri || "", e || t.openTarget ===
|
|
42
|
+
s.clickAction === ce.URI &&
|
|
43
|
+
Q(s.uri || "", e || t.openTarget === dt.BLANK, a);
|
|
44
44
|
}),
|
|
45
45
|
a.stopPropagation(),
|
|
46
46
|
!1
|
|
@@ -55,13 +55,13 @@ const xe = {
|
|
|
55
55
|
"" === e.text && (n = " "),
|
|
56
56
|
a.appendChild(document.createTextNode(n)),
|
|
57
57
|
t.Mo() ||
|
|
58
|
-
((a.style.backgroundColor =
|
|
59
|
-
(a.style.color =
|
|
60
|
-
(a.style.borderColor =
|
|
58
|
+
((a.style.backgroundColor = ae(e.backgroundColor)),
|
|
59
|
+
(a.style.color = ae(e.textColor)),
|
|
60
|
+
(a.style.borderColor = ae(e.borderColor))),
|
|
61
61
|
(a.onclick = l(e)),
|
|
62
62
|
s.appendChild(a);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
|
-
export default
|
|
67
|
+
export default ie;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
|
-
import
|
|
2
|
+
import se from "./in-app-message-manager-factory.js";
|
|
3
3
|
export function getDeferredInAppMessage() {
|
|
4
|
-
if (r.rr()) return
|
|
4
|
+
if (r.rr()) return se.ra().sa();
|
|
5
5
|
}
|
|
@@ -5,7 +5,7 @@ import InAppMessageButton from "./models/in-app-message-button.js";
|
|
|
5
5
|
import ModalMessage from "./models/modal-message.js";
|
|
6
6
|
import SlideUpMessage from "./models/slide-up-message.js";
|
|
7
7
|
import { logger as b } from "../../shared-lib/index.js";
|
|
8
|
-
import { IamServerTypes as
|
|
8
|
+
import { IamServerTypes as gt } from "./constants.js";
|
|
9
9
|
export function newInAppMessageFromJson(e) {
|
|
10
10
|
if (!e) return null;
|
|
11
11
|
if (e.is_control) return ControlMessage.fromJson(e);
|
|
@@ -49,7 +49,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
49
49
|
D = e.language,
|
|
50
50
|
E = e.image_alt;
|
|
51
51
|
let G;
|
|
52
|
-
if (o ===
|
|
52
|
+
if (o === gt.tE || o === gt.eE)
|
|
53
53
|
G = new ModalMessage(
|
|
54
54
|
s,
|
|
55
55
|
n,
|
|
@@ -82,7 +82,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
82
82
|
D,
|
|
83
83
|
E,
|
|
84
84
|
);
|
|
85
|
-
else if (o ===
|
|
85
|
+
else if (o === gt.oE)
|
|
86
86
|
G = new FullScreenMessage(
|
|
87
87
|
s,
|
|
88
88
|
n,
|
|
@@ -116,7 +116,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
116
116
|
D,
|
|
117
117
|
E,
|
|
118
118
|
);
|
|
119
|
-
else if (o ===
|
|
119
|
+
else if (o === gt.RE)
|
|
120
120
|
G = new SlideUpMessage(
|
|
121
121
|
s,
|
|
122
122
|
n,
|
|
@@ -144,7 +144,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
144
144
|
E,
|
|
145
145
|
);
|
|
146
146
|
else {
|
|
147
|
-
if (o !==
|
|
147
|
+
if (o !== gt.ME && o !== gt.CE && o !== gt.DE)
|
|
148
148
|
return void b.error("Ignoring message with unknown type " + o);
|
|
149
149
|
{
|
|
150
150
|
const o = e.message_fields;
|
|
@@ -152,7 +152,7 @@ export function newInAppMessageFromJson(e) {
|
|
|
152
152
|
(G.trusted = e.trusted || !1);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
return (G.
|
|
155
|
+
return (G.Oo = o), G;
|
|
156
156
|
}
|
|
157
157
|
export function buttonsFromSerializedInAppMessage(e) {
|
|
158
158
|
const o = [];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import ea from "./in-app-message-manager.js";
|
|
2
2
|
import r from "../managers/braze-instance.js";
|
|
3
|
-
const
|
|
3
|
+
const se = {
|
|
4
4
|
na: null,
|
|
5
5
|
i: !1,
|
|
6
6
|
ra: () => (
|
|
7
|
-
|
|
7
|
+
se.t(), se.na || (se.na = new ea(r.m(), r.u(), r.p(), r.ir())), se.na
|
|
8
8
|
),
|
|
9
9
|
t: () => {
|
|
10
|
-
|
|
10
|
+
se.i || (r.g(se), (se.i = !0));
|
|
11
11
|
},
|
|
12
12
|
destroy: () => {
|
|
13
|
-
(
|
|
13
|
+
(se.na = null), (se.i = !1);
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
|
-
export default
|
|
16
|
+
export default se;
|
|
@@ -5,28 +5,28 @@ 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 v from "../common/event-logger.js";
|
|
8
|
-
import { newInAppMessageFromJson as
|
|
8
|
+
import { newInAppMessageFromJson as yt } from "./in-app-message-factory.js";
|
|
9
9
|
import { randomInclusive as a } from "../util/math.js";
|
|
10
10
|
import L from "../models/request-result.js";
|
|
11
11
|
import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
|
|
12
12
|
import f from "../managers/subscription-manager.js";
|
|
13
|
-
import
|
|
13
|
+
import vt from "../triggers/models/trigger.js";
|
|
14
14
|
import { BRAZE_ACTION_URI_REGEX as to } from "../util/validation-utils.js";
|
|
15
15
|
import {
|
|
16
|
-
containsPushPrimerBrazeAction as
|
|
17
|
-
containsUnknownBrazeAction as
|
|
16
|
+
containsPushPrimerBrazeAction as It,
|
|
17
|
+
containsUnknownBrazeAction as At,
|
|
18
18
|
getDecodedBrazeAction as eo,
|
|
19
|
-
ineligibleBrazeActionURLErrorMessage as
|
|
20
|
-
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as
|
|
19
|
+
ineligibleBrazeActionURLErrorMessage as Mt,
|
|
20
|
+
INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES as Tt,
|
|
21
21
|
} from "../util/braze-actions.js";
|
|
22
|
-
import
|
|
22
|
+
import Dt from "../Push/utils/push-utils.js";
|
|
23
23
|
import h from "../util/request-header-utils.js";
|
|
24
24
|
import { STORAGE_KEYS as s } from "../managers/storage-manager.js";
|
|
25
25
|
import { FullScreenMessage, ModalMessage, SlideUpMessage } from "./index.js";
|
|
26
26
|
import {
|
|
27
|
-
IamClickAction as
|
|
28
|
-
IamServerTypes as
|
|
29
|
-
IamTiming as
|
|
27
|
+
IamClickAction as ce,
|
|
28
|
+
IamServerTypes as gt,
|
|
29
|
+
IamTiming as kt,
|
|
30
30
|
} from "./constants.js";
|
|
31
31
|
export default class ea {
|
|
32
32
|
constructor(t, e, s, i) {
|
|
@@ -40,24 +40,24 @@ export default class ea {
|
|
|
40
40
|
(this.Ss = i),
|
|
41
41
|
(this.In = new f()),
|
|
42
42
|
r.S(this.In),
|
|
43
|
-
(this.
|
|
43
|
+
(this.Tn = 1e3),
|
|
44
44
|
(this.Dn = 6e4),
|
|
45
|
+
(this.zn = null),
|
|
46
|
+
(this.Bn = null),
|
|
45
47
|
(this._n = null),
|
|
46
|
-
(this.qn =
|
|
47
|
-
(this.xn = null),
|
|
48
|
-
(this.Pn = {});
|
|
48
|
+
(this.qn = {});
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
Pn() {
|
|
51
51
|
return this.In;
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
En(t) {
|
|
54
54
|
return this.In.Ut(t);
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
return this.
|
|
56
|
+
Gn() {
|
|
57
|
+
return this.zn;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
this.
|
|
59
|
+
Nn(t) {
|
|
60
|
+
this.zn = t;
|
|
61
61
|
}
|
|
62
62
|
Dt(t, e, s, i) {
|
|
63
63
|
const r = new L();
|
|
@@ -126,53 +126,53 @@ export default class ea {
|
|
|
126
126
|
const e = (t) => {
|
|
127
127
|
if (!t) return;
|
|
128
128
|
const e = eo(t);
|
|
129
|
-
if (
|
|
130
|
-
if (
|
|
131
|
-
const t =
|
|
132
|
-
if (!t.Zn) return
|
|
129
|
+
if (At(e)) return Mt(Tt.Wn, "In-App Message");
|
|
130
|
+
if (It(e)) {
|
|
131
|
+
const t = Dt.Yn();
|
|
132
|
+
if (!t.Zn) return Dt.So(t.reason, "In-App Message");
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
if (this.Un(t)) {
|
|
136
|
-
const t =
|
|
137
|
-
if (!t.Zn) return
|
|
136
|
+
const t = Dt.Yn();
|
|
137
|
+
if (!t.Zn) return Dt.So(t.reason, "In-App Message");
|
|
138
138
|
}
|
|
139
139
|
const s = t.buttons || [];
|
|
140
140
|
let i;
|
|
141
141
|
for (const t of s)
|
|
142
142
|
if (
|
|
143
|
-
t.clickAction ===
|
|
143
|
+
t.clickAction === ce.URI &&
|
|
144
144
|
t.uri &&
|
|
145
145
|
to.test(t.uri) &&
|
|
146
146
|
((i = e(t.uri)), i)
|
|
147
147
|
)
|
|
148
148
|
return i;
|
|
149
|
-
return t.clickAction ===
|
|
149
|
+
return t.clickAction === ce.URI && t.uri && to.test(t.uri)
|
|
150
150
|
? e(t.uri)
|
|
151
151
|
: void 0;
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
e !== this.
|
|
153
|
+
Ro(t, e) {
|
|
154
|
+
e !== this._n && this._o(), (this.Bn = t), (this._n = e);
|
|
155
155
|
}
|
|
156
|
-
|
|
157
|
-
null != this.
|
|
158
|
-
(clearTimeout(this.
|
|
156
|
+
_o() {
|
|
157
|
+
null != this.Bn &&
|
|
158
|
+
(clearTimeout(this.Bn), (this.Bn = null), (this._n = null));
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
Po(t, e, s, i) {
|
|
161
161
|
const r = this.B;
|
|
162
162
|
if (!r) return;
|
|
163
|
-
this.
|
|
164
|
-
const n = r.
|
|
163
|
+
this._n && t.triggerId !== this._n && (this._o(), h.Ji(this.j, h.it.Xo));
|
|
164
|
+
const n = r.Qo(!1),
|
|
165
165
|
o = r.Z(n);
|
|
166
166
|
(o.template = { trigger_id: t.triggerId, trigger_event_type: e }),
|
|
167
|
-
null != s && (o.template.data = s.
|
|
168
|
-
const u = r.tt(o, h.it.
|
|
167
|
+
null != s && (o.template.data = s.Uo());
|
|
168
|
+
const u = r.tt(o, h.it.Xo);
|
|
169
169
|
r.et(
|
|
170
170
|
o,
|
|
171
171
|
(r = -1) => {
|
|
172
172
|
const n = this.B;
|
|
173
173
|
if (!n) return;
|
|
174
174
|
const m = new Date().valueOf();
|
|
175
|
-
h.nt(this.j, h.it.
|
|
175
|
+
h.nt(this.j, h.it.Xo, m),
|
|
176
176
|
-1 !== r && u.push(["X-Braze-Req-Tokens-Remaining", r.toString()]);
|
|
177
177
|
let p,
|
|
178
178
|
c,
|
|
@@ -183,16 +183,16 @@ export default class ea {
|
|
|
183
183
|
headers: u,
|
|
184
184
|
lt: (e) => {
|
|
185
185
|
if (!n.ut(o, e, u))
|
|
186
|
-
return void ("function" == typeof t.
|
|
186
|
+
return void ("function" == typeof t.Vo && t.Vo());
|
|
187
187
|
if ((n.ct(), null == e || null == e.templated_message)) return;
|
|
188
188
|
const s = e.templated_message;
|
|
189
|
-
if (s.type !==
|
|
190
|
-
const i =
|
|
189
|
+
if (s.type !== vt.Yo.Wo) return;
|
|
190
|
+
const i = yt(s.data);
|
|
191
191
|
if (null == i) return;
|
|
192
192
|
const r = this.Vn(i);
|
|
193
193
|
if (r)
|
|
194
|
-
return b.error(r), void ("function" == typeof t.
|
|
195
|
-
"function" == typeof t.
|
|
194
|
+
return b.error(r), void ("function" == typeof t.Vo && t.Vo());
|
|
195
|
+
"function" == typeof t.Zo && t.Zo(i);
|
|
196
196
|
},
|
|
197
197
|
error: (e) => {
|
|
198
198
|
(g = !0),
|
|
@@ -200,21 +200,21 @@ export default class ea {
|
|
|
200
200
|
(c = `getting user personalization for message ${t.triggerId}.`);
|
|
201
201
|
},
|
|
202
202
|
ft: (r, o) => {
|
|
203
|
-
if (new Date().valueOf() - t.
|
|
203
|
+
if (new Date().valueOf() - t.ta < t.ia) {
|
|
204
204
|
let r = 0;
|
|
205
205
|
if (g) {
|
|
206
|
-
const e = Math.min(t.
|
|
207
|
-
s = this.
|
|
206
|
+
const e = Math.min(t.ia, this.Dn),
|
|
207
|
+
s = this.Tn;
|
|
208
208
|
null == i && (i = s), (r = Math.min(e, a(s, 3 * i)));
|
|
209
209
|
}
|
|
210
210
|
n.yt(
|
|
211
211
|
o,
|
|
212
212
|
() => {
|
|
213
|
-
this.
|
|
213
|
+
this.Po(t, e, s, r);
|
|
214
214
|
},
|
|
215
|
-
h.it.
|
|
216
|
-
(e) => this.
|
|
217
|
-
() => this.
|
|
215
|
+
h.it.Xo,
|
|
216
|
+
(e) => this.Ro(e, t.triggerId),
|
|
217
|
+
() => this._o(),
|
|
218
218
|
r,
|
|
219
219
|
);
|
|
220
220
|
}
|
|
@@ -222,17 +222,17 @@ export default class ea {
|
|
|
222
222
|
},
|
|
223
223
|
});
|
|
224
224
|
},
|
|
225
|
-
h.it.
|
|
225
|
+
h.it.Xo,
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
Xn(t) {
|
|
229
229
|
if (null == t || "" === t) return !1;
|
|
230
230
|
const e = new Date().valueOf(),
|
|
231
|
-
s = this.
|
|
232
|
-
return (null != s && e - s <
|
|
231
|
+
s = this.qn[t];
|
|
232
|
+
return (null != s && e - s < kt.aE) || ((this.qn[t] = e), !1);
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
this.
|
|
234
|
+
oa() {
|
|
235
|
+
this.qn = {};
|
|
236
236
|
}
|
|
237
237
|
Kn(t) {
|
|
238
238
|
if (null == t.triggerId)
|
|
@@ -245,40 +245,40 @@ export default class ea {
|
|
|
245
245
|
const e = {};
|
|
246
246
|
return null != t.triggerId && (e.trigger_ids = [t.triggerId]), e;
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
An(t) {
|
|
249
249
|
return (
|
|
250
250
|
!!this.j &&
|
|
251
251
|
!(
|
|
252
252
|
!(t && t instanceof InAppMessage && t.constructor !== InAppMessage) ||
|
|
253
253
|
t instanceof ControlMessage
|
|
254
254
|
) &&
|
|
255
|
-
this.j.Pt(s.It.
|
|
255
|
+
this.j.Pt(s.It.la, t.qt())
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
258
|
sa() {
|
|
259
259
|
if (!this.j) return null;
|
|
260
|
-
const t = this.j.St(s.It.
|
|
260
|
+
const t = this.j.St(s.It.la);
|
|
261
261
|
if (!t) return null;
|
|
262
262
|
let e;
|
|
263
263
|
switch (t.type) {
|
|
264
|
-
case
|
|
265
|
-
e = FullScreenMessage.
|
|
264
|
+
case gt.oE:
|
|
265
|
+
e = FullScreenMessage.ua(t);
|
|
266
266
|
break;
|
|
267
|
-
case
|
|
268
|
-
case
|
|
269
|
-
case
|
|
270
|
-
e = HtmlMessage.
|
|
267
|
+
case gt.ME:
|
|
268
|
+
case gt.CE:
|
|
269
|
+
case gt.DE:
|
|
270
|
+
e = HtmlMessage.ua(t);
|
|
271
271
|
break;
|
|
272
|
-
case
|
|
273
|
-
case
|
|
274
|
-
e = ModalMessage.
|
|
272
|
+
case gt.tE:
|
|
273
|
+
case gt.eE:
|
|
274
|
+
e = ModalMessage.ua(t);
|
|
275
275
|
break;
|
|
276
|
-
case
|
|
277
|
-
e = SlideUpMessage.
|
|
276
|
+
case gt.RE:
|
|
277
|
+
e = SlideUpMessage.ua(t);
|
|
278
278
|
}
|
|
279
|
-
return e && this.
|
|
279
|
+
return e && this.ma(), e;
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
this.j && this.j.Vt(s.It.
|
|
281
|
+
ma() {
|
|
282
|
+
this.j && this.j.Vt(s.It.la);
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -2,7 +2,7 @@ import r from "../managers/braze-instance.js";
|
|
|
2
2
|
import { IamStrings as mr } from "./constants.js";
|
|
3
3
|
import InAppMessage from "./models/in-app-message.js";
|
|
4
4
|
import InAppMessageButton from "./models/in-app-message-button.js";
|
|
5
|
-
import
|
|
5
|
+
import se from "./in-app-message-manager-factory.js";
|
|
6
6
|
import { logger as b } from "../../shared-lib/index.js";
|
|
7
7
|
import ot from "../triggers/models/trigger-events.js";
|
|
8
8
|
import { TriggersProviderFactory as rt } from "../triggers/triggers-provider-factory.js";
|
|
@@ -12,7 +12,7 @@ export function logInAppMessageButtonClick(t, o) {
|
|
|
12
12
|
if (!(t instanceof InAppMessageButton))
|
|
13
13
|
return b.error("button must be an InAppMessageButton object"), !1;
|
|
14
14
|
if (!(o instanceof InAppMessage)) return b.error(mr.EE), !1;
|
|
15
|
-
const s =
|
|
15
|
+
const s = se.ra().Ln(t, o);
|
|
16
16
|
if (s.lt)
|
|
17
17
|
for (let r = 0; r < s.Ce.length; r++)
|
|
18
18
|
rt.o().Ee(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import r from "../managers/braze-instance.js";
|
|
2
2
|
import InAppMessage from "./models/in-app-message.js";
|
|
3
|
-
import
|
|
3
|
+
import se from "./in-app-message-manager-factory.js";
|
|
4
4
|
import { logInAppMessageImpression } from "./log-in-app-message-impression.js";
|
|
5
5
|
import { IamStrings as mr } from "./constants.js";
|
|
6
6
|
import { logger as b, EventTypes as p } from "../../shared-lib/index.js";
|
|
@@ -9,7 +9,7 @@ import { TriggersProviderFactory as rt } from "../triggers/triggers-provider-fac
|
|
|
9
9
|
export function logInAppMessageClick(s) {
|
|
10
10
|
if (!r.rr()) return !1;
|
|
11
11
|
if (!(s instanceof InAppMessage)) return b.error(mr.EE), !1;
|
|
12
|
-
const e =
|
|
12
|
+
const e = se.ra().Dt(s, p.Hn);
|
|
13
13
|
if (e) {
|
|
14
14
|
s.sm() || logInAppMessageImpression(s);
|
|
15
15
|
for (let r = 0; r < e.Ce.length; r++)
|