@braze/web-sdk 5.3.2 → 5.5.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 +12 -12
- package/shared-lib/indexed-db-adapter.js +14 -14
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +10 -9
- package/src/Card/card-manager.js +46 -42
- package/src/Card/display/card-display.js +59 -58
- package/src/Card/models/card.js +61 -55
- package/src/Card/models/classic-card.js +1 -1
- package/src/Card/models/control-card.js +1 -1
- package/src/Card/models/image-only.js +1 -1
- package/src/Card/util/card-factory.js +20 -20
- package/src/ContentCards/content-cards-provider.js +140 -140
- 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 +4 -4
- package/src/ContentCards/ui/show-content-cards.js +3 -3
- package/src/Core/disable-sdk.js +2 -2
- package/src/Core/enable-sdk.js +2 -2
- package/src/Core/index.js +1 -0
- package/src/Core/is-initialized.js +4 -0
- package/src/Core/log-custom-event.js +14 -14
- package/src/Core/log-purchase.js +8 -8
- package/src/Core/open-session.js +4 -4
- package/src/Core/wipe-data.js +2 -2
- package/src/FeatureFlags/feature-flag-factory.js +5 -5
- package/src/FeatureFlags/feature-flag.js +1 -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 +12 -12
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +2 -2
- package/src/Feed/feed-provider.js +29 -29
- package/src/Feed/get-cached-feed.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/display/in-app-message-to-html.js +64 -62
- package/src/InAppMessage/in-app-message-manager.js +63 -63
- 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 +1 -1
- package/src/InAppMessage/models/full-screen-message.js +10 -10
- package/src/InAppMessage/models/html-message.js +13 -13
- package/src/InAppMessage/models/in-app-message-button.js +4 -4
- package/src/InAppMessage/models/in-app-message.js +59 -59
- package/src/InAppMessage/models/modal-message.js +9 -9
- package/src/InAppMessage/models/slide-up-message.js +11 -11
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/ui/show-in-app-message.js +42 -40
- package/src/Push/push-manager-factory.js +5 -4
- package/src/Push/push-manager.js +77 -89
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +8 -8
- package/src/User/user.js +29 -29
- package/src/common/base-provider.js +1 -1
- package/src/common/event-logger.js +11 -11
- package/src/common/feed-display.js +18 -17
- package/src/l10n/l10n-manager-factory.js +7 -7
- package/src/l10n/l10n-manager.js +15 -5
- package/src/managers/auth-manager.js +9 -9
- package/src/managers/braze-instance.js +89 -87
- package/src/managers/device-manager.js +17 -17
- package/src/managers/network-manager.js +130 -130
- package/src/managers/server-config-manager.js +24 -24
- package/src/managers/session-manager.js +12 -12
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +31 -31
- package/src/managers/subscription-manager.js +2 -2
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +4 -4
- package/src/models/device.js +2 -2
- package/src/models/request-result.js +1 -1
- package/src/models/server-config.js +5 -5
- package/src/request-controller.js +130 -130
- package/src/triggers/models/filter.js +9 -9
- 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 +27 -27
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +7 -7
- package/src/triggers/triggers-provider.js +29 -29
- 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 +13 -12
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +17 -17
- package/src/util/user-agent-parser.js +3 -3
- package/src/util/window-utils.js +1 -1
package/src/Card/models/card.js
CHANGED
|
@@ -6,13 +6,13 @@ import { FEED_ANIMATION_DURATION as E } from "../../common/constants.js";
|
|
|
6
6
|
import T from "../../managers/subscription-manager.js";
|
|
7
7
|
import r from "../../../shared-lib/logger.js";
|
|
8
8
|
export default class Card {
|
|
9
|
-
constructor(t, i, s, h,
|
|
9
|
+
constructor(t, i, s, h, n, l, e, r, u, E, o, T, I, a, c, N) {
|
|
10
10
|
(this.id = t),
|
|
11
11
|
(this.viewed = i),
|
|
12
12
|
(this.title = s),
|
|
13
13
|
(this.imageUrl = h),
|
|
14
|
-
(this.description =
|
|
15
|
-
(this.created =
|
|
14
|
+
(this.description = n),
|
|
15
|
+
(this.created = l),
|
|
16
16
|
(this.updated = e),
|
|
17
17
|
(this.categories = r),
|
|
18
18
|
(this.expiresAt = u),
|
|
@@ -21,14 +21,14 @@ export default class Card {
|
|
|
21
21
|
(this.aspectRatio = T),
|
|
22
22
|
(this.extras = I),
|
|
23
23
|
(this.pinned = a),
|
|
24
|
-
(this.dismissible =
|
|
25
|
-
(this.clicked =
|
|
24
|
+
(this.dismissible = c),
|
|
25
|
+
(this.clicked = N),
|
|
26
26
|
(this.id = t),
|
|
27
27
|
(this.viewed = i || !1),
|
|
28
28
|
(this.title = s || ""),
|
|
29
29
|
(this.imageUrl = h),
|
|
30
|
-
(this.description =
|
|
31
|
-
(this.created =
|
|
30
|
+
(this.description = n || ""),
|
|
31
|
+
(this.created = l || null),
|
|
32
32
|
(this.updated = e || null),
|
|
33
33
|
(this.categories = r || []),
|
|
34
34
|
(this.expiresAt = u || null),
|
|
@@ -40,25 +40,26 @@ export default class Card {
|
|
|
40
40
|
(this.aspectRatio = isNaN(T) ? null : T)),
|
|
41
41
|
(this.extras = I || {}),
|
|
42
42
|
(this.pinned = a || !1),
|
|
43
|
-
(this.dismissible =
|
|
43
|
+
(this.dismissible = c || !1),
|
|
44
44
|
(this.dismissed = !1),
|
|
45
|
-
(this.clicked =
|
|
45
|
+
(this.clicked = N || !1),
|
|
46
46
|
(this.isControl = !1),
|
|
47
47
|
(this.test = !1),
|
|
48
48
|
(this.Et = null),
|
|
49
|
-
(this.Tt = null)
|
|
49
|
+
(this.Tt = null),
|
|
50
|
+
(this.It = null);
|
|
50
51
|
}
|
|
51
52
|
subscribeToClickedEvent(t) {
|
|
52
|
-
return this.
|
|
53
|
+
return this.St().Nt(t);
|
|
53
54
|
}
|
|
54
55
|
subscribeToDismissedEvent(t) {
|
|
55
|
-
return this.
|
|
56
|
+
return this.At().Nt(t);
|
|
56
57
|
}
|
|
57
58
|
removeSubscription(t) {
|
|
58
|
-
this.
|
|
59
|
+
this.St().removeSubscription(t), this.At().removeSubscription(t);
|
|
59
60
|
}
|
|
60
61
|
removeAllSubscriptions() {
|
|
61
|
-
this.
|
|
62
|
+
this.St().removeAllSubscriptions(), this.At().removeAllSubscriptions();
|
|
62
63
|
}
|
|
63
64
|
dismissCard() {
|
|
64
65
|
if (!this.dismissible || this.dismissed) return;
|
|
@@ -75,65 +76,69 @@ export default class Card {
|
|
|
75
76
|
(t.style.margin = "0"),
|
|
76
77
|
setTimeout(function () {
|
|
77
78
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
78
|
-
}, Card.
|
|
79
|
+
}, Card.Dt));
|
|
79
80
|
}, E));
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
St() {
|
|
82
83
|
return null == this.Et && (this.Et = new T()), this.Et;
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
At() {
|
|
85
86
|
return null == this.Tt && (this.Tt = new T()), this.Tt;
|
|
86
87
|
}
|
|
87
88
|
K() {
|
|
88
|
-
|
|
89
|
+
const t = new Date().valueOf();
|
|
90
|
+
return (
|
|
91
|
+
!(null != this.It && t - this.It < Card.Ct) &&
|
|
92
|
+
((this.It = t), (this.viewed = !0), !0)
|
|
93
|
+
);
|
|
89
94
|
}
|
|
90
95
|
p() {
|
|
91
|
-
(this.viewed = !0), (this.clicked = !0), this.
|
|
96
|
+
(this.viewed = !0), (this.clicked = !0), this.St().Rt();
|
|
92
97
|
}
|
|
93
98
|
N() {
|
|
94
99
|
return (
|
|
95
100
|
!(!this.dismissible || this.dismissed) &&
|
|
96
|
-
((this.dismissed = !0), this.
|
|
101
|
+
((this.dismissed = !0), this.At().Rt(), !0)
|
|
97
102
|
);
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
if (null == t || t[Card.
|
|
101
|
-
if (t[Card.
|
|
104
|
+
Lt(t) {
|
|
105
|
+
if (null == t || t[Card._t.ht] !== this.id) return !0;
|
|
106
|
+
if (t[Card._t.Ot]) return !1;
|
|
102
107
|
if (
|
|
103
|
-
null != t[Card.
|
|
108
|
+
null != t[Card._t.nt] &&
|
|
104
109
|
null != this.updated &&
|
|
105
|
-
parseInt(t[Card.
|
|
110
|
+
parseInt(t[Card._t.nt]) < h(this.updated.valueOf())
|
|
106
111
|
)
|
|
107
112
|
return !0;
|
|
108
113
|
if (
|
|
109
|
-
(t[Card.
|
|
110
|
-
t[Card.
|
|
111
|
-
null != t[Card.
|
|
112
|
-
null != t[Card.
|
|
113
|
-
null != t[Card.
|
|
114
|
-
null != t[Card.
|
|
114
|
+
(t[Card._t.et] && !this.viewed && (this.viewed = !0),
|
|
115
|
+
t[Card._t.zt] && !this.clicked && (this.clicked = t[Card._t.zt]),
|
|
116
|
+
null != t[Card._t.rt] && (this.title = t[Card._t.rt]),
|
|
117
|
+
null != t[Card._t.ot] && (this.imageUrl = t[Card._t.ot]),
|
|
118
|
+
null != t[Card._t.ct] && (this.description = t[Card._t.ct]),
|
|
119
|
+
null != t[Card._t.nt])
|
|
115
120
|
) {
|
|
116
|
-
const i = l(t[Card.
|
|
121
|
+
const i = l(t[Card._t.nt]);
|
|
117
122
|
null != i && (this.updated = i);
|
|
118
123
|
}
|
|
119
|
-
if (null != t[Card.
|
|
124
|
+
if (null != t[Card._t.lt]) {
|
|
120
125
|
let i;
|
|
121
|
-
(i = t[Card.
|
|
126
|
+
(i = t[Card._t.lt] === Card.Mt ? null : l(t[Card._t.lt])),
|
|
122
127
|
(this.expiresAt = i);
|
|
123
128
|
}
|
|
124
129
|
if (
|
|
125
|
-
(null != t[Card.
|
|
126
|
-
null != t[Card.
|
|
127
|
-
null != t[Card.
|
|
130
|
+
(null != t[Card._t.URL] && (this.url = t[Card._t.URL]),
|
|
131
|
+
null != t[Card._t.ft] && (this.linkText = t[Card._t.ft]),
|
|
132
|
+
null != t[Card._t.xt])
|
|
128
133
|
) {
|
|
129
|
-
const i = parseFloat(t[Card.
|
|
134
|
+
const i = parseFloat(t[Card._t.xt].toString());
|
|
130
135
|
this.aspectRatio = isNaN(i) ? null : i;
|
|
131
136
|
}
|
|
132
137
|
return (
|
|
133
|
-
null != t[Card.
|
|
134
|
-
null != t[Card.
|
|
135
|
-
null != t[Card.
|
|
136
|
-
null != t[Card.
|
|
138
|
+
null != t[Card._t.bt] && (this.extras = t[Card._t.bt]),
|
|
139
|
+
null != t[Card._t.gt] && (this.pinned = t[Card._t.gt]),
|
|
140
|
+
null != t[Card._t.jt] && (this.dismissible = t[Card._t.jt]),
|
|
141
|
+
null != t[Card._t.kt] && (this.test = t[Card._t.kt]),
|
|
137
142
|
!0
|
|
138
143
|
);
|
|
139
144
|
}
|
|
@@ -141,12 +146,12 @@ export default class Card {
|
|
|
141
146
|
r.error("Must be implemented in a subclass");
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
|
-
(Card.
|
|
145
|
-
(Card.
|
|
149
|
+
(Card.Mt = -1),
|
|
150
|
+
(Card._t = {
|
|
146
151
|
ht: "id",
|
|
147
152
|
et: "v",
|
|
148
153
|
jt: "db",
|
|
149
|
-
|
|
154
|
+
Ot: "r",
|
|
150
155
|
nt: "ca",
|
|
151
156
|
gt: "p",
|
|
152
157
|
lt: "ea",
|
|
@@ -163,10 +168,10 @@ export default class Card {
|
|
|
163
168
|
}),
|
|
164
169
|
(Card.it = {
|
|
165
170
|
st: "captioned_image",
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
Pt: "text_announcement",
|
|
172
|
+
Ut: "short_news",
|
|
173
|
+
Gt: "banner_image",
|
|
174
|
+
Xt: "control",
|
|
170
175
|
}),
|
|
171
176
|
(Card.tt = {
|
|
172
177
|
ht: "id",
|
|
@@ -188,10 +193,11 @@ export default class Card {
|
|
|
188
193
|
zt: "cl",
|
|
189
194
|
kt: "s",
|
|
190
195
|
}),
|
|
191
|
-
(Card.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
(Card.vt = {
|
|
197
|
+
Vt: "ADVERTISING",
|
|
198
|
+
Wt: "ANNOUNCEMENTS",
|
|
199
|
+
wt: "NEWS",
|
|
200
|
+
Ft: "SOCIAL",
|
|
196
201
|
}),
|
|
197
|
-
(Card.
|
|
202
|
+
(Card.Dt = 400),
|
|
203
|
+
(Card.Ct = 1e4);
|
|
@@ -12,31 +12,31 @@ import {
|
|
|
12
12
|
import { logger as r } from "../../../shared-lib/index.js";
|
|
13
13
|
export function newCard(n, e, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x, F) {
|
|
14
14
|
let j;
|
|
15
|
-
if (e === Card.it.
|
|
15
|
+
if (e === Card.it.Pt || e === Card.it.Ut)
|
|
16
16
|
j = new ClassicCard(n, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x);
|
|
17
17
|
else if (e === Card.it.st)
|
|
18
18
|
j = new CaptionedImage(n, t, o, i, l, u, d, a, w, f, s, m, C, p, c, x);
|
|
19
|
-
else if (e === Card.it.
|
|
19
|
+
else if (e === Card.it.Gt)
|
|
20
20
|
j = new ImageOnly(n, t, i, u, d, a, w, f, s, m, C, p, c, x);
|
|
21
21
|
else {
|
|
22
|
-
if (e !== Card.it.
|
|
22
|
+
if (e !== Card.it.Xt)
|
|
23
23
|
return r.error("Ignoring card with unknown type " + e), null;
|
|
24
24
|
j = new ControlCard(n, t, d, w, C, p);
|
|
25
25
|
}
|
|
26
26
|
return F && (j.test = F), j;
|
|
27
27
|
}
|
|
28
28
|
export function newCardFromContentCardsJson(n) {
|
|
29
|
-
if (n[Card.
|
|
30
|
-
const e = n[Card.
|
|
31
|
-
r = n[Card.
|
|
32
|
-
t = n[Card.
|
|
33
|
-
o = n[Card.
|
|
34
|
-
i = n[Card.
|
|
35
|
-
u = n[Card.
|
|
36
|
-
d = l(n[Card.
|
|
29
|
+
if (n[Card._t.Ot]) return null;
|
|
30
|
+
const e = n[Card._t.ht],
|
|
31
|
+
r = n[Card._t.Z],
|
|
32
|
+
t = n[Card._t.et],
|
|
33
|
+
o = n[Card._t.rt],
|
|
34
|
+
i = n[Card._t.ot],
|
|
35
|
+
u = n[Card._t.ct],
|
|
36
|
+
d = l(n[Card._t.nt]),
|
|
37
37
|
a = d;
|
|
38
38
|
let w;
|
|
39
|
-
w = n[Card.
|
|
39
|
+
w = n[Card._t.lt] === Card.Mt ? null : l(n[Card._t.lt]);
|
|
40
40
|
return newCard(
|
|
41
41
|
e,
|
|
42
42
|
r,
|
|
@@ -48,14 +48,14 @@ export function newCardFromContentCardsJson(n) {
|
|
|
48
48
|
d,
|
|
49
49
|
null,
|
|
50
50
|
w,
|
|
51
|
-
n[Card.
|
|
52
|
-
n[Card.
|
|
53
|
-
n[Card.
|
|
54
|
-
n[Card.
|
|
55
|
-
n[Card.
|
|
56
|
-
n[Card.
|
|
57
|
-
n[Card.
|
|
58
|
-
n[Card.
|
|
51
|
+
n[Card._t.URL],
|
|
52
|
+
n[Card._t.ft],
|
|
53
|
+
n[Card._t.xt],
|
|
54
|
+
n[Card._t.bt],
|
|
55
|
+
n[Card._t.gt],
|
|
56
|
+
n[Card._t.jt],
|
|
57
|
+
n[Card._t.zt],
|
|
58
|
+
n[Card._t.kt] || !1,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
export function newCardFromFeedJson(n) {
|