@braze/web-sdk 4.8.0 → 4.8.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 +6 -3
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +11 -11
- package/shared-lib/indexed-db-adapter.js +67 -67
- package/shared-lib/logger.js +7 -7
- package/src/Card/card-manager.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +1 -1
- package/src/Core/disable-sdk.js +5 -4
- package/src/Core/enable-sdk.js +1 -1
- package/src/Core/is-disabled.js +1 -1
- package/src/FeatureFlags/feature-flags-provider.js +12 -12
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +40 -34
- 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 +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +13 -13
- package/src/InAppMessage/models/slide-up-message.js +2 -2
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +2 -2
- package/src/Push/push-manager.js +82 -81
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +5 -5
- package/src/common/feed-display.js +82 -72
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/managers/auth-manager.js +18 -15
- package/src/managers/braze-instance.js +125 -109
- package/src/managers/device-manager.js +40 -35
- package/src/managers/network-manager.js +90 -81
- package/src/managers/server-config-manager.js +36 -34
- package/src/managers/session-manager.js +44 -37
- package/src/managers/storage-manager-factory.js +23 -16
- package/src/managers/storage-manager.js +251 -239
- package/src/managers/subscription-manager.js +10 -7
- package/src/managers/types.js +1 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +10 -4
- package/src/models/device.js +10 -18
- package/src/models/identifier.js +10 -11
- package/src/models/push-token.js +14 -9
- package/src/models/request-result.js +2 -2
- package/src/models/server-config.js +32 -16
- package/src/models/types.js +1 -0
- package/src/request-controller.js +109 -109
- package/src/triggers/models/custom-event-data.js +6 -6
- package/src/triggers/models/custom-event-property-data.js +9 -9
- package/src/triggers/models/filter-set.js +9 -9
- package/src/triggers/models/filter.js +60 -60
- package/src/triggers/models/in-app-message-click-data.js +9 -9
- package/src/triggers/models/purchase-data.js +3 -3
- package/src/triggers/models/purchase-property-data.js +7 -7
- package/src/triggers/models/push-click-data.js +6 -6
- package/src/triggers/models/trigger-condition.js +46 -46
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +27 -27
- package/src/triggers/triggers-provider.js +126 -126
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/base-device-parser.js +2 -2
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +18 -18
- package/src/util/client-hints-parser.js +6 -6
- package/src/util/device-constants.js +6 -6
- package/src/util/dom-utils.js +5 -5
- package/src/util/error-utils.js +2 -0
- package/src/util/net.js +1 -1
- package/src/util/request-header-utils.js +9 -9
- package/src/util/user-agent-parser.js +21 -21
- package/src/util/window-utils.js +1 -1
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
impressOnBottom as be,
|
|
6
6
|
impressOnTop as ye,
|
|
7
7
|
markCardAsRead as Fe,
|
|
8
|
-
topHadImpression as
|
|
8
|
+
topHadImpression as _e
|
|
9
9
|
} from "../Card/display/card-display.js";
|
|
10
|
-
import { bottomIsInView as
|
|
10
|
+
import { bottomIsInView as Te, topIsInView as xe } from "../util/dom-utils.js";
|
|
11
11
|
import { Card, ControlCard } from "../Card/index.js";
|
|
12
|
-
import { cardToHtml as
|
|
12
|
+
import { cardToHtml as Ee } from "../Card/display/card-display.js";
|
|
13
13
|
import { isArray as p } from "../util/code-utils.js";
|
|
14
14
|
import { KeyCodes as lt } from "../util/key-codes.js";
|
|
15
|
-
import
|
|
15
|
+
import he from "../l10n/l10n-manager-factory.js";
|
|
16
16
|
import { removeSubscription } from "../Core/remove-subscription.js";
|
|
17
17
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
18
18
|
import { BRAZE_ACTION_URI_REGEX as X } from "../util/validation-utils.js";
|
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
export const LAST_REQUESTED_REFRESH_DATA_ATTRIBUTE =
|
|
26
26
|
"data-last-requested-refresh";
|
|
27
27
|
export const _SUBSCRIPTION_ID_DATA_ATTRIBUTE = "data-update-subscription-id";
|
|
28
|
+
export const _SCROLL_LISTENER_ID = "data-listener-id";
|
|
29
|
+
export const scrollListeners = {};
|
|
28
30
|
export function destroyFeedHtml(e) {
|
|
29
31
|
e &&
|
|
30
32
|
((e.className = e.className.replace("ab-show", "ab-hide")),
|
|
@@ -33,6 +35,10 @@ export function destroyFeedHtml(e) {
|
|
|
33
35
|
}, x.Th));
|
|
34
36
|
const t = e.getAttribute("data-update-subscription-id");
|
|
35
37
|
null != t && removeSubscription(t);
|
|
38
|
+
const o = e.getAttribute("data-listener-id");
|
|
39
|
+
null != o &&
|
|
40
|
+
(window.removeEventListener("scroll", scrollListeners[o]),
|
|
41
|
+
delete scrollListeners[o]);
|
|
36
42
|
}
|
|
37
43
|
export function _generateFeedBody(e, t) {
|
|
38
44
|
const o = document.createElement("div");
|
|
@@ -54,9 +60,9 @@ export function _generateFeedBody(e, t) {
|
|
|
54
60
|
e.logCardClick(t);
|
|
55
61
|
};
|
|
56
62
|
for (const n of e.cards) {
|
|
57
|
-
const
|
|
58
|
-
!
|
|
59
|
-
? (o.appendChild(
|
|
63
|
+
const i = n instanceof ControlCard;
|
|
64
|
+
!i || e.ur()
|
|
65
|
+
? (o.appendChild(Ee(n, logCardClick, t)), (s = s || !i))
|
|
60
66
|
: r.j.error(
|
|
61
67
|
"Received a control card for a legacy news feed. Control cards are only supported with content cards."
|
|
62
68
|
);
|
|
@@ -64,7 +70,7 @@ export function _generateFeedBody(e, t) {
|
|
|
64
70
|
if (!s) {
|
|
65
71
|
const e = document.createElement("div");
|
|
66
72
|
(e.className = "ab-no-cards-message"),
|
|
67
|
-
(e.innerHTML =
|
|
73
|
+
(e.innerHTML = he.m().get("NO_CARDS_MESSAGE")),
|
|
68
74
|
e.setAttribute("role", "article"),
|
|
69
75
|
o.appendChild(e);
|
|
70
76
|
}
|
|
@@ -74,25 +80,28 @@ export function _generateFeedBody(e, t) {
|
|
|
74
80
|
export function detectFeedImpressions(e, t) {
|
|
75
81
|
if (null != t) {
|
|
76
82
|
const o = [],
|
|
77
|
-
|
|
83
|
+
s = t.querySelectorAll(".ab-card");
|
|
78
84
|
e.fo || (e.fo = {});
|
|
79
|
-
for (let t = 0; t <
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
for (let t = 0; t < s.length; t++) {
|
|
86
|
+
const r = fe(s[t]),
|
|
87
|
+
n = xe(s[t]),
|
|
88
|
+
i = Te(s[t]);
|
|
89
|
+
if (e.fo[r]) {
|
|
90
|
+
n || i || Fe(s[t]);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
let a = _e(s[t]),
|
|
94
|
+
d = de(s[t]);
|
|
95
|
+
const l = a,
|
|
96
|
+
c = d;
|
|
88
97
|
if (
|
|
89
|
-
(!
|
|
90
|
-
!
|
|
91
|
-
|
|
98
|
+
(!a && n && ((a = !0), ye(s[t])),
|
|
99
|
+
!d && i && ((d = !0), be(s[t])),
|
|
100
|
+
a && d)
|
|
92
101
|
) {
|
|
93
|
-
if (
|
|
102
|
+
if (l && c) continue;
|
|
94
103
|
for (const t of e.cards)
|
|
95
|
-
if (t.id ===
|
|
104
|
+
if (t.id === r) {
|
|
96
105
|
(e.fo[t.id] = !0), o.push(t);
|
|
97
106
|
break;
|
|
98
107
|
}
|
|
@@ -105,17 +114,17 @@ export function refreshFeed(e, t) {
|
|
|
105
114
|
t.setAttribute("aria-busy", "true");
|
|
106
115
|
const o = t.querySelectorAll(".ab-refresh-button")[0];
|
|
107
116
|
null != o && (o.className += " fa-spin");
|
|
108
|
-
const
|
|
109
|
-
t.setAttribute("data-last-requested-refresh",
|
|
117
|
+
const s = new Date().valueOf().toString();
|
|
118
|
+
t.setAttribute("data-last-requested-refresh", s),
|
|
110
119
|
setTimeout(() => {
|
|
111
|
-
if (t.getAttribute("data-last-requested-refresh") ===
|
|
120
|
+
if (t.getAttribute("data-last-requested-refresh") === s) {
|
|
112
121
|
const e = t.querySelectorAll(".fa-spin");
|
|
113
122
|
for (let t = 0; t < e.length; t++)
|
|
114
123
|
e[t].className = e[t].className.replace(/fa-spin/g, "");
|
|
115
124
|
const o = t.querySelectorAll(".ab-initial-spinner")[0];
|
|
116
125
|
if (null != o) {
|
|
117
126
|
const e = document.createElement("span");
|
|
118
|
-
(e.innerHTML =
|
|
127
|
+
(e.innerHTML = he.m().get("FEED_TIMEOUT_MESSAGE")),
|
|
119
128
|
o.parentNode.appendChild(e),
|
|
120
129
|
o.parentNode.removeChild(o);
|
|
121
130
|
}
|
|
@@ -125,66 +134,67 @@ export function refreshFeed(e, t) {
|
|
|
125
134
|
}, x.uo),
|
|
126
135
|
e.sr();
|
|
127
136
|
}
|
|
128
|
-
export function feedToHtml(e, t) {
|
|
129
|
-
const
|
|
130
|
-
(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
destroyFeedHtml(
|
|
137
|
+
export function feedToHtml(e, t, o) {
|
|
138
|
+
const s = document.createElement("div");
|
|
139
|
+
(s.className = "ab-feed ab-hide ab-effect-slide"),
|
|
140
|
+
s.setAttribute("role", "dialog"),
|
|
141
|
+
s.setAttribute("aria-label", "Feed"),
|
|
142
|
+
s.setAttribute("tabindex", "-1");
|
|
143
|
+
const n = document.createElement("div");
|
|
144
|
+
(n.className = "ab-feed-buttons-wrapper"),
|
|
145
|
+
n.setAttribute("role", "group"),
|
|
146
|
+
s.appendChild(n);
|
|
147
|
+
const i = document.createElement("i");
|
|
148
|
+
(i.className = "fa fa-times ab-close-button"),
|
|
149
|
+
i.setAttribute("aria-label", "Close Feed"),
|
|
150
|
+
i.setAttribute("tabindex", "0"),
|
|
151
|
+
i.setAttribute("role", "button");
|
|
152
|
+
const a = e => {
|
|
153
|
+
destroyFeedHtml(s), e.stopPropagation();
|
|
145
154
|
};
|
|
146
|
-
|
|
147
|
-
(e.keyCode !== lt.yo && e.keyCode !== lt.Fo) ||
|
|
155
|
+
i.addEventListener("keydown", e => {
|
|
156
|
+
(e.keyCode !== lt.yo && e.keyCode !== lt.Fo) || a(e);
|
|
148
157
|
}),
|
|
149
|
-
(
|
|
150
|
-
const
|
|
151
|
-
(
|
|
152
|
-
null == e.lastUpdated && (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
refreshFeed(e,
|
|
158
|
+
(i.onclick = a);
|
|
159
|
+
const d = document.createElement("i");
|
|
160
|
+
(d.className = "fa fa-refresh ab-refresh-button"),
|
|
161
|
+
null == e.lastUpdated && (d.className += " fa-spin"),
|
|
162
|
+
d.setAttribute("aria-label", "Refresh Feed"),
|
|
163
|
+
d.setAttribute("tabindex", "0"),
|
|
164
|
+
d.setAttribute("role", "button");
|
|
165
|
+
const l = t => {
|
|
166
|
+
refreshFeed(e, s), t.stopPropagation();
|
|
158
167
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
d.addEventListener("keydown", e => {
|
|
169
|
+
(e.keyCode !== lt.yo && e.keyCode !== lt.Fo) || l(e);
|
|
170
|
+
}),
|
|
171
|
+
(d.onclick = l),
|
|
172
|
+
n.appendChild(d),
|
|
173
|
+
n.appendChild(i),
|
|
174
|
+
s.appendChild(_generateFeedBody(e, t));
|
|
175
|
+
const c = () => detectFeedImpressions(e, s);
|
|
176
|
+
if ((s.addEventListener("scroll", c), !o)) {
|
|
177
|
+
window.addEventListener("scroll", c);
|
|
178
|
+
const e = r.Z.Y();
|
|
179
|
+
(scrollListeners[e] = c), s.setAttribute("data-listener-id", e);
|
|
180
|
+
}
|
|
181
|
+
return s;
|
|
172
182
|
}
|
|
173
183
|
export function updateFeedCards(e, t, o, s, n) {
|
|
174
184
|
if (!p(t)) return;
|
|
175
|
-
const
|
|
185
|
+
const i = [];
|
|
176
186
|
for (const e of t)
|
|
177
187
|
if (e instanceof Card) {
|
|
178
188
|
if (e.url && X.test(e.url)) {
|
|
179
189
|
let t = Q(e.url);
|
|
180
190
|
if (ft(t)) {
|
|
181
|
-
r.j.error(dt(vt.
|
|
191
|
+
r.j.error(dt(vt.Ki, "Content Card"));
|
|
182
192
|
continue;
|
|
183
193
|
}
|
|
184
194
|
}
|
|
185
|
-
|
|
195
|
+
i.push(e);
|
|
186
196
|
}
|
|
187
|
-
if (((e.cards =
|
|
197
|
+
if (((e.cards = i), (e.lastUpdated = o), null != s))
|
|
188
198
|
if ((s.setAttribute("aria-busy", "false"), null == e.lastUpdated))
|
|
189
199
|
destroyFeedHtml(s);
|
|
190
200
|
else {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import e, { OPTIONS as L } from "../managers/braze-instance.js";
|
|
2
2
|
import V from "../util/browser-detector.js";
|
|
3
3
|
import nr from "./l10n-manager.js";
|
|
4
|
-
const
|
|
4
|
+
const he = {
|
|
5
5
|
t: !1,
|
|
6
6
|
i: null,
|
|
7
7
|
m: () => {
|
|
8
|
-
if ((
|
|
8
|
+
if ((he.o(), !he.i)) {
|
|
9
9
|
let r = V.language,
|
|
10
10
|
t = !1;
|
|
11
|
-
e.nn(L.Mn) && ((r = e.nn(L.Mn)), (t = !0)), (
|
|
11
|
+
e.nn(L.Mn) && ((r = e.nn(L.Mn)), (t = !0)), (he.i = new nr(r, t));
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return he.i;
|
|
14
14
|
},
|
|
15
15
|
o: () => {
|
|
16
|
-
|
|
16
|
+
he.t || (e.g(he), (he.t = !0));
|
|
17
17
|
},
|
|
18
18
|
destroy: () => {
|
|
19
|
-
(
|
|
19
|
+
(he.i = null), (he.t = !1);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
export default
|
|
22
|
+
export default he;
|
|
@@ -3,43 +3,46 @@ import E from "./subscription-manager.js";
|
|
|
3
3
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
4
4
|
export default class jt {
|
|
5
5
|
constructor(t, i, s) {
|
|
6
|
-
(this.
|
|
7
|
-
(this.
|
|
6
|
+
(this.u = t),
|
|
7
|
+
(this.Jn = i),
|
|
8
|
+
(this.Qn = s),
|
|
9
|
+
(this.u = t),
|
|
10
|
+
(this.Jn = i || !1),
|
|
8
11
|
(this.Qn = s),
|
|
9
12
|
(this.Vn = new E()),
|
|
10
13
|
(this.Xn = 0),
|
|
11
14
|
(this.Yn = 1);
|
|
12
15
|
}
|
|
13
16
|
Zn() {
|
|
14
|
-
return this.
|
|
17
|
+
return this.Jn;
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
return this.
|
|
19
|
+
gh() {
|
|
20
|
+
return this.u.v(i.k.Fh);
|
|
18
21
|
}
|
|
19
22
|
setSdkAuthenticationSignature(t) {
|
|
20
|
-
const s = this.
|
|
21
|
-
this.
|
|
23
|
+
const s = this.gh();
|
|
24
|
+
this.u.D(i.k.Fh, t);
|
|
22
25
|
const e = r.zt.Ft;
|
|
23
|
-
new r.xt(e, r.j).setItem(e.Jt.
|
|
26
|
+
new r.xt(e, r.j).setItem(e.Jt.kh, this.Yn, t), s !== t && this.si();
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
this.
|
|
28
|
+
fh() {
|
|
29
|
+
this.u.ri(i.k.Fh);
|
|
27
30
|
const t = r.zt.Ft;
|
|
28
|
-
new r.xt(t, r.j).br(t.Jt.
|
|
31
|
+
new r.xt(t, r.j).br(t.Jt.kh, this.Yn);
|
|
29
32
|
}
|
|
30
33
|
subscribeToSdkAuthenticationFailures(t) {
|
|
31
34
|
return this.Qn.lt(t);
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
wh(t) {
|
|
34
37
|
this.Qn.Et(t);
|
|
35
38
|
}
|
|
36
|
-
|
|
39
|
+
jh() {
|
|
37
40
|
this.Vn.removeAllSubscriptions();
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
Ch() {
|
|
40
43
|
this.Xn += 1;
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
xh() {
|
|
43
46
|
return this.Xn;
|
|
44
47
|
}
|
|
45
48
|
si() {
|