@braze/web-sdk 5.2.0 → 5.3.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 +54 -5
- package/package.json +1 -1
- package/shared-lib/event-types.js +14 -14
- package/shared-lib/indexed-db-adapter.js +51 -51
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +7 -7
- package/src/ContentCards/content-cards-provider.js +107 -135
- 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 +2 -2
- package/src/ContentCards/ui/show-content-cards.js +1 -1
- package/src/FeatureFlags/feature-flag.js +41 -30
- package/src/FeatureFlags/feature-flags-provider.js +88 -84
- 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 +2 -2
- package/src/Feed/feed-provider.js +24 -24
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.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/defer-in-app-message.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +9 -9
- package/src/InAppMessage/display/in-app-message-to-html.js +20 -20
- package/src/InAppMessage/display/modal-utils.js +5 -5
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +78 -75
- package/src/InAppMessage/log-in-app-message-button-click.js +2 -2
- package/src/InAppMessage/log-in-app-message-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-html-click.js +3 -3
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/full-screen-message.js +12 -12
- package/src/InAppMessage/models/html-message.js +9 -9
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +84 -82
- package/src/InAppMessage/models/modal-message.js +12 -12
- package/src/InAppMessage/models/slide-up-message.js +17 -17
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +3 -3
- package/src/InAppMessage/ui/show-in-app-message.js +17 -17
- package/src/Push/push-manager-factory.js +6 -6
- package/src/Push/push-manager.js +2 -2
- package/src/Push/utils/push-utils.js +1 -1
- package/src/User/user.js +12 -12
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +0 -2
- package/src/common/event-logger.js +2 -2
- package/src/common/feed-display.js +1 -1
- package/src/managers/auth-manager.js +3 -3
- package/src/managers/braze-instance.js +73 -73
- package/src/managers/device-manager.js +15 -15
- package/src/managers/network-manager.js +190 -145
- package/src/managers/server-config-manager.js +43 -47
- package/src/managers/session-manager.js +21 -21
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +107 -107
- package/src/managers/utils.js +1 -1
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +6 -6
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +8 -8
- package/src/models/server-config.js +25 -25
- package/src/request-controller.js +115 -108
- package/src/triggers/models/custom-event-data.js +2 -2
- package/src/triggers/models/custom-event-property-data.js +4 -4
- package/src/triggers/models/filter-set.js +3 -3
- package/src/triggers/models/filter.js +55 -55
- package/src/triggers/models/in-app-message-click-data.js +8 -8
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +4 -4
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +40 -40
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +31 -31
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +40 -40
- package/src/ui/js/attach-css.js +2 -2
- package/src/util/base-device-parser.js +7 -7
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +23 -23
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/dom-utils.js +6 -6
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -37
- package/src/util/user-agent-parser.js +7 -7
- package/src/util/window-utils.js +1 -1
|
@@ -30,50 +30,50 @@ export default class Mt {
|
|
|
30
30
|
(this.wl = e);
|
|
31
31
|
}
|
|
32
32
|
jl(s, t) {
|
|
33
|
-
return new ue(this.wt.getUserId(), i.xl, s, t.eu, { d: h(s - t.
|
|
33
|
+
return new ue(this.wt.getUserId(), i.xl, s, t.eu, { d: h(s - t.Dl) });
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
const s = this.u.tu(o.iu.
|
|
35
|
+
Si() {
|
|
36
|
+
const s = this.u.tu(o.iu.El);
|
|
37
37
|
return null == s ? null : s.eu;
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
Gl() {
|
|
40
40
|
const s = new Date().valueOf(),
|
|
41
41
|
t = this.yt.dl(),
|
|
42
|
-
i = this.u.j(o.C.
|
|
42
|
+
i = this.u.j(o.C.Nl);
|
|
43
43
|
if (null != i && null == t) return !1;
|
|
44
44
|
let e = !1;
|
|
45
45
|
return (
|
|
46
46
|
null == i ? (e = !0) : null != t && (e = s - i > 1e3 * t),
|
|
47
|
-
e && this.u.k(o.C.
|
|
47
|
+
e && this.u.k(o.C.Nl, s),
|
|
48
48
|
e
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
return null == t || null == t.
|
|
51
|
+
zl(s, t) {
|
|
52
|
+
return null == t || null == t.Hl || (!(s - t.Dl < this.Sl) && t.Hl < s);
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
wo() {
|
|
55
55
|
const s = new Date().valueOf(),
|
|
56
56
|
t = s + 1e3 * this.wl,
|
|
57
|
-
e = this.u.tu(o.iu.
|
|
58
|
-
if (this.
|
|
57
|
+
e = this.u.tu(o.iu.El);
|
|
58
|
+
if (this.zl(s, e)) {
|
|
59
59
|
let n = "Generating session start event with time " + s;
|
|
60
60
|
if (null != e) {
|
|
61
|
-
let s = e.
|
|
62
|
-
s - e.
|
|
63
|
-
this.u.
|
|
61
|
+
let s = e.Wl;
|
|
62
|
+
s - e.Dl < this.Sl && (s = e.Dl + this.Sl),
|
|
63
|
+
this.u.kl(this.jl(s, e)),
|
|
64
64
|
(n += " (old session ended " + s + ")");
|
|
65
65
|
}
|
|
66
66
|
(n += ". Will expire " + t.valueOf()), r.info(n);
|
|
67
67
|
const l = new _t(p.W(), t);
|
|
68
|
-
this.u.
|
|
69
|
-
this.u.uu(o.iu.
|
|
70
|
-
return null == this.u.j(o.C.
|
|
68
|
+
this.u.kl(new ue(this.wt.getUserId(), i.ql, s, l.eu)),
|
|
69
|
+
this.u.uu(o.iu.El, l);
|
|
70
|
+
return null == this.u.j(o.C.Nl) && this.u.k(o.C.Nl, s), l.eu;
|
|
71
71
|
}
|
|
72
|
-
if (null != e) return (e.
|
|
72
|
+
if (null != e) return (e.Wl = s), (e.Hl = t), this.u.uu(o.iu.El, e), e.eu;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
const s = this.u.tu(o.iu.
|
|
74
|
+
yl() {
|
|
75
|
+
const s = this.u.tu(o.iu.El);
|
|
76
76
|
null != s &&
|
|
77
|
-
(this.u.
|
|
77
|
+
(this.u.Al(o.iu.El), this.u.kl(this.jl(new Date().valueOf(), s)));
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -14,70 +14,70 @@ export const STORAGE_KEYS = {
|
|
|
14
14
|
iu: {
|
|
15
15
|
su: "ab.storage.userId",
|
|
16
16
|
Uo: "ab.storage.deviceId",
|
|
17
|
-
|
|
17
|
+
El: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
19
|
C: {
|
|
20
20
|
ec: "ab.test",
|
|
21
21
|
tE: "ab.storage.events",
|
|
22
22
|
eE: "ab.storage.attributes",
|
|
23
23
|
sE: "ab.storage.attributes.anonymous_user",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
Ca: "ab.storage.device",
|
|
25
|
+
Yh: "ab.storage.sdk_metadata",
|
|
26
|
+
Jh: "ab.storage.session_id_for_cached_metadata",
|
|
27
27
|
In: "ab.storage.pushToken",
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
Ui: "ab.storage.newsFeed",
|
|
29
|
+
ki: "ab.storage.lastNewsFeedRefresh",
|
|
30
30
|
J: "ab.storage.cardImpressions",
|
|
31
|
-
|
|
31
|
+
ul: "ab.storage.serverConfig",
|
|
32
32
|
rE: "ab.storage.triggers",
|
|
33
33
|
oE: "ab.storage.triggers.ts",
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
Nl: "ab.storage.messagingSessionStart",
|
|
35
|
+
ws: "ab.storage.cc",
|
|
36
36
|
gs: "ab.storage.ccLastFullSync",
|
|
37
37
|
ys: "ab.storage.ccLastCardUpdated",
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
nE: "ab.storage.ccRateLimitCurrentTokenCount",
|
|
39
|
+
au: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
40
|
+
vu: "ab.storage.dynamicRateLimitCurrentTokenCount",
|
|
41
41
|
v: "ab.storage.ccClicks",
|
|
42
42
|
H: "ab.storage.ccImpressions",
|
|
43
43
|
A: "ab.storage.ccDismissals",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
aE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
45
|
+
iE: "ab.storage.lastDisplayedTriggerTime",
|
|
46
|
+
EE: "ab.storage.triggerFireInstancesById",
|
|
47
47
|
wh: "ab.storage.signature",
|
|
48
48
|
As: "ab.storage.brazeSyncRetryCount",
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
Ss: "ab.storage.sdkVersion",
|
|
50
|
+
gi: "ab.storage.ff",
|
|
51
|
+
vi: "ab.storage.ffImpressions",
|
|
52
|
+
xi: "ab.storage.ffLastRefreshAt",
|
|
53
|
+
Di: "ab.storage.ff.sessionId",
|
|
54
|
+
lE: "ab.storage.lastReqToEndpoint",
|
|
55
|
+
SE: "ab.storage.requestAttempts",
|
|
56
|
+
Cr: "ab.storage.deferredIam",
|
|
57
|
+
Qa: "ab.storage.lastSdkReq",
|
|
58
|
+
_E: "ab.storage.alias",
|
|
59
59
|
},
|
|
60
60
|
se: "ab.optOut",
|
|
61
61
|
};
|
|
62
62
|
export default class Q {
|
|
63
63
|
constructor(t, e) {
|
|
64
|
-
(this.
|
|
64
|
+
(this.uE = t), (this.TE = e), (this.uE = t), (this.TE = e);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
Wh(t) {
|
|
67
67
|
const e = to(STORAGE_KEYS.iu),
|
|
68
68
|
s = new Q.ee(t);
|
|
69
69
|
for (const t of e) s.remove(STORAGE_KEYS.iu[t]);
|
|
70
70
|
}
|
|
71
71
|
uu(t, e) {
|
|
72
72
|
let s = null;
|
|
73
|
-
null != e && e instanceof _t && (s = e.Y()), this.
|
|
73
|
+
null != e && e instanceof _t && (s = e.Y()), this.uE.store(t, s);
|
|
74
74
|
}
|
|
75
75
|
cE(t) {
|
|
76
76
|
const e = this.tu(t);
|
|
77
|
-
null != e && ((e.
|
|
77
|
+
null != e && ((e.Wl = new Date().valueOf()), this.uu(t, e));
|
|
78
78
|
}
|
|
79
79
|
tu(t) {
|
|
80
|
-
const e = this.
|
|
80
|
+
const e = this.uE.br(t),
|
|
81
81
|
s = ((t) => {
|
|
82
82
|
let e;
|
|
83
83
|
try {
|
|
@@ -90,42 +90,42 @@ export default class Q {
|
|
|
90
90
|
let r;
|
|
91
91
|
if (s) (r = _t.qn(s) || null), r && this.uu(t, r);
|
|
92
92
|
else {
|
|
93
|
-
const s = _t.
|
|
93
|
+
const s = _t.hE(e);
|
|
94
94
|
(r = _t.qn(s) || null), s !== e && r && this.uu(t, r);
|
|
95
95
|
}
|
|
96
96
|
return r;
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
this.
|
|
98
|
+
Al(t) {
|
|
99
|
+
this.uE.remove(t);
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
Vh() {
|
|
102
102
|
const t = to(STORAGE_KEYS.iu);
|
|
103
103
|
let e;
|
|
104
104
|
for (const s of t)
|
|
105
105
|
(e = this.tu(STORAGE_KEYS.iu[s])),
|
|
106
106
|
null != e && this.uu(STORAGE_KEYS.iu[s], e);
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
xo(t) {
|
|
109
109
|
let e;
|
|
110
110
|
if (null == t || 0 === t.length) return !1;
|
|
111
111
|
e = j(t) ? t : [t];
|
|
112
|
-
let s = this.
|
|
112
|
+
let s = this.TE.br(STORAGE_KEYS.C.tE);
|
|
113
113
|
(null != s && j(s)) || (s = []);
|
|
114
114
|
for (let t = 0; t < e.length; t++) s.push(e[t].Y());
|
|
115
|
-
return this.
|
|
115
|
+
return this.TE.store(STORAGE_KEYS.C.tE, s);
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
return null != t && this.
|
|
117
|
+
kl(t) {
|
|
118
|
+
return null != t && this.xo([t]);
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
let t = this.
|
|
122
|
-
this.
|
|
120
|
+
AE() {
|
|
121
|
+
let t = this.TE.br(STORAGE_KEYS.C.tE);
|
|
122
|
+
this.TE.remove(STORAGE_KEYS.C.tE), null == t && (t = []);
|
|
123
123
|
const e = [];
|
|
124
124
|
let s = !1,
|
|
125
125
|
r = null;
|
|
126
126
|
if (j(t))
|
|
127
127
|
for (let s = 0; s < t.length; s++)
|
|
128
|
-
ue.
|
|
128
|
+
ue.RE(t[s]) ? e.push(ue.qn(t[s])) : (r = s);
|
|
129
129
|
else s = !0;
|
|
130
130
|
if (s || null != r) {
|
|
131
131
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -138,7 +138,7 @@ export default class Q {
|
|
|
138
138
|
typeof t +
|
|
139
139
|
": " +
|
|
140
140
|
JSON.stringify(t)),
|
|
141
|
-
e.push(new ue(null, i.
|
|
141
|
+
e.push(new ue(null, i.qs, new Date().valueOf(), null, { e: o }));
|
|
142
142
|
}
|
|
143
143
|
return e;
|
|
144
144
|
}
|
|
@@ -149,7 +149,7 @@ export default class Q {
|
|
|
149
149
|
t,
|
|
150
150
|
"StorageManager cannot store object.",
|
|
151
151
|
"STORAGE_KEYS.OBJECTS",
|
|
152
|
-
) && this.
|
|
152
|
+
) && this.TE.store(t, e)
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
155
|
j(t) {
|
|
@@ -159,17 +159,17 @@ export default class Q {
|
|
|
159
159
|
t,
|
|
160
160
|
"StorageManager cannot retrieve object.",
|
|
161
161
|
"STORAGE_KEYS.OBJECTS",
|
|
162
|
-
) && this.
|
|
162
|
+
) && this.TE.br(t)
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
ti(t) {
|
|
166
166
|
return (
|
|
167
167
|
!!J(
|
|
168
168
|
STORAGE_KEYS.C,
|
|
169
169
|
t,
|
|
170
170
|
"StorageManager cannot remove object.",
|
|
171
171
|
"STORAGE_KEYS.OBJECTS",
|
|
172
|
-
) && (this.
|
|
172
|
+
) && (this.TE.remove(t), !0)
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
clearData() {
|
|
@@ -177,20 +177,20 @@ export default class Q {
|
|
|
177
177
|
e = to(STORAGE_KEYS.C);
|
|
178
178
|
for (let e = 0; e < t.length; e++) {
|
|
179
179
|
const s = t[e];
|
|
180
|
-
this.
|
|
180
|
+
this.uE.remove(STORAGE_KEYS.iu[s]);
|
|
181
181
|
}
|
|
182
182
|
for (let t = 0; t < e.length; t++) {
|
|
183
183
|
const s = e[t];
|
|
184
|
-
this.
|
|
184
|
+
this.TE.remove(STORAGE_KEYS.C[s]);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
gE(t) {
|
|
188
188
|
return t || STORAGE_KEYS.C.sE;
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
let e = this.
|
|
190
|
+
La(t) {
|
|
191
|
+
let e = this.TE.br(STORAGE_KEYS.C.eE);
|
|
192
192
|
null == e && (e = {});
|
|
193
|
-
const s = this.
|
|
193
|
+
const s = this.gE(t[User.Yn]),
|
|
194
194
|
r = e[s];
|
|
195
195
|
for (const o in t)
|
|
196
196
|
o !== User.Yn &&
|
|
@@ -198,9 +198,9 @@ export default class Q {
|
|
|
198
198
|
this.mu(t[User.Yn], o, t[o]);
|
|
199
199
|
}
|
|
200
200
|
mu(t, e, s) {
|
|
201
|
-
let r = this.
|
|
201
|
+
let r = this.TE.br(STORAGE_KEYS.C.eE);
|
|
202
202
|
null == r && (r = {});
|
|
203
|
-
const o = this.
|
|
203
|
+
const o = this.gE(t);
|
|
204
204
|
let n = r[o];
|
|
205
205
|
if (
|
|
206
206
|
(null == n && ((n = {}), null != t && (n[User.Yn] = t)), e === User.lu)
|
|
@@ -208,51 +208,51 @@ export default class Q {
|
|
|
208
208
|
null == n[e] && (n[e] = {});
|
|
209
209
|
for (const t in s) n[e][t] = s[t];
|
|
210
210
|
} else n[e] = s;
|
|
211
|
-
return (r[o] = n), this.
|
|
211
|
+
return (r[o] = n), this.TE.store(STORAGE_KEYS.C.eE, r);
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
const t = this.
|
|
215
|
-
this.
|
|
213
|
+
OE() {
|
|
214
|
+
const t = this.TE.br(STORAGE_KEYS.C.eE);
|
|
215
|
+
this.TE.remove(STORAGE_KEYS.C.eE);
|
|
216
216
|
const e = [];
|
|
217
217
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
218
218
|
return e;
|
|
219
219
|
}
|
|
220
220
|
ru(t) {
|
|
221
|
-
const e = this.
|
|
221
|
+
const e = this.TE.br(STORAGE_KEYS.C.eE);
|
|
222
222
|
if (null != e) {
|
|
223
|
-
const s = this.
|
|
223
|
+
const s = this.gE(null),
|
|
224
224
|
r = e[s];
|
|
225
225
|
null != r &&
|
|
226
226
|
((e[s] = void 0),
|
|
227
|
-
this.
|
|
227
|
+
this.TE.store(STORAGE_KEYS.C.eE, e),
|
|
228
228
|
(r[User.Yn] = t),
|
|
229
|
-
this.
|
|
229
|
+
this.La(r));
|
|
230
230
|
}
|
|
231
|
-
const s = this.tu(STORAGE_KEYS.iu.
|
|
231
|
+
const s = this.tu(STORAGE_KEYS.iu.El);
|
|
232
232
|
let r = null;
|
|
233
233
|
null != s && (r = s.eu);
|
|
234
|
-
const o = this.
|
|
234
|
+
const o = this.AE();
|
|
235
235
|
if (null != o)
|
|
236
236
|
for (let e = 0; e < o.length; e++) {
|
|
237
237
|
const s = o[e];
|
|
238
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
238
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.kl(s);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
|
|
242
|
-
return this.
|
|
241
|
+
dE() {
|
|
242
|
+
return this.TE.fE;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
(Q.rc = class {
|
|
246
246
|
constructor(t) {
|
|
247
|
-
(this.rn = t), (this.rn = t), (this.fE = X.
|
|
247
|
+
(this.rn = t), (this.rn = t), (this.fE = X.IE() ? 3 : 10);
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
bE(t) {
|
|
250
250
|
return t + "." + this.rn;
|
|
251
251
|
}
|
|
252
252
|
store(t, e) {
|
|
253
253
|
const s = { v: e };
|
|
254
254
|
try {
|
|
255
|
-
return localStorage.setItem(this.
|
|
255
|
+
return localStorage.setItem(this.bE(t), JSON.stringify(s)), !0;
|
|
256
256
|
} catch (t) {
|
|
257
257
|
return r.info("Storage failure: " + si(t)), !1;
|
|
258
258
|
}
|
|
@@ -260,7 +260,7 @@ export default class Q {
|
|
|
260
260
|
br(t) {
|
|
261
261
|
try {
|
|
262
262
|
let e = null;
|
|
263
|
-
const s = localStorage.getItem(this.
|
|
263
|
+
const s = localStorage.getItem(this.bE(t));
|
|
264
264
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
265
265
|
} catch (t) {
|
|
266
266
|
return r.info("Storage retrieval failure: " + si(t)), null;
|
|
@@ -268,7 +268,7 @@ export default class Q {
|
|
|
268
268
|
}
|
|
269
269
|
remove(t) {
|
|
270
270
|
try {
|
|
271
|
-
localStorage.removeItem(this.
|
|
271
|
+
localStorage.removeItem(this.bE(t));
|
|
272
272
|
} catch (t) {
|
|
273
273
|
return r.info("Storage removal failure: " + si(t)), !1;
|
|
274
274
|
}
|
|
@@ -276,11 +276,11 @@ export default class Q {
|
|
|
276
276
|
}),
|
|
277
277
|
(Q.ac = class {
|
|
278
278
|
constructor() {
|
|
279
|
-
(this.
|
|
279
|
+
(this.mE = {}), (this.KE = 5242880), (this.fE = 3);
|
|
280
280
|
}
|
|
281
281
|
store(t, e) {
|
|
282
282
|
const s = { value: e },
|
|
283
|
-
o = this.
|
|
283
|
+
o = this.YE(e);
|
|
284
284
|
return o > this.KE
|
|
285
285
|
? (r.info(
|
|
286
286
|
"Storage failure: object is ≈" +
|
|
@@ -289,9 +289,9 @@ export default class Q {
|
|
|
289
289
|
this.KE,
|
|
290
290
|
),
|
|
291
291
|
!1)
|
|
292
|
-
: ((this.
|
|
292
|
+
: ((this.mE[t] = s), !0);
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
YE(t) {
|
|
295
295
|
const e = [],
|
|
296
296
|
s = [t];
|
|
297
297
|
let r = 0;
|
|
@@ -309,26 +309,26 @@ export default class Q {
|
|
|
309
309
|
return r;
|
|
310
310
|
}
|
|
311
311
|
br(t) {
|
|
312
|
-
const e = this.
|
|
312
|
+
const e = this.mE[t];
|
|
313
313
|
return null == e ? null : e.value;
|
|
314
314
|
}
|
|
315
315
|
remove(t) {
|
|
316
|
-
this.
|
|
316
|
+
this.mE[t] = null;
|
|
317
317
|
}
|
|
318
318
|
}),
|
|
319
319
|
(Q.ee = class {
|
|
320
320
|
constructor(t, e) {
|
|
321
321
|
(this.rn = t),
|
|
322
|
-
(this.
|
|
322
|
+
(this.NE = e),
|
|
323
323
|
(this.rn = t),
|
|
324
|
-
(this.
|
|
325
|
-
(this.
|
|
326
|
-
(this.
|
|
324
|
+
(this.CE = this.GE()),
|
|
325
|
+
(this.DE = 576e3),
|
|
326
|
+
(this.NE = !!e);
|
|
327
327
|
}
|
|
328
|
-
|
|
328
|
+
bE(t) {
|
|
329
329
|
return null != this.rn ? t + "." + this.rn : t;
|
|
330
330
|
}
|
|
331
|
-
|
|
331
|
+
GE() {
|
|
332
332
|
let t = 0,
|
|
333
333
|
e = document.location.hostname;
|
|
334
334
|
const s = e.split("."),
|
|
@@ -345,9 +345,9 @@ export default class Q {
|
|
|
345
345
|
}
|
|
346
346
|
ne() {
|
|
347
347
|
const t = new Date();
|
|
348
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
348
|
+
return t.setTime(t.getTime() + 60 * this.DE * 1e3), t.getFullYear();
|
|
349
349
|
}
|
|
350
|
-
|
|
350
|
+
ME() {
|
|
351
351
|
const t = Pt(STORAGE_KEYS.iu),
|
|
352
352
|
e = document.cookie.split(";");
|
|
353
353
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -361,19 +361,19 @@ export default class Q {
|
|
|
361
361
|
}
|
|
362
362
|
if (o) {
|
|
363
363
|
const t = r.split("=")[0];
|
|
364
|
-
-1 === t.indexOf("." + this.rn) && this.
|
|
364
|
+
-1 === t.indexOf("." + this.rn) && this.pE(t);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
store(t, e) {
|
|
369
|
-
this.
|
|
369
|
+
this.ME();
|
|
370
370
|
const s = new Date();
|
|
371
|
-
s.setTime(s.getTime() + 60 * this.
|
|
371
|
+
s.setTime(s.getTime() + 60 * this.DE * 1e3);
|
|
372
372
|
const o = "expires=" + s.toUTCString(),
|
|
373
|
-
n = "domain=" + this.
|
|
373
|
+
n = "domain=" + this.CE;
|
|
374
374
|
let a;
|
|
375
|
-
a = this.
|
|
376
|
-
const i = this.
|
|
375
|
+
a = this.NE ? e : encodeURIComponent(e);
|
|
376
|
+
const i = this.bE(t) + "=" + a + ";" + o + ";" + n + ";path=/";
|
|
377
377
|
return i.length >= 4093
|
|
378
378
|
? (r.info(
|
|
379
379
|
"Storage failure: string is " +
|
|
@@ -385,7 +385,7 @@ export default class Q {
|
|
|
385
385
|
}
|
|
386
386
|
br(t) {
|
|
387
387
|
const e = [],
|
|
388
|
-
s = this.
|
|
388
|
+
s = this.bE(t) + "=",
|
|
389
389
|
o = document.cookie.split(";");
|
|
390
390
|
for (let n = 0; n < o.length; n++) {
|
|
391
391
|
let a = o[n];
|
|
@@ -393,7 +393,7 @@ export default class Q {
|
|
|
393
393
|
if (0 === a.indexOf(s))
|
|
394
394
|
try {
|
|
395
395
|
let t;
|
|
396
|
-
(t = this.
|
|
396
|
+
(t = this.NE
|
|
397
397
|
? a.substring(s.length, a.length)
|
|
398
398
|
: decodeURIComponent(a.substring(s.length, a.length))),
|
|
399
399
|
e.push(t);
|
|
@@ -408,37 +408,37 @@ export default class Q {
|
|
|
408
408
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
409
409
|
}
|
|
410
410
|
remove(t) {
|
|
411
|
-
this.
|
|
411
|
+
this.pE(this.bE(t));
|
|
412
412
|
}
|
|
413
|
-
|
|
413
|
+
pE(t) {
|
|
414
414
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
415
415
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
416
|
-
const s = e + ";domain=" + this.
|
|
416
|
+
const s = e + ";domain=" + this.CE;
|
|
417
417
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
418
418
|
}
|
|
419
419
|
}),
|
|
420
420
|
(Q.tc = class {
|
|
421
421
|
constructor(t, e, s) {
|
|
422
422
|
(this.rn = t),
|
|
423
|
-
(this.
|
|
424
|
-
e && this.
|
|
425
|
-
s && this.
|
|
426
|
-
this.
|
|
423
|
+
(this.vE = []),
|
|
424
|
+
e && this.vE.push(new Q.ee(t)),
|
|
425
|
+
s && this.vE.push(new Q.rc(t)),
|
|
426
|
+
this.vE.push(new Q.ac());
|
|
427
427
|
}
|
|
428
428
|
store(t, e) {
|
|
429
429
|
let s = !0;
|
|
430
|
-
for (let r = 0; r < this.
|
|
430
|
+
for (let r = 0; r < this.vE.length; r++) s = this.vE[r].store(t, e) && s;
|
|
431
431
|
return s;
|
|
432
432
|
}
|
|
433
433
|
br(t) {
|
|
434
|
-
for (let e = 0; e < this.
|
|
435
|
-
const s = this.
|
|
434
|
+
for (let e = 0; e < this.vE.length; e++) {
|
|
435
|
+
const s = this.vE[e].br(t);
|
|
436
436
|
if (null != s) return s;
|
|
437
437
|
}
|
|
438
438
|
return null;
|
|
439
439
|
}
|
|
440
440
|
remove(t) {
|
|
441
441
|
new Q.ee(this.rn).remove(t);
|
|
442
|
-
for (let e = 0; e < this.
|
|
442
|
+
for (let e = 0; e < this.vE.length; e++) this.vE[e].remove(t);
|
|
443
443
|
}
|
|
444
444
|
});
|
package/src/managers/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
qa: "invalid_api_key",
|
|
3
|
+
Aa: "blacklisted",
|
|
4
|
+
Ba: "no_device_identifier",
|
|
5
|
+
Ra: "invalid_json_response",
|
|
6
|
+
Zh: "empty_response",
|
|
7
7
|
__: "sdk_auth_error",
|
|
8
8
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import e from "../managers/braze-instance.js";
|
|
2
|
-
import { getAlias as
|
|
2
|
+
import { getAlias as Gt } from "../managers/utils.js";
|
|
3
3
|
import { isObject as Nt } from "../util/code-utils.js";
|
|
4
4
|
import {
|
|
5
5
|
convertMsToSeconds as h,
|
|
6
|
-
timestampOrNow as
|
|
6
|
+
timestampOrNow as Jt,
|
|
7
7
|
} from "../util/date-utils.js";
|
|
8
8
|
export default class ue {
|
|
9
9
|
constructor(t, s, i, r, e) {
|
|
@@ -14,11 +14,11 @@ export default class ue {
|
|
|
14
14
|
(this.data = e),
|
|
15
15
|
(this.userId = t),
|
|
16
16
|
(this.type = s),
|
|
17
|
-
(this.time =
|
|
17
|
+
(this.time = Jt(i)),
|
|
18
18
|
(this.sessionId = r),
|
|
19
19
|
(this.data = e);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
Ir() {
|
|
22
22
|
var t;
|
|
23
23
|
const s = {
|
|
24
24
|
name: this.type,
|
|
@@ -29,7 +29,7 @@ export default class ue {
|
|
|
29
29
|
null != this.userId && (s.user_id = this.userId);
|
|
30
30
|
const i = (null === (t = e.Sr()) || void 0 === t ? void 0 : t.Fh()) || !1;
|
|
31
31
|
if (!s.user_id && !i) {
|
|
32
|
-
const t =
|
|
32
|
+
const t = Gt(e.l());
|
|
33
33
|
t && (s.alias = t);
|
|
34
34
|
}
|
|
35
35
|
return s;
|
|
@@ -46,7 +46,7 @@ export default class ue {
|
|
|
46
46
|
static fromJson(t) {
|
|
47
47
|
return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
48
48
|
}
|
|
49
|
-
static
|
|
49
|
+
static RE(t) {
|
|
50
50
|
return null != t && Nt(t) && null != t.t && "" !== t.t;
|
|
51
51
|
}
|
|
52
52
|
static qn(t) {
|
package/src/models/device.js
CHANGED
|
@@ -2,11 +2,11 @@ export default class zt {
|
|
|
2
2
|
constructor(s) {
|
|
3
3
|
(this.id = s), (this.id = s);
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
Ir() {
|
|
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),
|