@braze/web-sdk 5.0.0 → 5.0.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 +3 -1
- package/package.json +1 -1
- package/shared-lib/logger.js +2 -2
- package/src/managers/braze-instance.js +4 -3
- package/src/managers/device-manager.js +13 -13
- package/src/managers/network-manager.js +1 -1
- package/src/managers/storage-manager-factory.js +4 -4
- package/src/managers/storage-manager.js +89 -82
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/server-config.js +2 -2
- package/src/request-controller.js +9 -9
- package/src/triggers/triggers-provider.js +16 -16
- 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/request-header-utils.js +4 -4
- 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 v5.0.
|
|
2
|
+
* Type definitions for @braze/web-sdk v5.0.1
|
|
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
|
|
@@ -2389,6 +2389,8 @@ export type InitializationOptions = {
|
|
|
2389
2389
|
/**
|
|
2390
2390
|
* A numerical app version value which can be used for user segmentation. This value must be sent with four fields, such as
|
|
2391
2391
|
* "1.2.3.4", otherwise it will be ignored.
|
|
2392
|
+
*
|
|
2393
|
+
* Note: `appVersion` must also be set, either with the same value or a unique name for this version.
|
|
2392
2394
|
*/
|
|
2393
2395
|
appVersionNumber?: string;
|
|
2394
2396
|
/**
|
package/package.json
CHANGED
package/shared-lib/logger.js
CHANGED
|
@@ -24,13 +24,13 @@ const Ue = {
|
|
|
24
24
|
},
|
|
25
25
|
warn: function (n) {
|
|
26
26
|
if (Ue.zg) {
|
|
27
|
-
const o = "Braze SDK Warning: " + n + " (v5.0.
|
|
27
|
+
const o = "Braze SDK Warning: " + n + " (v5.0.1)";
|
|
28
28
|
null != Ue.j ? Ue.j(o) : console.warn(o);
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
error: function (n) {
|
|
32
32
|
if (Ue.zg) {
|
|
33
|
-
const o = "Braze SDK Error: " + n + " (v5.0.
|
|
33
|
+
const o = "Braze SDK Error: " + n + " (v5.0.1)";
|
|
34
34
|
null != Ue.j ? Ue.j(o) : console.error(o);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -71,7 +71,7 @@ class Bt {
|
|
|
71
71
|
(this.Go = []),
|
|
72
72
|
(this.Ko = []),
|
|
73
73
|
(this.Ve = []),
|
|
74
|
-
(this.jo = "5.0.
|
|
74
|
+
(this.jo = "5.0.1");
|
|
75
75
|
}
|
|
76
76
|
$o(t) {
|
|
77
77
|
this.zo.It(t);
|
|
@@ -187,6 +187,7 @@ class Bt {
|
|
|
187
187
|
this.$t,
|
|
188
188
|
)),
|
|
189
189
|
this.ki.initialize(),
|
|
190
|
+
a || this.u.Ho(),
|
|
190
191
|
r.j.info(
|
|
191
192
|
`Initialized for the Braze backend at "${this.nn(
|
|
192
193
|
L._o,
|
|
@@ -241,7 +242,7 @@ class Bt {
|
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
rr() {
|
|
244
|
-
return !this.
|
|
245
|
+
return !this.Xo() && (!!this.fe() || (console.warn(P), !1));
|
|
245
246
|
}
|
|
246
247
|
Ma() {
|
|
247
248
|
return this.cn;
|
|
@@ -310,7 +311,7 @@ class Bt {
|
|
|
310
311
|
fe() {
|
|
311
312
|
return this.Bo;
|
|
312
313
|
}
|
|
313
|
-
|
|
314
|
+
Xo() {
|
|
314
315
|
return this.Wo;
|
|
315
316
|
}
|
|
316
317
|
As() {
|
|
@@ -15,8 +15,8 @@ export default class Ot {
|
|
|
15
15
|
(this.Qo = e);
|
|
16
16
|
}
|
|
17
17
|
ce(t = !0) {
|
|
18
|
-
let e = this.u.tu(i.eu.
|
|
19
|
-
null == e && ((e = new _t(r.Z.Y())), t && this.u.uu(i.eu.
|
|
18
|
+
let e = this.u.tu(i.eu.Zo);
|
|
19
|
+
null == e && ((e = new _t(r.Z.Y())), t && this.u.uu(i.eu.Zo, e));
|
|
20
20
|
const s = new xt(e.iu);
|
|
21
21
|
for (let t = 0; t < this.Qo.length; t++) {
|
|
22
22
|
switch (this.Qo[t]) {
|
|
@@ -24,19 +24,19 @@ export default class Ot {
|
|
|
24
24
|
s.browser = Q.browser;
|
|
25
25
|
break;
|
|
26
26
|
case DeviceProperties.BROWSER_VERSION:
|
|
27
|
-
s.
|
|
27
|
+
s.Ia = Q.version;
|
|
28
28
|
break;
|
|
29
29
|
case DeviceProperties.OS:
|
|
30
|
-
s.os = this.
|
|
30
|
+
s.os = this.Ta();
|
|
31
31
|
break;
|
|
32
32
|
case DeviceProperties.RESOLUTION:
|
|
33
|
-
s.
|
|
33
|
+
s.Da = screen.width + "x" + screen.height;
|
|
34
34
|
break;
|
|
35
35
|
case DeviceProperties.LANGUAGE:
|
|
36
36
|
s.language = Q.language;
|
|
37
37
|
break;
|
|
38
38
|
case DeviceProperties.TIME_ZONE:
|
|
39
|
-
s.timeZone = this.
|
|
39
|
+
s.timeZone = this.Oa(new Date());
|
|
40
40
|
break;
|
|
41
41
|
case DeviceProperties.USER_AGENT:
|
|
42
42
|
s.userAgent = Q.userAgent;
|
|
@@ -44,12 +44,12 @@ export default class Ot {
|
|
|
44
44
|
}
|
|
45
45
|
return s;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
if (Q.
|
|
49
|
-
const t = this.u.v(i.k.
|
|
50
|
-
return t && t.os_version ? t.os_version : Q.
|
|
47
|
+
Ta() {
|
|
48
|
+
if (Q.Ca()) return Q.Ca();
|
|
49
|
+
const t = this.u.v(i.k.Fa);
|
|
50
|
+
return t && t.os_version ? t.os_version : Q.Ta();
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
Oa(t) {
|
|
53
53
|
let e = !1;
|
|
54
54
|
if ("undefined" != typeof Intl && "function" == typeof Intl.DateTimeFormat)
|
|
55
55
|
try {
|
|
@@ -66,9 +66,9 @@ export default class Ot {
|
|
|
66
66
|
}
|
|
67
67
|
if (e) return "";
|
|
68
68
|
const s = t.getTimezoneOffset();
|
|
69
|
-
return this.
|
|
69
|
+
return this.Ga(s);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
Ga(t) {
|
|
72
72
|
const e = Math.trunc(t / 60),
|
|
73
73
|
r = Math.trunc(t % 60);
|
|
74
74
|
let s = "GMT";
|
|
@@ -24,12 +24,12 @@ const Mt = {
|
|
|
24
24
|
} catch (e) {
|
|
25
25
|
r.j.info("Local Storage not supported!");
|
|
26
26
|
}
|
|
27
|
-
const a = Mt.
|
|
28
|
-
n = new J.
|
|
27
|
+
const a = Mt.Ja(),
|
|
28
|
+
n = new J.Va(e, a && !o, t);
|
|
29
29
|
let c;
|
|
30
|
-
return (c = t ? new J.
|
|
30
|
+
return (c = t ? new J.Ya(e) : new J.Za()), new J(n, c);
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
Ja: function () {
|
|
33
33
|
return (
|
|
34
34
|
navigator.cookieEnabled ||
|
|
35
35
|
("cookie" in document &&
|
|
@@ -13,15 +13,15 @@ import { getErrorMessage as ei } from "../util/error-utils.js";
|
|
|
13
13
|
export const STORAGE_KEYS = {
|
|
14
14
|
eu: {
|
|
15
15
|
su: "ab.storage.userId",
|
|
16
|
-
|
|
16
|
+
Zo: "ab.storage.deviceId",
|
|
17
17
|
Dl: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
19
|
k: {
|
|
20
20
|
Qa: "ab.test",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
tE: "ab.storage.events",
|
|
22
|
+
eE: "ab.storage.attributes",
|
|
23
|
+
sE: "ab.storage.attributes.anonymous_user",
|
|
24
|
+
Fa: "ab.storage.device",
|
|
25
25
|
Kh: "ab.storage.sdk_metadata",
|
|
26
26
|
Wh: "ab.storage.session_id_for_cached_metadata",
|
|
27
27
|
Bn: "ab.storage.pushToken",
|
|
@@ -29,8 +29,8 @@ export const STORAGE_KEYS = {
|
|
|
29
29
|
Ei: "ab.storage.lastNewsFeedRefresh",
|
|
30
30
|
L: "ab.storage.cardImpressions",
|
|
31
31
|
hl: "ab.storage.serverConfig",
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
rE: "ab.storage.triggers",
|
|
33
|
+
oE: "ab.storage.triggers.ts",
|
|
34
34
|
zl: "ab.storage.messagingSessionStart",
|
|
35
35
|
gs: "ab.storage.cc",
|
|
36
36
|
js: "ab.storage.ccLastFullSync",
|
|
@@ -40,24 +40,24 @@ export const STORAGE_KEYS = {
|
|
|
40
40
|
C: "ab.storage.ccClicks",
|
|
41
41
|
K: "ab.storage.ccImpressions",
|
|
42
42
|
G: "ab.storage.ccDismissals",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
nE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
44
|
+
iE: "ab.storage.lastDisplayedTriggerTime",
|
|
45
|
+
aE: "ab.storage.triggerFireInstancesById",
|
|
46
46
|
xh: "ab.storage.signature",
|
|
47
47
|
zs: "ab.storage.brazeSyncRetryCount",
|
|
48
48
|
Us: "ab.storage.sdkVersion",
|
|
49
49
|
Ri: "ab.storage.ff",
|
|
50
50
|
qi: "ab.storage.ffImpressions",
|
|
51
51
|
Ui: "ab.storage.ffLastRefreshAt",
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
EE: "ab.storage.lastReqToEndpoint",
|
|
53
|
+
lE: "ab.storage.requestAttempts",
|
|
54
54
|
rn: "ab.storage.deferredIam",
|
|
55
55
|
},
|
|
56
56
|
re: "ab.optOut",
|
|
57
57
|
};
|
|
58
58
|
export default class J {
|
|
59
59
|
constructor(t, e) {
|
|
60
|
-
(this.
|
|
60
|
+
(this.SE = t), (this._E = e), (this.SE = t), (this._E = e);
|
|
61
61
|
}
|
|
62
62
|
Jo(t) {
|
|
63
63
|
const e = oo(STORAGE_KEYS.eu),
|
|
@@ -66,39 +66,46 @@ export default class J {
|
|
|
66
66
|
}
|
|
67
67
|
uu(t, e) {
|
|
68
68
|
let s = null;
|
|
69
|
-
null != e && e instanceof _t && (s = e.tt()), this.
|
|
69
|
+
null != e && e instanceof _t && (s = e.tt()), this.SE.store(t, s);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
uE(t) {
|
|
72
72
|
const e = this.tu(t);
|
|
73
73
|
null != e && ((e.Nl = new Date().valueOf()), this.uu(t, e));
|
|
74
74
|
}
|
|
75
75
|
tu(t) {
|
|
76
|
-
return _t.Yn(this.
|
|
76
|
+
return _t.Yn(this.SE.jr(t));
|
|
77
77
|
}
|
|
78
78
|
ql(t) {
|
|
79
|
-
this.
|
|
79
|
+
this.SE.remove(t);
|
|
80
|
+
}
|
|
81
|
+
Ho() {
|
|
82
|
+
const t = oo(STORAGE_KEYS.eu);
|
|
83
|
+
let e;
|
|
84
|
+
for (const s of t)
|
|
85
|
+
(e = this.tu(STORAGE_KEYS.eu[s])),
|
|
86
|
+
null != e && this.uu(STORAGE_KEYS.eu[s], e);
|
|
80
87
|
}
|
|
81
88
|
bo(t) {
|
|
82
89
|
let e;
|
|
83
90
|
if (null == t || 0 === t.length) return !1;
|
|
84
91
|
e = p(t) ? t : [t];
|
|
85
|
-
let s = this.
|
|
92
|
+
let s = this._E.jr(STORAGE_KEYS.k.tE);
|
|
86
93
|
(null != s && p(s)) || (s = []);
|
|
87
94
|
for (let t = 0; t < e.length; t++) s.push(e[t].tt());
|
|
88
|
-
return this.
|
|
95
|
+
return this._E.store(STORAGE_KEYS.k.tE, s);
|
|
89
96
|
}
|
|
90
97
|
Hl(t) {
|
|
91
98
|
return null != t && this.bo([t]);
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
let t = this.
|
|
95
|
-
this.
|
|
100
|
+
cE() {
|
|
101
|
+
let t = this._E.jr(STORAGE_KEYS.k.tE);
|
|
102
|
+
this._E.remove(STORAGE_KEYS.k.tE), null == t && (t = []);
|
|
96
103
|
const e = [];
|
|
97
104
|
let s = !1,
|
|
98
105
|
o = null;
|
|
99
106
|
if (p(t))
|
|
100
107
|
for (let s = 0; s < t.length; s++)
|
|
101
|
-
ue.
|
|
108
|
+
ue.TE(t[s]) ? e.push(ue.Yn(t[s])) : (o = s);
|
|
102
109
|
else s = !0;
|
|
103
110
|
if (s || null != o) {
|
|
104
111
|
let n = "Stored events could not be deserialized as Events";
|
|
@@ -122,7 +129,7 @@ export default class J {
|
|
|
122
129
|
t,
|
|
123
130
|
"StorageManager cannot store object.",
|
|
124
131
|
"STORAGE_KEYS.OBJECTS",
|
|
125
|
-
) && this.
|
|
132
|
+
) && this._E.store(t, e)
|
|
126
133
|
);
|
|
127
134
|
}
|
|
128
135
|
v(t) {
|
|
@@ -132,7 +139,7 @@ export default class J {
|
|
|
132
139
|
t,
|
|
133
140
|
"StorageManager cannot retrieve object.",
|
|
134
141
|
"STORAGE_KEYS.OBJECTS",
|
|
135
|
-
) && this.
|
|
142
|
+
) && this._E.jr(t)
|
|
136
143
|
);
|
|
137
144
|
}
|
|
138
145
|
ni(t) {
|
|
@@ -142,7 +149,7 @@ export default class J {
|
|
|
142
149
|
t,
|
|
143
150
|
"StorageManager cannot remove object.",
|
|
144
151
|
"STORAGE_KEYS.OBJECTS",
|
|
145
|
-
) && (this.
|
|
152
|
+
) && (this._E.remove(t), !0)
|
|
146
153
|
);
|
|
147
154
|
}
|
|
148
155
|
clearData() {
|
|
@@ -150,20 +157,20 @@ export default class J {
|
|
|
150
157
|
e = oo(STORAGE_KEYS.k);
|
|
151
158
|
for (let e = 0; e < t.length; e++) {
|
|
152
159
|
const s = t[e];
|
|
153
|
-
this.
|
|
160
|
+
this.SE.remove(STORAGE_KEYS.eu[s]);
|
|
154
161
|
}
|
|
155
162
|
for (let t = 0; t < e.length; t++) {
|
|
156
163
|
const s = e[t];
|
|
157
|
-
this.
|
|
164
|
+
this._E.remove(STORAGE_KEYS.k[s]);
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
|
-
|
|
161
|
-
return t || STORAGE_KEYS.k.
|
|
167
|
+
hE(t) {
|
|
168
|
+
return t || STORAGE_KEYS.k.sE;
|
|
162
169
|
}
|
|
163
170
|
Ha(t) {
|
|
164
|
-
let e = this.
|
|
171
|
+
let e = this._E.jr(STORAGE_KEYS.k.eE);
|
|
165
172
|
null == e && (e = {});
|
|
166
|
-
const s = this.
|
|
173
|
+
const s = this.hE(t[User.bu]),
|
|
167
174
|
r = e[s];
|
|
168
175
|
for (const o in t)
|
|
169
176
|
o !== User.bu &&
|
|
@@ -171,61 +178,61 @@ export default class J {
|
|
|
171
178
|
this.mu(t[User.bu], o, t[o]);
|
|
172
179
|
}
|
|
173
180
|
mu(t, e, s) {
|
|
174
|
-
let r = this.
|
|
181
|
+
let r = this._E.jr(STORAGE_KEYS.k.eE);
|
|
175
182
|
null == r && (r = {});
|
|
176
|
-
const o = this.
|
|
183
|
+
const o = this.hE(t);
|
|
177
184
|
let n = r[o];
|
|
178
185
|
if (
|
|
179
186
|
(null == n && ((n = {}), null != t && (n[User.bu] = t)), e === User.lu)
|
|
180
187
|
) {
|
|
181
188
|
null == n[e] && (n[e] = {});
|
|
182
189
|
for (const t in s) n[e][t] = s[t];
|
|
183
|
-
} else
|
|
184
|
-
return (r[o] = n), this.
|
|
190
|
+
} else n[e] = s;
|
|
191
|
+
return (r[o] = n), this._E.store(STORAGE_KEYS.k.eE, r);
|
|
185
192
|
}
|
|
186
|
-
|
|
187
|
-
const t = this.
|
|
188
|
-
this.
|
|
193
|
+
AE() {
|
|
194
|
+
const t = this._E.jr(STORAGE_KEYS.k.eE);
|
|
195
|
+
this._E.remove(STORAGE_KEYS.k.eE);
|
|
189
196
|
const e = [];
|
|
190
197
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
191
198
|
return e;
|
|
192
199
|
}
|
|
193
200
|
ou(t) {
|
|
194
|
-
const e = this.
|
|
201
|
+
const e = this._E.jr(STORAGE_KEYS.k.eE);
|
|
195
202
|
if (null != e) {
|
|
196
|
-
const s = this.
|
|
203
|
+
const s = this.hE(null),
|
|
197
204
|
r = e[s];
|
|
198
205
|
null != r &&
|
|
199
206
|
((e[s] = void 0),
|
|
200
|
-
this.
|
|
207
|
+
this._E.store(STORAGE_KEYS.k.eE, e),
|
|
201
208
|
(r[User.bu] = t),
|
|
202
209
|
this.Ha(r));
|
|
203
210
|
}
|
|
204
211
|
const s = this.tu(STORAGE_KEYS.eu.Dl);
|
|
205
212
|
let r = null;
|
|
206
213
|
null != s && (r = s.iu);
|
|
207
|
-
const o = this.
|
|
214
|
+
const o = this.cE();
|
|
208
215
|
if (null != o)
|
|
209
216
|
for (let e = 0; e < o.length; e++) {
|
|
210
217
|
const s = o[e];
|
|
211
218
|
null == s.userId && s.sessionId == r && (s.userId = t), this.Hl(s);
|
|
212
219
|
}
|
|
213
220
|
}
|
|
214
|
-
|
|
215
|
-
return this.
|
|
221
|
+
RE() {
|
|
222
|
+
return this._E.OE;
|
|
216
223
|
}
|
|
217
224
|
}
|
|
218
|
-
(J.
|
|
225
|
+
(J.Ya = class {
|
|
219
226
|
constructor(t) {
|
|
220
|
-
(this.cn = t), (this.cn = t), (this.
|
|
227
|
+
(this.cn = t), (this.cn = t), (this.OE = Q.gE() ? 3 : 10);
|
|
221
228
|
}
|
|
222
|
-
|
|
229
|
+
dE(t) {
|
|
223
230
|
return t + "." + this.cn;
|
|
224
231
|
}
|
|
225
232
|
store(t, e) {
|
|
226
233
|
const s = { v: e };
|
|
227
234
|
try {
|
|
228
|
-
return localStorage.setItem(this.
|
|
235
|
+
return localStorage.setItem(this.dE(t), JSON.stringify(s)), !0;
|
|
229
236
|
} catch (t) {
|
|
230
237
|
return r.j.info("Storage failure: " + ei(t)), !1;
|
|
231
238
|
}
|
|
@@ -233,7 +240,7 @@ export default class J {
|
|
|
233
240
|
jr(t) {
|
|
234
241
|
try {
|
|
235
242
|
let e = null;
|
|
236
|
-
const s = localStorage.getItem(this.
|
|
243
|
+
const s = localStorage.getItem(this.dE(t));
|
|
237
244
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
238
245
|
} catch (t) {
|
|
239
246
|
return r.j.info("Storage retrieval failure: " + ei(t)), null;
|
|
@@ -241,30 +248,30 @@ export default class J {
|
|
|
241
248
|
}
|
|
242
249
|
remove(t) {
|
|
243
250
|
try {
|
|
244
|
-
localStorage.removeItem(this.
|
|
251
|
+
localStorage.removeItem(this.dE(t));
|
|
245
252
|
} catch (t) {
|
|
246
253
|
return r.j.info("Storage removal failure: " + ei(t)), !1;
|
|
247
254
|
}
|
|
248
255
|
}
|
|
249
256
|
}),
|
|
250
|
-
(J.
|
|
257
|
+
(J.Za = class {
|
|
251
258
|
constructor() {
|
|
252
|
-
(this.
|
|
259
|
+
(this.fE = {}), (this.bE = 5242880), (this.OE = 3);
|
|
253
260
|
}
|
|
254
261
|
store(t, e) {
|
|
255
262
|
const s = { value: e },
|
|
256
|
-
o = this.
|
|
257
|
-
return o > this.
|
|
263
|
+
o = this.IE(e);
|
|
264
|
+
return o > this.bE
|
|
258
265
|
? (r.j.info(
|
|
259
266
|
"Storage failure: object is ≈" +
|
|
260
267
|
o +
|
|
261
268
|
" bytes which is greater than the max of " +
|
|
262
|
-
this.
|
|
269
|
+
this.bE,
|
|
263
270
|
),
|
|
264
271
|
!1)
|
|
265
|
-
: ((this.
|
|
272
|
+
: ((this.fE[t] = s), !0);
|
|
266
273
|
}
|
|
267
|
-
|
|
274
|
+
IE(t) {
|
|
268
275
|
const e = [],
|
|
269
276
|
s = [t];
|
|
270
277
|
let r = 0;
|
|
@@ -282,26 +289,26 @@ export default class J {
|
|
|
282
289
|
return r;
|
|
283
290
|
}
|
|
284
291
|
jr(t) {
|
|
285
|
-
const e = this.
|
|
292
|
+
const e = this.fE[t];
|
|
286
293
|
return null == e ? null : e.value;
|
|
287
294
|
}
|
|
288
295
|
remove(t) {
|
|
289
|
-
this.
|
|
296
|
+
this.fE[t] = null;
|
|
290
297
|
}
|
|
291
298
|
}),
|
|
292
299
|
(J.ee = class {
|
|
293
300
|
constructor(t, e) {
|
|
294
301
|
(this.cn = t),
|
|
295
|
-
(this.
|
|
302
|
+
(this.mE = e),
|
|
296
303
|
(this.cn = t),
|
|
297
|
-
(this.
|
|
298
|
-
(this.
|
|
299
|
-
(this.
|
|
304
|
+
(this.KE = this.YE()),
|
|
305
|
+
(this.NE = 576e3),
|
|
306
|
+
(this.mE = !!e);
|
|
300
307
|
}
|
|
301
|
-
|
|
308
|
+
dE(t) {
|
|
302
309
|
return null != this.cn ? t + "." + this.cn : t;
|
|
303
310
|
}
|
|
304
|
-
|
|
311
|
+
YE() {
|
|
305
312
|
let t = 0,
|
|
306
313
|
e = document.location.hostname;
|
|
307
314
|
const s = e.split("."),
|
|
@@ -318,9 +325,9 @@ export default class J {
|
|
|
318
325
|
}
|
|
319
326
|
ae() {
|
|
320
327
|
const t = new Date();
|
|
321
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
328
|
+
return t.setTime(t.getTime() + 60 * this.NE * 1e3), t.getFullYear();
|
|
322
329
|
}
|
|
323
|
-
|
|
330
|
+
DE() {
|
|
324
331
|
const t = Pt(STORAGE_KEYS.eu),
|
|
325
332
|
e = document.cookie.split(";");
|
|
326
333
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -334,19 +341,19 @@ export default class J {
|
|
|
334
341
|
}
|
|
335
342
|
if (o) {
|
|
336
343
|
const t = r.split("=")[0];
|
|
337
|
-
-1 === t.indexOf("." + this.cn) && this.
|
|
344
|
+
-1 === t.indexOf("." + this.cn) && this.GE(t);
|
|
338
345
|
}
|
|
339
346
|
}
|
|
340
347
|
}
|
|
341
348
|
store(t, e) {
|
|
342
|
-
this.
|
|
349
|
+
this.DE();
|
|
343
350
|
const s = new Date();
|
|
344
|
-
s.setTime(s.getTime() + 60 * this.
|
|
351
|
+
s.setTime(s.getTime() + 60 * this.NE * 1e3);
|
|
345
352
|
const o = "expires=" + s.toUTCString(),
|
|
346
|
-
n = "domain=" + this.
|
|
353
|
+
n = "domain=" + this.KE;
|
|
347
354
|
let i;
|
|
348
|
-
i = this.
|
|
349
|
-
const a = this.
|
|
355
|
+
i = this.mE ? e : encodeURIComponent(JSON.stringify(e));
|
|
356
|
+
const a = this.dE(t) + "=" + i + ";" + o + ";" + n + ";path=/";
|
|
350
357
|
return a.length >= 4093
|
|
351
358
|
? (r.j.info(
|
|
352
359
|
"Storage failure: string is " +
|
|
@@ -358,7 +365,7 @@ export default class J {
|
|
|
358
365
|
}
|
|
359
366
|
jr(t) {
|
|
360
367
|
const e = [],
|
|
361
|
-
s = this.
|
|
368
|
+
s = this.dE(t) + "=",
|
|
362
369
|
o = document.cookie.split(";");
|
|
363
370
|
for (let n = 0; n < o.length; n++) {
|
|
364
371
|
let i = o[n];
|
|
@@ -366,7 +373,7 @@ export default class J {
|
|
|
366
373
|
if (0 === i.indexOf(s))
|
|
367
374
|
try {
|
|
368
375
|
let t;
|
|
369
|
-
(t = this.
|
|
376
|
+
(t = this.mE
|
|
370
377
|
? i.substring(s.length, i.length)
|
|
371
378
|
: JSON.parse(
|
|
372
379
|
decodeURIComponent(i.substring(s.length, i.length)),
|
|
@@ -383,22 +390,22 @@ export default class J {
|
|
|
383
390
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
384
391
|
}
|
|
385
392
|
remove(t) {
|
|
386
|
-
this.
|
|
393
|
+
this.GE(this.dE(t));
|
|
387
394
|
}
|
|
388
|
-
|
|
395
|
+
GE(t) {
|
|
389
396
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
390
397
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
391
|
-
const s = e + ";domain=" + this.
|
|
398
|
+
const s = e + ";domain=" + this.KE;
|
|
392
399
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
393
400
|
}
|
|
394
401
|
}),
|
|
395
|
-
(J.
|
|
402
|
+
(J.Va = class {
|
|
396
403
|
constructor(t, e, s) {
|
|
397
404
|
(this.cn = t),
|
|
398
405
|
(this.CE = []),
|
|
399
406
|
e && this.CE.push(new J.ee(t)),
|
|
400
|
-
s && this.CE.push(new J.
|
|
401
|
-
this.CE.push(new J.
|
|
407
|
+
s && this.CE.push(new J.Ya(t)),
|
|
408
|
+
this.CE.push(new J.Za());
|
|
402
409
|
}
|
|
403
410
|
store(t, e) {
|
|
404
411
|
let s = !0;
|
package/src/models/device.js
CHANGED
|
@@ -6,7 +6,7 @@ export default class xt {
|
|
|
6
6
|
const s = {};
|
|
7
7
|
return (
|
|
8
8
|
null != this.browser && (s.browser = this.browser),
|
|
9
|
-
null != this.
|
|
9
|
+
null != this.Ia && (s.browser_version = this.Ia),
|
|
10
10
|
null != this.os && (s.os_version = this.os),
|
|
11
11
|
null != this.resolution && (s.resolution = this.resolution),
|
|
12
12
|
null != this.language && (s.locale = this.language),
|
|
@@ -28,7 +28,7 @@ export default class Kt {
|
|
|
28
28
|
}
|
|
29
29
|
tt() {
|
|
30
30
|
return {
|
|
31
|
-
s: "5.0.
|
|
31
|
+
s: "5.0.1",
|
|
32
32
|
l: this.ol,
|
|
33
33
|
e: this.cl,
|
|
34
34
|
a: this.gl,
|
|
@@ -42,7 +42,7 @@ export default class Kt {
|
|
|
42
42
|
static Yn(t) {
|
|
43
43
|
let i = t.l;
|
|
44
44
|
return (
|
|
45
|
-
"5.0.
|
|
45
|
+
"5.0.1" !== t.s && (i = 0), new Kt(i, t.e, t.a, t.p, t.m, t.v, t.c, t.f)
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -23,7 +23,7 @@ export default class Lt {
|
|
|
23
23
|
(this.cn = t),
|
|
24
24
|
(this.baseUrl = i),
|
|
25
25
|
(this.gu = 0),
|
|
26
|
-
(this.
|
|
26
|
+
(this.OE = n.RE() || 0),
|
|
27
27
|
(this.vu = null),
|
|
28
28
|
(this._e = s),
|
|
29
29
|
(this.fn = e),
|
|
@@ -54,8 +54,8 @@ export default class Lt {
|
|
|
54
54
|
}
|
|
55
55
|
qu(t = !1, s = !1, e = !0, h, o, n, u = !1, l = !1) {
|
|
56
56
|
e && this.Au();
|
|
57
|
-
const a = this.u.
|
|
58
|
-
c = this.u.
|
|
57
|
+
const a = this.u.cE(),
|
|
58
|
+
c = this.u.AE();
|
|
59
59
|
let d = !1;
|
|
60
60
|
const f = (t, s) => {
|
|
61
61
|
let r = !1;
|
|
@@ -73,7 +73,7 @@ export default class Lt {
|
|
|
73
73
|
this.yt.ul(e),
|
|
74
74
|
(null != t.respond_with &&
|
|
75
75
|
t.respond_with.user_id != this.wt.getUserId()) ||
|
|
76
|
-
(null != t.device && this.u.D(i.k.
|
|
76
|
+
(null != t.device && this.u.D(i.k.Fa, t.device),
|
|
77
77
|
null != t.sdk_metadata &&
|
|
78
78
|
(this.u.D(i.k.Kh, t.sdk_metadata),
|
|
79
79
|
this.u.D(i.k.Wh, this._e.Yh())),
|
|
@@ -95,8 +95,8 @@ export default class Lt {
|
|
|
95
95
|
else {
|
|
96
96
|
T.hi(this.u, T.Os.Na);
|
|
97
97
|
let t = this.vu;
|
|
98
|
-
(null == t || t < 1e3 * this.
|
|
99
|
-
this.Cu(Math.min(3e5, D(1e3 * this.
|
|
98
|
+
(null == t || t < 1e3 * this.OE) && (t = 1e3 * this.OE),
|
|
99
|
+
this.Cu(Math.min(3e5, D(1e3 * this.OE, 3 * t)));
|
|
100
100
|
}
|
|
101
101
|
d = !0;
|
|
102
102
|
}
|
|
@@ -124,7 +124,7 @@ export default class Lt {
|
|
|
124
124
|
Du() {
|
|
125
125
|
return this.gu > 0;
|
|
126
126
|
}
|
|
127
|
-
Cu(t = 1e3 * this.
|
|
127
|
+
Cu(t = 1e3 * this.OE) {
|
|
128
128
|
this.ju ||
|
|
129
129
|
(this.Au(),
|
|
130
130
|
(this.ku = window.setTimeout(() => {
|
|
@@ -158,7 +158,7 @@ export default class Lt {
|
|
|
158
158
|
}
|
|
159
159
|
openSession() {
|
|
160
160
|
const t = this._e.Yh() !== this._e.co();
|
|
161
|
-
t && (this.u.
|
|
161
|
+
t && (this.u.uE(i.eu.Zo), this.u.uE(i.eu.su)),
|
|
162
162
|
this.qu(void 0, !1, void 0, void 0, void 0),
|
|
163
163
|
this.pu(),
|
|
164
164
|
t &&
|
|
@@ -201,7 +201,7 @@ export default class Lt {
|
|
|
201
201
|
e ? this.Mo.setSdkAuthenticationSignature(e) : this.Mo.yh();
|
|
202
202
|
for (let t = 0; t < s.length; t++) s[t].changeUser(null == h);
|
|
203
203
|
null != h && this.u.ni(i.k.L),
|
|
204
|
-
this.u.ni(i.k.
|
|
204
|
+
this.u.ni(i.k.Fa),
|
|
205
205
|
this.openSession(),
|
|
206
206
|
r.j.info('Changed user to "' + t + '".');
|
|
207
207
|
} else {
|
|
@@ -37,9 +37,9 @@ export default class gr extends y {
|
|
|
37
37
|
}
|
|
38
38
|
fg() {
|
|
39
39
|
if (this.u) {
|
|
40
|
-
(this.hg = this.u.v(i.k.
|
|
41
|
-
(this.ng = this.u.v(i.k.
|
|
42
|
-
(this.og = this.u.v(i.k.
|
|
40
|
+
(this.hg = this.u.v(i.k.iE) || this.hg),
|
|
41
|
+
(this.ng = this.u.v(i.k.aE) || this.ng),
|
|
42
|
+
(this.og = this.u.v(i.k.nE) || this.og);
|
|
43
43
|
for (let t = 0; t < this.triggers.length; t++) {
|
|
44
44
|
const i = this.triggers[t];
|
|
45
45
|
i.id && null != this.og[i.id] && i.Wu(this.og[i.id]);
|
|
@@ -48,8 +48,8 @@ export default class gr extends y {
|
|
|
48
48
|
}
|
|
49
49
|
lg() {
|
|
50
50
|
if (!this.u) return;
|
|
51
|
-
this.ag = this.u.v(i.k.
|
|
52
|
-
const t = this.u.v(i.k.
|
|
51
|
+
this.ag = this.u.v(i.k.oE) || 0;
|
|
52
|
+
const t = this.u.v(i.k.rE) || [],
|
|
53
53
|
s = [];
|
|
54
54
|
for (let i = 0; i < t.length; i++) s.push(pt.Yn(t[i]));
|
|
55
55
|
(this.triggers = s), this.fg();
|
|
@@ -76,7 +76,7 @@ export default class gr extends y {
|
|
|
76
76
|
let t, r;
|
|
77
77
|
h.push(n),
|
|
78
78
|
null != n.ug && (t = n.ug),
|
|
79
|
-
null != n.dg && ue.
|
|
79
|
+
null != n.dg && ue.TE(n.dg) && (r = ue.Yn(n.dg));
|
|
80
80
|
const a = [];
|
|
81
81
|
if (n.pg && p(n.pg))
|
|
82
82
|
for (let t = 0; t < n.pg.length; t++) {
|
|
@@ -92,7 +92,7 @@ export default class gr extends y {
|
|
|
92
92
|
0 === this.ng[i.id].length && delete this.ng[i.id]);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
r && this.u && this.u.D(i.k.
|
|
95
|
+
r && this.u && this.u.D(i.k.aE, this.ng);
|
|
96
96
|
}
|
|
97
97
|
mg() {
|
|
98
98
|
if (!this.u) return;
|
|
@@ -100,12 +100,12 @@ export default class gr extends y {
|
|
|
100
100
|
for (let i = 0; i < this.triggers.length; i++)
|
|
101
101
|
t.push(this.triggers[i].tt());
|
|
102
102
|
(this.ag = new Date().valueOf()),
|
|
103
|
-
this.u.D(i.k.
|
|
104
|
-
this.u.D(i.k.
|
|
103
|
+
this.u.D(i.k.rE, t),
|
|
104
|
+
this.u.D(i.k.oE, this.ag);
|
|
105
105
|
}
|
|
106
106
|
bg() {
|
|
107
107
|
if (!this.u) return;
|
|
108
|
-
(this.u.v(i.k.
|
|
108
|
+
(this.u.v(i.k.oE) || 0) > this.ag ? this.lg() : this.fg();
|
|
109
109
|
}
|
|
110
110
|
Ss(t) {
|
|
111
111
|
let s = !1;
|
|
@@ -129,8 +129,8 @@ export default class gr extends y {
|
|
|
129
129
|
this.triggers.push(r);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
ii(this.og, e) || ((this.og = e), this.u && this.u.D(i.k.
|
|
133
|
-
ii(this.ng, h) || ((this.ng = h), this.u && this.u.D(i.k.
|
|
132
|
+
ii(this.og, e) || ((this.og = e), this.u && this.u.D(i.k.nE, this.og)),
|
|
133
|
+
ii(this.ng, h) || ((this.ng = h), this.u && this.u.D(i.k.aE, this.ng)),
|
|
134
134
|
this.mg(),
|
|
135
135
|
s &&
|
|
136
136
|
(r.j.info("Trigger with test condition found, firing test."),
|
|
@@ -281,11 +281,11 @@ export default class gr extends y {
|
|
|
281
281
|
));
|
|
282
282
|
}
|
|
283
283
|
changeUser(t = !1) {
|
|
284
|
-
if (((this.triggers = []), this.u && this.u.ni(i.k.
|
|
284
|
+
if (((this.triggers = []), this.u && this.u.ni(i.k.rE), !t)) {
|
|
285
285
|
(this.sg = []), (this.hg = null), (this.og = {}), (this.ng = {});
|
|
286
286
|
for (let t = 0; t < this.eg.length; t++) clearTimeout(this.eg[t]);
|
|
287
287
|
(this.eg = []),
|
|
288
|
-
this.u && (this.u.ni(i.k.
|
|
288
|
+
this.u && (this.u.ni(i.k.iE), this.u.ni(i.k.nE), this.u.ni(i.k.aE));
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
clearData() {
|
|
@@ -314,13 +314,13 @@ export default class gr extends y {
|
|
|
314
314
|
for (const t of h) t.id && a.push(t.id);
|
|
315
315
|
(n.pg = a),
|
|
316
316
|
t.id && this.ng[t.id].push(n),
|
|
317
|
-
this.u && this.u.D(i.k.
|
|
317
|
+
this.u && this.u.D(i.k.aE, this.ng);
|
|
318
318
|
}
|
|
319
319
|
yg(t, s) {
|
|
320
320
|
this.fg(),
|
|
321
321
|
t.Wu(s),
|
|
322
322
|
(this.hg = s),
|
|
323
323
|
t.id && (this.og[t.id] = s),
|
|
324
|
-
this.u && (this.u.D(i.k.
|
|
324
|
+
this.u && (this.u.D(i.k.iE, s), this.u.D(i.k.nE, this.og));
|
|
325
325
|
}
|
|
326
326
|
}
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e, { OPTIONS as L } from "../../managers/braze-instance.js";
|
|
2
2
|
export function attachCSS(n, t, o) {
|
|
3
3
|
const c = n || document.querySelector("head"),
|
|
4
|
-
s = `ab-${t}-css-definitions-${"5.0.
|
|
4
|
+
s = `ab-${t}-css-definitions-${"5.0.1".replace(/\./g, "-")}`;
|
|
5
5
|
if (!c) return;
|
|
6
6
|
const a = c.ownerDocument || document;
|
|
7
7
|
if (null == a.getElementById(s)) {
|
|
@@ -9,7 +9,7 @@ class gi {
|
|
|
9
9
|
(this.browser = this.Sg.tf()),
|
|
10
10
|
(this.version = this.Sg.ef()),
|
|
11
11
|
(this.OS = null),
|
|
12
|
-
this.
|
|
12
|
+
this.Ta().then((t) => (this.OS = t));
|
|
13
13
|
const i = navigator;
|
|
14
14
|
(this.language = (
|
|
15
15
|
i.userLanguage ||
|
|
@@ -23,13 +23,13 @@ class gi {
|
|
|
23
23
|
gE() {
|
|
24
24
|
return this.browser === oi.Bg;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
Ca() {
|
|
27
27
|
return this.OS || null;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
Ta() {
|
|
30
30
|
return this.OS
|
|
31
31
|
? Promise.resolve(this.OS)
|
|
32
|
-
: this.Sg.
|
|
32
|
+
: this.Sg.Ta(gi.Og).then((t) => ((this.OS = t), t));
|
|
33
33
|
}
|
|
34
34
|
static vg(t) {
|
|
35
35
|
t = t.toLowerCase();
|
|
@@ -3,16 +3,16 @@ import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
|
3
3
|
const T = {
|
|
4
4
|
Os: { Na: "d", Ks: "cc", Si: "ff", Lr: "t" },
|
|
5
5
|
rm: (e) => {
|
|
6
|
-
if (e) return e.v(i.k.
|
|
6
|
+
if (e) return e.v(i.k.EE);
|
|
7
7
|
},
|
|
8
8
|
sm: (e) => {
|
|
9
|
-
if (e) return e.v(i.k.
|
|
9
|
+
if (e) return e.v(i.k.lE);
|
|
10
10
|
},
|
|
11
11
|
nm: (e, t) => {
|
|
12
|
-
e && e.D(i.k.
|
|
12
|
+
e && e.D(i.k.EE, t);
|
|
13
13
|
},
|
|
14
14
|
um: (e, t) => {
|
|
15
|
-
e && e.D(i.k.
|
|
15
|
+
e && e.D(i.k.lE, t);
|
|
16
16
|
},
|
|
17
17
|
La: (e, t) => {
|
|
18
18
|
if (!e || !t) return -1;
|