@braze/web-sdk 4.7.1 → 4.7.2
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 +1 -1
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/event-types.js +7 -7
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +2 -2
- package/src/managers/braze-instance.js +19 -17
- package/src/managers/device-manager.js +5 -5
- package/src/managers/network-manager.js +32 -32
- package/src/managers/session-manager.js +1 -1
- package/src/managers/storage-manager.js +73 -66
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +1 -1
- package/src/models/server-config.js +2 -2
- package/src/request-controller.js +70 -70
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +5 -5
- 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 +9 -9
- package/src/triggers/models/purchase-data.js +1 -1
- package/src/triggers/models/purchase-property-data.js +5 -5
- package/src/triggers/models/push-click-data.js +4 -4
- package/src/triggers/models/trigger-condition.js +2 -2
- package/src/triggers/models/trigger.js +20 -20
- package/src/triggers/triggers-provider.js +37 -37
- package/src/ui/js/attach-css.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/browser-detector.js +4 -4
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/user-agent-parser.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Type definitions for @braze/web-sdk v4.7.
|
|
2
|
+
* Type definitions for @braze/web-sdk v4.7.2
|
|
3
3
|
* Project: https://github.com/braze-inc/braze-web-sdk
|
|
4
4
|
* (c) Braze, Inc. 2023 - http://braze.com
|
|
5
5
|
* License available at https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE
|
package/package.json
CHANGED
|
@@ -4,5 +4,5 @@ import Be from "./guid.js";
|
|
|
4
4
|
import Ae from "./indexed-db-adapter.js";
|
|
5
5
|
import Ge from "./logger.js";
|
|
6
6
|
import Ue from "./supported-options.js";
|
|
7
|
-
const r = { yn: je, A: ve, Ar: De, it: Be, qt: Ae, xt: Ae.ep, D: Ge,
|
|
7
|
+
const r = { yn: je, A: ve, Ar: De, it: Be, qt: Ae, xt: Ae.ep, D: Ge, Fo: Ue };
|
|
8
8
|
export default r;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const ve = {
|
|
2
2
|
CustomEvent: "ce",
|
|
3
3
|
Pr: "p",
|
|
4
|
-
|
|
4
|
+
Ol: "pc",
|
|
5
5
|
cc: "ca",
|
|
6
|
-
|
|
6
|
+
Aa: "i",
|
|
7
7
|
qs: "ie",
|
|
8
8
|
T: "cci",
|
|
9
9
|
W: "ccic",
|
|
@@ -16,18 +16,18 @@ const ve = {
|
|
|
16
16
|
Ai: "sbc",
|
|
17
17
|
Ze: "sfe",
|
|
18
18
|
ro: "iec",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Nl: "lr",
|
|
20
|
+
Ml: "uae",
|
|
21
21
|
U: "ci",
|
|
22
22
|
F: "cc",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
xl: "lcaa",
|
|
24
|
+
Ul: "lcar",
|
|
25
25
|
Fn: "inc",
|
|
26
26
|
Un: "add",
|
|
27
27
|
En: "rem",
|
|
28
28
|
Sn: "set",
|
|
29
29
|
An: "ncam",
|
|
30
|
-
|
|
30
|
+
Jl: "sgu"
|
|
31
31
|
},
|
|
32
32
|
De = { qr: "feed_displayed", dc: "content_cards_displayed" };
|
|
33
33
|
export { ve as EventTypes, De as InternalEventTypes };
|
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const Ge = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function(n) {
|
|
26
26
|
if (Ge.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v4.7.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v4.7.2)";
|
|
28
28
|
null != Ge.nd ? Ge.nd(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function(n) {
|
|
32
32
|
if (Ge.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v4.7.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v4.7.2)";
|
|
34
34
|
null != Ge.nd ? Ge.nd(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -59,7 +59,7 @@ class Bt {
|
|
|
59
59
|
(this.Ro = []),
|
|
60
60
|
(this.Mo = []),
|
|
61
61
|
(this.Se = []),
|
|
62
|
-
(this.jo = "4.7.
|
|
62
|
+
(this.jo = "4.7.2");
|
|
63
63
|
}
|
|
64
64
|
yo(t) {
|
|
65
65
|
this.Co.ut(t);
|
|
@@ -87,10 +87,10 @@ class Bt {
|
|
|
87
87
|
if (null == n || "" === n || "string" != typeof n)
|
|
88
88
|
return r.D.error("Braze requires a valid baseUrl to be initialized."), !1;
|
|
89
89
|
!1 === /^https?:/.test(n) && (n = `https://${n}`);
|
|
90
|
-
let
|
|
90
|
+
let h = n;
|
|
91
91
|
if (
|
|
92
92
|
((n = document.createElement("a")),
|
|
93
|
-
(n.href =
|
|
93
|
+
(n.href = h),
|
|
94
94
|
"/" === n.pathname && (n = `${n}api/v3`),
|
|
95
95
|
(this.Uo = n.toString()),
|
|
96
96
|
ot.zo && !this.nn(T.Yn))
|
|
@@ -100,24 +100,26 @@ class Bt {
|
|
|
100
100
|
(this.vo = !0),
|
|
101
101
|
!1
|
|
102
102
|
);
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
103
|
+
const a = this.nn(T.Zn) || !1;
|
|
104
|
+
if (
|
|
105
|
+
((this.h = Dt.Bo(t, a)), a && this.h.Wo(t), new G.ne(null, !0).lr(o.ae))
|
|
106
|
+
)
|
|
105
107
|
return (
|
|
106
108
|
r.D.info("Ignoring all activity due to previous opt out"),
|
|
107
109
|
(this.vo = !0),
|
|
108
110
|
!1
|
|
109
111
|
);
|
|
110
112
|
for (const t of or(this.Po))
|
|
111
|
-
-1 === Lt(r.
|
|
113
|
+
-1 === Lt(r.Fo).indexOf(t) &&
|
|
112
114
|
r.D.warn(`Ignoring unknown initialization option '${t}'.`);
|
|
113
115
|
const l = ["mparticle", "wordpress", "tealium"];
|
|
114
116
|
if (null != this.nn(T.To)) {
|
|
115
117
|
const t = this.nn(T.To);
|
|
116
118
|
-1 !== l.indexOf(t)
|
|
117
|
-
? (this.
|
|
119
|
+
? (this.Vo = t)
|
|
118
120
|
: r.D.error("Invalid sdk flavor passed: " + t);
|
|
119
121
|
}
|
|
120
|
-
let f = this.nn(r.
|
|
122
|
+
let f = this.nn(r.Fo.ho);
|
|
121
123
|
if (null != f)
|
|
122
124
|
if (p(f)) {
|
|
123
125
|
const t = [];
|
|
@@ -140,19 +142,19 @@ class Bt {
|
|
|
140
142
|
(this.j = new jt(this.h, this.v, this.gt, this.nn(T.Io)));
|
|
141
143
|
const m = new u();
|
|
142
144
|
return (
|
|
143
|
-
(this.
|
|
145
|
+
(this.Go = new kt(this.h, this.nn(T.Eo), m)),
|
|
144
146
|
this.jt(m),
|
|
145
147
|
(this.vt = new Pt(
|
|
146
148
|
this.Ur,
|
|
147
149
|
this.h,
|
|
148
|
-
this.
|
|
150
|
+
this.Go,
|
|
149
151
|
this.v,
|
|
150
152
|
this.j,
|
|
151
153
|
this.gt,
|
|
152
154
|
this._r,
|
|
153
155
|
this.Uo,
|
|
154
156
|
this.jo,
|
|
155
|
-
this.
|
|
157
|
+
this.Vo,
|
|
156
158
|
this.nn(T.Ao)
|
|
157
159
|
)),
|
|
158
160
|
(this.Ci = new Rt(
|
|
@@ -166,7 +168,7 @@ class Bt {
|
|
|
166
168
|
t => {
|
|
167
169
|
if (this.Do()) for (const i of this.re()) i.Rs(t);
|
|
168
170
|
},
|
|
169
|
-
this.
|
|
171
|
+
this.Go,
|
|
170
172
|
this.vt
|
|
171
173
|
)),
|
|
172
174
|
this.Ci.initialize(),
|
|
@@ -214,21 +216,21 @@ class Bt {
|
|
|
214
216
|
(this.Se = []),
|
|
215
217
|
this.Ci.destroy(),
|
|
216
218
|
(this.Ci = null),
|
|
217
|
-
(this.
|
|
219
|
+
(this.Go = null),
|
|
218
220
|
(this.Ur = null),
|
|
219
221
|
(this.vt = null),
|
|
220
222
|
(this.gt = null),
|
|
221
223
|
(this.j = null),
|
|
222
224
|
(this.v = null),
|
|
223
225
|
(this.Po = {}),
|
|
224
|
-
(this.
|
|
226
|
+
(this.Vo = void 0),
|
|
225
227
|
(this.Oo = !1),
|
|
226
228
|
(this.vo = !1),
|
|
227
229
|
t && (this.h = null);
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
rr() {
|
|
231
|
-
if (this.
|
|
233
|
+
if (this.Ko()) return !1;
|
|
232
234
|
if (!this.Do())
|
|
233
235
|
throw new Error("Braze must be initialized before calling methods.");
|
|
234
236
|
return !0;
|
|
@@ -237,7 +239,7 @@ class Bt {
|
|
|
237
239
|
return this._r;
|
|
238
240
|
}
|
|
239
241
|
ii() {
|
|
240
|
-
return this.
|
|
242
|
+
return this.Go;
|
|
241
243
|
}
|
|
242
244
|
Ks() {
|
|
243
245
|
return this.Uo;
|
|
@@ -300,7 +302,7 @@ class Bt {
|
|
|
300
302
|
Do() {
|
|
301
303
|
return this.Oo;
|
|
302
304
|
}
|
|
303
|
-
|
|
305
|
+
Ko() {
|
|
304
306
|
return this.vo;
|
|
305
307
|
}
|
|
306
308
|
Ds() {
|
|
@@ -41,9 +41,9 @@ export default class Ot {
|
|
|
41
41
|
return t;
|
|
42
42
|
}
|
|
43
43
|
qo() {
|
|
44
|
-
if (ot.
|
|
45
|
-
const e = this.h.I(o.q.
|
|
46
|
-
return e && e.os_version ? e.os_version : ot.
|
|
44
|
+
if (ot.Qo()) return ot.Qo();
|
|
45
|
+
const e = this.h.I(o.q.Xo);
|
|
46
|
+
return e && e.os_version ? e.os_version : ot.Yo();
|
|
47
47
|
}
|
|
48
48
|
Ho(e) {
|
|
49
49
|
if ("undefined" != typeof Intl && "function" == typeof Intl.DateTimeFormat)
|
|
@@ -61,9 +61,9 @@ export default class Ot {
|
|
|
61
61
|
}
|
|
62
62
|
if (!e) return e;
|
|
63
63
|
const t = e.getTimezoneOffset();
|
|
64
|
-
return this.
|
|
64
|
+
return this.Zo(t);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
Zo(e) {
|
|
67
67
|
const t = parseInt(e / 60),
|
|
68
68
|
r = parseInt(e % 60);
|
|
69
69
|
let s = "GMT";
|
|
@@ -12,32 +12,32 @@ export default class Pt {
|
|
|
12
12
|
constructor(t, e, s, i, r, o, n, a, u, h, c) {
|
|
13
13
|
(this.Ur = t),
|
|
14
14
|
(this.h = e),
|
|
15
|
-
(this.
|
|
15
|
+
(this.Go = s),
|
|
16
16
|
(this.v = i),
|
|
17
17
|
(this.j = r),
|
|
18
18
|
(this.gt = o),
|
|
19
19
|
(this._r = n),
|
|
20
20
|
(this.Uo = a),
|
|
21
21
|
(this.jo = u),
|
|
22
|
-
(this.
|
|
22
|
+
(this.Vo = h),
|
|
23
23
|
(this.$o = c),
|
|
24
|
-
(this.
|
|
24
|
+
(this.sa = ["npm"]);
|
|
25
25
|
}
|
|
26
26
|
Ps(t, e) {
|
|
27
27
|
const s = this.Ur.te(),
|
|
28
28
|
i = s.Pi(),
|
|
29
|
-
r = this.h.I(o.q.
|
|
29
|
+
r = this.h.I(o.q.Xo);
|
|
30
30
|
ii(r, i) || (t.device = i),
|
|
31
31
|
(t.api_key = this._r),
|
|
32
32
|
(t.time = l(new Date().valueOf(), !0));
|
|
33
|
-
const n = this.h.I(o.q.
|
|
34
|
-
a = this.h.I(o.q.
|
|
33
|
+
const n = this.h.I(o.q.oa) || [],
|
|
34
|
+
a = this.h.I(o.q.ua) || "";
|
|
35
35
|
if (
|
|
36
|
-
(this.
|
|
37
|
-
(!ii(n, this.
|
|
38
|
-
(t.sdk_metadata = this.
|
|
36
|
+
(this.sa.length > 0 &&
|
|
37
|
+
(!ii(n, this.sa) || a !== this.j.ha()) &&
|
|
38
|
+
(t.sdk_metadata = this.sa),
|
|
39
39
|
(t.sdk_version = this.jo),
|
|
40
|
-
this.
|
|
40
|
+
this.Vo && (t.sdk_flavor = this.Vo),
|
|
41
41
|
(t.app_version = this.$o),
|
|
42
42
|
(t.device_id = s.id),
|
|
43
43
|
e)
|
|
@@ -53,7 +53,7 @@ export default class Pt {
|
|
|
53
53
|
if (!o && !n) return !0;
|
|
54
54
|
if (o) {
|
|
55
55
|
let e;
|
|
56
|
-
this.
|
|
56
|
+
this.Go.Vn();
|
|
57
57
|
const s = { errorCode: o.error_code };
|
|
58
58
|
for (const t of i)
|
|
59
59
|
p(t) && "X-Braze-Auth-Signature" === t[0] && (s.signature = t[1]);
|
|
@@ -65,12 +65,12 @@ export default class Pt {
|
|
|
65
65
|
n
|
|
66
66
|
? ((s.reason = n), (e = `due to ${n}`))
|
|
67
67
|
: (e = `with error code ${o.error_code}.`),
|
|
68
|
-
this.
|
|
68
|
+
this.Go.Jn() ||
|
|
69
69
|
(e +=
|
|
70
70
|
' Please use the "enableSdkAuthentication" initialization option to enable authentication.'),
|
|
71
71
|
r.D.error(`SDK Authentication failed ${e}`),
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
72
|
+
this.ca(t.events, t.attributes),
|
|
73
|
+
this.Go.Qn(s),
|
|
74
74
|
!1
|
|
75
75
|
);
|
|
76
76
|
}
|
|
@@ -78,38 +78,38 @@ export default class Pt {
|
|
|
78
78
|
let i,
|
|
79
79
|
o = n;
|
|
80
80
|
switch (o) {
|
|
81
|
-
case qt.
|
|
81
|
+
case qt.la:
|
|
82
82
|
return (
|
|
83
83
|
(i = "Received successful response with empty body."),
|
|
84
84
|
s.G(r.A.qs, { e: i }),
|
|
85
85
|
r.D.info(i),
|
|
86
86
|
!1
|
|
87
87
|
);
|
|
88
|
-
case qt.
|
|
88
|
+
case qt.fa:
|
|
89
89
|
return (
|
|
90
90
|
(i = "Received successful response with invalid JSON"),
|
|
91
91
|
s.G(r.A.qs, { e: i + ": " + e.response }),
|
|
92
92
|
r.D.info(i),
|
|
93
93
|
!1
|
|
94
94
|
);
|
|
95
|
-
case qt.
|
|
95
|
+
case qt.ma:
|
|
96
96
|
o = `The API key "${t.api_key}" is invalid for the baseUrl ${this.Uo}`;
|
|
97
97
|
break;
|
|
98
|
-
case qt.
|
|
98
|
+
case qt.pa:
|
|
99
99
|
o =
|
|
100
100
|
"Sorry, we are not currently accepting your requests. If you think this is in error, please contact us.";
|
|
101
101
|
break;
|
|
102
|
-
case qt.
|
|
102
|
+
case qt.Ra:
|
|
103
103
|
o = "No device identifier. Please contact support@braze.com";
|
|
104
104
|
}
|
|
105
105
|
r.D.error("Backend error: " + o);
|
|
106
106
|
}
|
|
107
107
|
return !1;
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
ba(t, e, s, i) {
|
|
110
110
|
return !!((t && 0 !== t.length) || (e && 0 !== e.length) || s || i);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
ga(t, e, s, i) {
|
|
113
113
|
const r = [],
|
|
114
114
|
o = t => t || "",
|
|
115
115
|
n = o(this.v.getUserId());
|
|
@@ -121,7 +121,7 @@ export default class Pt {
|
|
|
121
121
|
if (s.length > 0) {
|
|
122
122
|
const t = [];
|
|
123
123
|
for (const e of s) {
|
|
124
|
-
if (((a = e.Pi()), this.
|
|
124
|
+
if (((a = e.Pi()), this.Go.Jn())) {
|
|
125
125
|
if (n && !a.user_id) {
|
|
126
126
|
c || ((c = {}), (c.events = [])), c.events.push(a);
|
|
127
127
|
continue;
|
|
@@ -138,21 +138,21 @@ export default class Pt {
|
|
|
138
138
|
if (i.length > 0) {
|
|
139
139
|
const t = [];
|
|
140
140
|
for (const e of i)
|
|
141
|
-
this.
|
|
141
|
+
this.Go.Jn() && o(e.user_id) !== n
|
|
142
142
|
? (h || (h = []), h.push(e))
|
|
143
143
|
: t.push(e);
|
|
144
144
|
t.length > 0 && (l.attributes = t);
|
|
145
145
|
}
|
|
146
|
-
if ((this.
|
|
146
|
+
if ((this.ca(u, h), (l = this.Ps(l, !0)), c)) {
|
|
147
147
|
c = this.Ps(c, !1);
|
|
148
148
|
const t = { requestData: c, headers: this.Bs(c) };
|
|
149
149
|
r.push(t);
|
|
150
150
|
}
|
|
151
|
-
if (l && !this.
|
|
151
|
+
if (l && !this.ba(l.events, l.attributes, t, e)) return c ? r : null;
|
|
152
152
|
const f = { requestData: l, headers: this.Bs(l) };
|
|
153
153
|
return r.push(f), r;
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
ca(t, e) {
|
|
156
156
|
if (t) {
|
|
157
157
|
const e = [];
|
|
158
158
|
for (const s of t) {
|
|
@@ -161,14 +161,14 @@ export default class Pt {
|
|
|
161
161
|
}
|
|
162
162
|
this.h.bo(e);
|
|
163
163
|
}
|
|
164
|
-
if (e) for (const t of e) this.h.
|
|
164
|
+
if (e) for (const t of e) this.h.qa(t);
|
|
165
165
|
}
|
|
166
166
|
Vs(t, e) {
|
|
167
167
|
let s = "HTTP error ";
|
|
168
168
|
null != t && (s += t + " "), (s += e), r.D.error(s);
|
|
169
169
|
}
|
|
170
170
|
Fr(t) {
|
|
171
|
-
return s.G(r.A.
|
|
171
|
+
return s.G(r.A.Aa, { n: t });
|
|
172
172
|
}
|
|
173
173
|
Oi(t, e, s) {
|
|
174
174
|
const i = {};
|
|
@@ -201,9 +201,9 @@ export default class Pt {
|
|
|
201
201
|
if (
|
|
202
202
|
(s && (r.push(["X-Braze-FeatureFlagsRequest", "true"]), (n = !0)),
|
|
203
203
|
n && r.push(["X-Braze-DataRequest", "true"]),
|
|
204
|
-
this.
|
|
204
|
+
this.Go.Jn())
|
|
205
205
|
) {
|
|
206
|
-
const t = this.
|
|
206
|
+
const t = this.Go.Kn();
|
|
207
207
|
null != t && r.push(["X-Braze-Auth-Signature", t]);
|
|
208
208
|
}
|
|
209
209
|
return r;
|
|
@@ -217,12 +217,12 @@ export default class Pt {
|
|
|
217
217
|
: e();
|
|
218
218
|
}
|
|
219
219
|
Qs() {
|
|
220
|
-
this.
|
|
220
|
+
this.Go.Qs();
|
|
221
221
|
}
|
|
222
222
|
Ks() {
|
|
223
223
|
return this.Uo;
|
|
224
224
|
}
|
|
225
225
|
addSdkMetadata(t) {
|
|
226
|
-
for (const e of t) -1 === this.
|
|
226
|
+
for (const e of t) -1 === this.sa.indexOf(e) && this.sa.push(e);
|
|
227
227
|
}
|
|
228
228
|
}
|