@braze/web-sdk 5.1.1 → 5.3.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 +65 -10
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +20 -20
- package/shared-lib/indexed-db-adapter.js +52 -52
- package/shared-lib/logger.js +7 -7
- package/shared-lib/supported-options.js +22 -21
- 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 +45 -42
- package/src/InAppMessage/display/in-app-message-to-html.js +22 -22
- package/src/InAppMessage/display/modal-utils.js +7 -7
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +23 -21
- package/src/InAppMessage/in-app-message-manager.js +95 -112
- 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/control-message.js +4 -2
- package/src/InAppMessage/models/full-screen-message.js +14 -11
- package/src/InAppMessage/models/html-message.js +11 -9
- package/src/InAppMessage/models/in-app-message-button.js +2 -2
- package/src/InAppMessage/models/in-app-message.js +127 -120
- package/src/InAppMessage/models/modal-message.js +14 -11
- package/src/InAppMessage/models/slide-up-message.js +46 -21
- 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 +37 -43
- package/src/InAppMessage/utils/in-app-message-utils.js +18 -1
- package/src/Push/push-manager-factory.js +4 -4
- package/src/Push/push-manager.js +118 -110
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +4 -4
- package/src/User/user.js +19 -19
- package/src/common/base-feed.js +1 -1
- 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 +12 -12
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/l10n/l10n-manager.js +4 -4
- package/src/managers/auth-manager.js +27 -27
- package/src/managers/braze-instance.js +119 -112
- package/src/managers/device-manager.js +19 -19
- package/src/managers/network-manager.js +215 -165
- package/src/managers/server-config-manager.js +46 -50
- package/src/managers/session-manager.js +21 -21
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +128 -125
- package/src/managers/utils.js +6 -0
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +19 -11
- package/src/models/device.js +3 -3
- package/src/models/identifier.js +34 -20
- package/src/models/push-token.js +4 -4
- package/src/models/server-config.js +24 -24
- package/src/request-controller.js +134 -124
- 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 +8 -8
- package/src/triggers/models/push-click-data.js +3 -3
- package/src/triggers/models/trigger-condition.js +30 -30
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +36 -36
- package/src/triggers/triggers-provider-factory.js +2 -2
- package/src/triggers/triggers-provider.js +84 -95
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/load-font-awesome.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 +25 -24
- package/src/util/client-hints-parser.js +4 -4
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +2 -2
- package/src/util/dom-utils.js +6 -6
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +4 -4
- package/src/util/request-header-utils.js +36 -37
- package/src/util/user-agent-parser.js +8 -8
- package/src/util/validation-utils.js +2 -0
- package/src/util/window-utils.js +3 -3
|
@@ -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
|
}
|
|
@@ -13,70 +13,71 @@ import { getErrorMessage as si } from "../util/error-utils.js";
|
|
|
13
13
|
export const STORAGE_KEYS = {
|
|
14
14
|
iu: {
|
|
15
15
|
su: "ab.storage.userId",
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Uo: "ab.storage.deviceId",
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
Ca: "ab.storage.device",
|
|
25
|
+
Yh: "ab.storage.sdk_metadata",
|
|
26
|
+
Jh: "ab.storage.session_id_for_cached_metadata",
|
|
27
|
+
In: "ab.storage.pushToken",
|
|
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
|
-
|
|
47
|
-
|
|
44
|
+
aE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
45
|
+
iE: "ab.storage.lastDisplayedTriggerTime",
|
|
46
|
+
EE: "ab.storage.triggerFireInstancesById",
|
|
47
|
+
wh: "ab.storage.signature",
|
|
48
48
|
As: "ab.storage.brazeSyncRetryCount",
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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",
|
|
58
59
|
},
|
|
59
60
|
se: "ab.optOut",
|
|
60
61
|
};
|
|
61
62
|
export default class Q {
|
|
62
63
|
constructor(t, e) {
|
|
63
|
-
(this.
|
|
64
|
+
(this.uE = t), (this.TE = e), (this.uE = t), (this.TE = e);
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
Wh(t) {
|
|
66
67
|
const e = to(STORAGE_KEYS.iu),
|
|
67
68
|
s = new Q.ee(t);
|
|
68
69
|
for (const t of e) s.remove(STORAGE_KEYS.iu[t]);
|
|
69
70
|
}
|
|
70
71
|
uu(t, e) {
|
|
71
72
|
let s = null;
|
|
72
|
-
null != e && e instanceof _t && (s = e.Y()), this.
|
|
73
|
+
null != e && e instanceof _t && (s = e.Y()), this.uE.store(t, s);
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
cE(t) {
|
|
75
76
|
const e = this.tu(t);
|
|
76
|
-
null != e && ((e.
|
|
77
|
+
null != e && ((e.Wl = new Date().valueOf()), this.uu(t, e));
|
|
77
78
|
}
|
|
78
79
|
tu(t) {
|
|
79
|
-
const e = this.
|
|
80
|
+
const e = this.uE.br(t),
|
|
80
81
|
s = ((t) => {
|
|
81
82
|
let e;
|
|
82
83
|
try {
|
|
@@ -87,42 +88,44 @@ export default class Q {
|
|
|
87
88
|
return e;
|
|
88
89
|
})(e);
|
|
89
90
|
let r;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
if (s) (r = _t.qn(s) || null), r && this.uu(t, r);
|
|
92
|
+
else {
|
|
93
|
+
const s = _t.hE(e);
|
|
94
|
+
(r = _t.qn(s) || null), s !== e && r && this.uu(t, r);
|
|
95
|
+
}
|
|
96
|
+
return r;
|
|
94
97
|
}
|
|
95
|
-
|
|
96
|
-
this.
|
|
98
|
+
Al(t) {
|
|
99
|
+
this.uE.remove(t);
|
|
97
100
|
}
|
|
98
|
-
|
|
101
|
+
Vh() {
|
|
99
102
|
const t = to(STORAGE_KEYS.iu);
|
|
100
103
|
let e;
|
|
101
104
|
for (const s of t)
|
|
102
105
|
(e = this.tu(STORAGE_KEYS.iu[s])),
|
|
103
106
|
null != e && this.uu(STORAGE_KEYS.iu[s], e);
|
|
104
107
|
}
|
|
105
|
-
|
|
108
|
+
xo(t) {
|
|
106
109
|
let e;
|
|
107
110
|
if (null == t || 0 === t.length) return !1;
|
|
108
111
|
e = j(t) ? t : [t];
|
|
109
|
-
let s = this.
|
|
112
|
+
let s = this.TE.br(STORAGE_KEYS.C.tE);
|
|
110
113
|
(null != s && j(s)) || (s = []);
|
|
111
114
|
for (let t = 0; t < e.length; t++) s.push(e[t].Y());
|
|
112
|
-
return this.
|
|
115
|
+
return this.TE.store(STORAGE_KEYS.C.tE, s);
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
return null != t && this.
|
|
117
|
+
kl(t) {
|
|
118
|
+
return null != t && this.xo([t]);
|
|
116
119
|
}
|
|
117
|
-
|
|
118
|
-
let t = this.
|
|
119
|
-
this.
|
|
120
|
+
AE() {
|
|
121
|
+
let t = this.TE.br(STORAGE_KEYS.C.tE);
|
|
122
|
+
this.TE.remove(STORAGE_KEYS.C.tE), null == t && (t = []);
|
|
120
123
|
const e = [];
|
|
121
124
|
let s = !1,
|
|
122
125
|
r = null;
|
|
123
126
|
if (j(t))
|
|
124
127
|
for (let s = 0; s < t.length; s++)
|
|
125
|
-
ue.
|
|
128
|
+
ue.RE(t[s]) ? e.push(ue.qn(t[s])) : (r = s);
|
|
126
129
|
else s = !0;
|
|
127
130
|
if (s || null != r) {
|
|
128
131
|
let o = "Stored events could not be deserialized as Events";
|
|
@@ -135,7 +138,7 @@ export default class Q {
|
|
|
135
138
|
typeof t +
|
|
136
139
|
": " +
|
|
137
140
|
JSON.stringify(t)),
|
|
138
|
-
e.push(new ue(null, i.
|
|
141
|
+
e.push(new ue(null, i.qs, new Date().valueOf(), null, { e: o }));
|
|
139
142
|
}
|
|
140
143
|
return e;
|
|
141
144
|
}
|
|
@@ -146,7 +149,7 @@ export default class Q {
|
|
|
146
149
|
t,
|
|
147
150
|
"StorageManager cannot store object.",
|
|
148
151
|
"STORAGE_KEYS.OBJECTS",
|
|
149
|
-
) && this.
|
|
152
|
+
) && this.TE.store(t, e)
|
|
150
153
|
);
|
|
151
154
|
}
|
|
152
155
|
j(t) {
|
|
@@ -156,17 +159,17 @@ export default class Q {
|
|
|
156
159
|
t,
|
|
157
160
|
"StorageManager cannot retrieve object.",
|
|
158
161
|
"STORAGE_KEYS.OBJECTS",
|
|
159
|
-
) && this.
|
|
162
|
+
) && this.TE.br(t)
|
|
160
163
|
);
|
|
161
164
|
}
|
|
162
|
-
|
|
165
|
+
ti(t) {
|
|
163
166
|
return (
|
|
164
167
|
!!J(
|
|
165
168
|
STORAGE_KEYS.C,
|
|
166
169
|
t,
|
|
167
170
|
"StorageManager cannot remove object.",
|
|
168
171
|
"STORAGE_KEYS.OBJECTS",
|
|
169
|
-
) && (this.
|
|
172
|
+
) && (this.TE.remove(t), !0)
|
|
170
173
|
);
|
|
171
174
|
}
|
|
172
175
|
clearData() {
|
|
@@ -174,82 +177,82 @@ export default class Q {
|
|
|
174
177
|
e = to(STORAGE_KEYS.C);
|
|
175
178
|
for (let e = 0; e < t.length; e++) {
|
|
176
179
|
const s = t[e];
|
|
177
|
-
this.
|
|
180
|
+
this.uE.remove(STORAGE_KEYS.iu[s]);
|
|
178
181
|
}
|
|
179
182
|
for (let t = 0; t < e.length; t++) {
|
|
180
183
|
const s = e[t];
|
|
181
|
-
this.
|
|
184
|
+
this.TE.remove(STORAGE_KEYS.C[s]);
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
|
-
|
|
187
|
+
gE(t) {
|
|
185
188
|
return t || STORAGE_KEYS.C.sE;
|
|
186
189
|
}
|
|
187
|
-
|
|
188
|
-
let e = this.
|
|
190
|
+
La(t) {
|
|
191
|
+
let e = this.TE.br(STORAGE_KEYS.C.eE);
|
|
189
192
|
null == e && (e = {});
|
|
190
|
-
const s = this.
|
|
193
|
+
const s = this.gE(t[User.Yn]),
|
|
191
194
|
r = e[s];
|
|
192
195
|
for (const o in t)
|
|
193
|
-
o !== User.
|
|
196
|
+
o !== User.Yn &&
|
|
194
197
|
(null == e[s] || (r && null == r[o])) &&
|
|
195
|
-
this.mu(t[User.
|
|
198
|
+
this.mu(t[User.Yn], o, t[o]);
|
|
196
199
|
}
|
|
197
200
|
mu(t, e, s) {
|
|
198
|
-
let r = this.
|
|
201
|
+
let r = this.TE.br(STORAGE_KEYS.C.eE);
|
|
199
202
|
null == r && (r = {});
|
|
200
|
-
const o = this.
|
|
203
|
+
const o = this.gE(t);
|
|
201
204
|
let n = r[o];
|
|
202
205
|
if (
|
|
203
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
206
|
+
(null == n && ((n = {}), null != t && (n[User.Yn] = t)), e === User.lu)
|
|
204
207
|
) {
|
|
205
208
|
null == n[e] && (n[e] = {});
|
|
206
209
|
for (const t in s) n[e][t] = s[t];
|
|
207
210
|
} else n[e] = s;
|
|
208
|
-
return (r[o] = n), this.
|
|
211
|
+
return (r[o] = n), this.TE.store(STORAGE_KEYS.C.eE, r);
|
|
209
212
|
}
|
|
210
|
-
|
|
211
|
-
const t = this.
|
|
212
|
-
this.
|
|
213
|
+
OE() {
|
|
214
|
+
const t = this.TE.br(STORAGE_KEYS.C.eE);
|
|
215
|
+
this.TE.remove(STORAGE_KEYS.C.eE);
|
|
213
216
|
const e = [];
|
|
214
217
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
215
218
|
return e;
|
|
216
219
|
}
|
|
217
220
|
ru(t) {
|
|
218
|
-
const e = this.
|
|
221
|
+
const e = this.TE.br(STORAGE_KEYS.C.eE);
|
|
219
222
|
if (null != e) {
|
|
220
|
-
const s = this.
|
|
223
|
+
const s = this.gE(null),
|
|
221
224
|
r = e[s];
|
|
222
225
|
null != r &&
|
|
223
226
|
((e[s] = void 0),
|
|
224
|
-
this.
|
|
225
|
-
(r[User.
|
|
226
|
-
this.
|
|
227
|
+
this.TE.store(STORAGE_KEYS.C.eE, e),
|
|
228
|
+
(r[User.Yn] = t),
|
|
229
|
+
this.La(r));
|
|
227
230
|
}
|
|
228
|
-
const s = this.tu(STORAGE_KEYS.iu.
|
|
231
|
+
const s = this.tu(STORAGE_KEYS.iu.El);
|
|
229
232
|
let r = null;
|
|
230
233
|
null != s && (r = s.eu);
|
|
231
|
-
const o = this.
|
|
234
|
+
const o = this.AE();
|
|
232
235
|
if (null != o)
|
|
233
236
|
for (let e = 0; e < o.length; e++) {
|
|
234
237
|
const s = o[e];
|
|
235
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
238
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.kl(s);
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
|
-
|
|
239
|
-
return this.
|
|
241
|
+
dE() {
|
|
242
|
+
return this.TE.fE;
|
|
240
243
|
}
|
|
241
244
|
}
|
|
242
245
|
(Q.rc = class {
|
|
243
246
|
constructor(t) {
|
|
244
|
-
(this.
|
|
247
|
+
(this.rn = t), (this.rn = t), (this.fE = X.IE() ? 3 : 10);
|
|
245
248
|
}
|
|
246
|
-
|
|
247
|
-
return t + "." + this.
|
|
249
|
+
bE(t) {
|
|
250
|
+
return t + "." + this.rn;
|
|
248
251
|
}
|
|
249
252
|
store(t, e) {
|
|
250
253
|
const s = { v: e };
|
|
251
254
|
try {
|
|
252
|
-
return localStorage.setItem(this.
|
|
255
|
+
return localStorage.setItem(this.bE(t), JSON.stringify(s)), !0;
|
|
253
256
|
} catch (t) {
|
|
254
257
|
return r.info("Storage failure: " + si(t)), !1;
|
|
255
258
|
}
|
|
@@ -257,7 +260,7 @@ export default class Q {
|
|
|
257
260
|
br(t) {
|
|
258
261
|
try {
|
|
259
262
|
let e = null;
|
|
260
|
-
const s = localStorage.getItem(this.
|
|
263
|
+
const s = localStorage.getItem(this.bE(t));
|
|
261
264
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
262
265
|
} catch (t) {
|
|
263
266
|
return r.info("Storage retrieval failure: " + si(t)), null;
|
|
@@ -265,7 +268,7 @@ export default class Q {
|
|
|
265
268
|
}
|
|
266
269
|
remove(t) {
|
|
267
270
|
try {
|
|
268
|
-
localStorage.removeItem(this.
|
|
271
|
+
localStorage.removeItem(this.bE(t));
|
|
269
272
|
} catch (t) {
|
|
270
273
|
return r.info("Storage removal failure: " + si(t)), !1;
|
|
271
274
|
}
|
|
@@ -273,22 +276,22 @@ export default class Q {
|
|
|
273
276
|
}),
|
|
274
277
|
(Q.ac = class {
|
|
275
278
|
constructor() {
|
|
276
|
-
(this.
|
|
279
|
+
(this.mE = {}), (this.KE = 5242880), (this.fE = 3);
|
|
277
280
|
}
|
|
278
281
|
store(t, e) {
|
|
279
282
|
const s = { value: e },
|
|
280
|
-
o = this.
|
|
281
|
-
return o > this.
|
|
283
|
+
o = this.YE(e);
|
|
284
|
+
return o > this.KE
|
|
282
285
|
? (r.info(
|
|
283
286
|
"Storage failure: object is ≈" +
|
|
284
287
|
o +
|
|
285
288
|
" bytes which is greater than the max of " +
|
|
286
|
-
this.
|
|
289
|
+
this.KE,
|
|
287
290
|
),
|
|
288
291
|
!1)
|
|
289
|
-
: ((this.
|
|
292
|
+
: ((this.mE[t] = s), !0);
|
|
290
293
|
}
|
|
291
|
-
|
|
294
|
+
YE(t) {
|
|
292
295
|
const e = [],
|
|
293
296
|
s = [t];
|
|
294
297
|
let r = 0;
|
|
@@ -306,26 +309,26 @@ export default class Q {
|
|
|
306
309
|
return r;
|
|
307
310
|
}
|
|
308
311
|
br(t) {
|
|
309
|
-
const e = this.
|
|
312
|
+
const e = this.mE[t];
|
|
310
313
|
return null == e ? null : e.value;
|
|
311
314
|
}
|
|
312
315
|
remove(t) {
|
|
313
|
-
this.
|
|
316
|
+
this.mE[t] = null;
|
|
314
317
|
}
|
|
315
318
|
}),
|
|
316
319
|
(Q.ee = class {
|
|
317
320
|
constructor(t, e) {
|
|
318
|
-
(this.
|
|
319
|
-
(this.
|
|
320
|
-
(this.
|
|
321
|
-
(this.
|
|
322
|
-
(this.
|
|
323
|
-
(this.
|
|
321
|
+
(this.rn = t),
|
|
322
|
+
(this.NE = e),
|
|
323
|
+
(this.rn = t),
|
|
324
|
+
(this.CE = this.GE()),
|
|
325
|
+
(this.DE = 576e3),
|
|
326
|
+
(this.NE = !!e);
|
|
324
327
|
}
|
|
325
|
-
|
|
326
|
-
return null != this.
|
|
328
|
+
bE(t) {
|
|
329
|
+
return null != this.rn ? t + "." + this.rn : t;
|
|
327
330
|
}
|
|
328
|
-
|
|
331
|
+
GE() {
|
|
329
332
|
let t = 0,
|
|
330
333
|
e = document.location.hostname;
|
|
331
334
|
const s = e.split("."),
|
|
@@ -342,9 +345,9 @@ export default class Q {
|
|
|
342
345
|
}
|
|
343
346
|
ne() {
|
|
344
347
|
const t = new Date();
|
|
345
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
348
|
+
return t.setTime(t.getTime() + 60 * this.DE * 1e3), t.getFullYear();
|
|
346
349
|
}
|
|
347
|
-
|
|
350
|
+
ME() {
|
|
348
351
|
const t = Pt(STORAGE_KEYS.iu),
|
|
349
352
|
e = document.cookie.split(";");
|
|
350
353
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -358,19 +361,19 @@ export default class Q {
|
|
|
358
361
|
}
|
|
359
362
|
if (o) {
|
|
360
363
|
const t = r.split("=")[0];
|
|
361
|
-
-1 === t.indexOf("." + this.
|
|
364
|
+
-1 === t.indexOf("." + this.rn) && this.pE(t);
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
367
|
}
|
|
365
368
|
store(t, e) {
|
|
366
|
-
this.
|
|
369
|
+
this.ME();
|
|
367
370
|
const s = new Date();
|
|
368
|
-
s.setTime(s.getTime() + 60 * this.
|
|
371
|
+
s.setTime(s.getTime() + 60 * this.DE * 1e3);
|
|
369
372
|
const o = "expires=" + s.toUTCString(),
|
|
370
|
-
n = "domain=" + this.
|
|
373
|
+
n = "domain=" + this.CE;
|
|
371
374
|
let a;
|
|
372
|
-
a = this.
|
|
373
|
-
const i = this.
|
|
375
|
+
a = this.NE ? e : encodeURIComponent(e);
|
|
376
|
+
const i = this.bE(t) + "=" + a + ";" + o + ";" + n + ";path=/";
|
|
374
377
|
return i.length >= 4093
|
|
375
378
|
? (r.info(
|
|
376
379
|
"Storage failure: string is " +
|
|
@@ -382,7 +385,7 @@ export default class Q {
|
|
|
382
385
|
}
|
|
383
386
|
br(t) {
|
|
384
387
|
const e = [],
|
|
385
|
-
s = this.
|
|
388
|
+
s = this.bE(t) + "=",
|
|
386
389
|
o = document.cookie.split(";");
|
|
387
390
|
for (let n = 0; n < o.length; n++) {
|
|
388
391
|
let a = o[n];
|
|
@@ -390,7 +393,7 @@ export default class Q {
|
|
|
390
393
|
if (0 === a.indexOf(s))
|
|
391
394
|
try {
|
|
392
395
|
let t;
|
|
393
|
-
(t = this.
|
|
396
|
+
(t = this.NE
|
|
394
397
|
? a.substring(s.length, a.length)
|
|
395
398
|
: decodeURIComponent(a.substring(s.length, a.length))),
|
|
396
399
|
e.push(t);
|
|
@@ -405,37 +408,37 @@ export default class Q {
|
|
|
405
408
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
406
409
|
}
|
|
407
410
|
remove(t) {
|
|
408
|
-
this.
|
|
411
|
+
this.pE(this.bE(t));
|
|
409
412
|
}
|
|
410
|
-
|
|
413
|
+
pE(t) {
|
|
411
414
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
412
415
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
413
|
-
const s = e + ";domain=" + this.
|
|
416
|
+
const s = e + ";domain=" + this.CE;
|
|
414
417
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
415
418
|
}
|
|
416
419
|
}),
|
|
417
420
|
(Q.tc = class {
|
|
418
421
|
constructor(t, e, s) {
|
|
419
|
-
(this.
|
|
420
|
-
(this.
|
|
421
|
-
e && this.
|
|
422
|
-
s && this.
|
|
423
|
-
this.
|
|
422
|
+
(this.rn = t),
|
|
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());
|
|
424
427
|
}
|
|
425
428
|
store(t, e) {
|
|
426
429
|
let s = !0;
|
|
427
|
-
for (let r = 0; r < this.
|
|
430
|
+
for (let r = 0; r < this.vE.length; r++) s = this.vE[r].store(t, e) && s;
|
|
428
431
|
return s;
|
|
429
432
|
}
|
|
430
433
|
br(t) {
|
|
431
|
-
for (let e = 0; e < this.
|
|
432
|
-
const s = this.
|
|
434
|
+
for (let e = 0; e < this.vE.length; e++) {
|
|
435
|
+
const s = this.vE[e].br(t);
|
|
433
436
|
if (null != s) return s;
|
|
434
437
|
}
|
|
435
438
|
return null;
|
|
436
439
|
}
|
|
437
440
|
remove(t) {
|
|
438
|
-
new Q.ee(this.
|
|
439
|
-
for (let e = 0; e < this.
|
|
441
|
+
new Q.ee(this.rn).remove(t);
|
|
442
|
+
for (let e = 0; e < this.vE.length; e++) this.vE[e].remove(t);
|
|
440
443
|
}
|
|
441
444
|
});
|
|
@@ -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,30 +1,38 @@
|
|
|
1
|
+
import e from "../managers/braze-instance.js";
|
|
2
|
+
import { getAlias as Gt } from "../managers/utils.js";
|
|
1
3
|
import { isObject as Nt } from "../util/code-utils.js";
|
|
2
4
|
import {
|
|
3
5
|
convertMsToSeconds as h,
|
|
4
6
|
timestampOrNow as Jt,
|
|
5
7
|
} from "../util/date-utils.js";
|
|
6
8
|
export default class ue {
|
|
7
|
-
constructor(t,
|
|
9
|
+
constructor(t, s, i, r, e) {
|
|
8
10
|
(this.userId = t),
|
|
9
|
-
(this.type =
|
|
10
|
-
(this.time =
|
|
11
|
+
(this.type = s),
|
|
12
|
+
(this.time = i),
|
|
11
13
|
(this.sessionId = r),
|
|
12
14
|
(this.data = e),
|
|
13
15
|
(this.userId = t),
|
|
14
|
-
(this.type =
|
|
15
|
-
(this.time = Jt(
|
|
16
|
+
(this.type = s),
|
|
17
|
+
(this.time = Jt(i)),
|
|
16
18
|
(this.sessionId = r),
|
|
17
19
|
(this.data = e);
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
Ir() {
|
|
22
|
+
var t;
|
|
23
|
+
const s = {
|
|
21
24
|
name: this.type,
|
|
22
25
|
time: h(this.time),
|
|
23
26
|
data: this.data || {},
|
|
24
27
|
session_id: this.sessionId,
|
|
25
|
-
user_id: void 0,
|
|
26
28
|
};
|
|
27
|
-
|
|
29
|
+
null != this.userId && (s.user_id = this.userId);
|
|
30
|
+
const i = (null === (t = e.Sr()) || void 0 === t ? void 0 : t.Fh()) || !1;
|
|
31
|
+
if (!s.user_id && !i) {
|
|
32
|
+
const t = Gt(e.l());
|
|
33
|
+
t && (s.alias = t);
|
|
34
|
+
}
|
|
35
|
+
return s;
|
|
28
36
|
}
|
|
29
37
|
Y() {
|
|
30
38
|
return {
|
|
@@ -38,10 +46,10 @@ export default class ue {
|
|
|
38
46
|
static fromJson(t) {
|
|
39
47
|
return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
40
48
|
}
|
|
41
|
-
static
|
|
49
|
+
static RE(t) {
|
|
42
50
|
return null != t && Nt(t) && null != t.t && "" !== t.t;
|
|
43
51
|
}
|
|
44
|
-
static
|
|
52
|
+
static qn(t) {
|
|
45
53
|
return new ue(t.u, t.t, t.ts, t.s, t.d);
|
|
46
54
|
}
|
|
47
55
|
}
|