@braze/web-sdk 4.10.0 → 5.0.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 +19 -106
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/indexed-db-adapter.js +12 -12
- package/shared-lib/logger.js +2 -2
- package/shared-lib/supported-options.js +7 -8
- package/src/Card/models/captioned-image.js +19 -19
- package/src/Card/models/card.js +95 -94
- package/src/Card/models/classic-card.js +19 -19
- package/src/Card/models/control-card.js +9 -9
- package/src/Card/models/image-only.js +21 -22
- package/src/Card/models/index.js +0 -1
- package/src/Card/util/card-factory.js +39 -39
- package/src/ContentCards/content-cards-provider.js +114 -114
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/index.js +0 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +3 -3
- package/src/ContentCards/ui/hide-content-cards.js +2 -2
- package/src/ContentCards/ui/show-content-cards.js +14 -14
- package/src/Core/add-sdk-metadata.js +2 -2
- package/src/Core/change-user.js +2 -2
- package/src/Core/disable-sdk.js +4 -4
- package/src/Core/enable-sdk.js +4 -4
- package/src/Core/handle-braze-action.js +14 -14
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/open-session.js +5 -5
- package/src/Core/set-sdk-authentication-signature.js +2 -2
- package/src/Core/wipe-data.js +4 -4
- package/src/FeatureFlags/feature-flag-factory.js +10 -10
- package/src/FeatureFlags/feature-flag.js +7 -7
- package/src/FeatureFlags/feature-flags-provider.js +50 -50
- package/src/FeatureFlags/get-all-feature-flags.js +1 -1
- package/src/FeatureFlags/get-feature-flag.js +3 -5
- package/src/Feed/feed-provider-factory.js +8 -8
- package/src/Feed/feed-provider.js +15 -15
- package/src/Feed/get-cached-feed.js +2 -2
- package/src/Feed/request-feed-refresh.js +2 -2
- package/src/Feed/subscribe-to-feed-updates.js +2 -2
- package/src/Feed/ui/hide-feed.js +2 -2
- package/src/Feed/ui/show-feed.js +13 -13
- package/src/InAppMessage/display/html-message-to-html.js +11 -12
- package/src/InAppMessage/display/in-app-message-to-html.js +15 -15
- package/src/InAppMessage/display/modal-utils.js +8 -8
- package/src/InAppMessage/in-app-message-factory.js +4 -4
- package/src/InAppMessage/in-app-message-manager.js +38 -38
- package/src/InAppMessage/models/full-screen-message.js +31 -31
- package/src/InAppMessage/models/html-message.js +16 -16
- package/src/InAppMessage/models/in-app-message-button.js +5 -5
- package/src/InAppMessage/models/in-app-message.js +46 -46
- package/src/InAppMessage/models/modal-message.js +30 -30
- package/src/InAppMessage/models/slide-up-message.js +26 -26
- package/src/InAppMessage/ui/show-in-app-message.js +9 -9
- package/src/Push/is-push-blocked.js +2 -2
- package/src/Push/is-push-permission-granted.js +2 -2
- package/src/Push/is-push-supported.js +2 -2
- package/src/Push/push-manager.js +31 -31
- package/src/Push/utils/push-utils.js +9 -9
- package/src/User/user-manager.js +8 -8
- package/src/User/user.js +29 -29
- package/src/common/base-feed.js +15 -14
- package/src/common/base-provider.js +1 -1
- package/src/common/event-logger.js +2 -2
- package/src/common/feed-display.js +32 -32
- package/src/l10n/l10n-manager-factory.js +9 -9
- package/src/managers/auth-manager.js +6 -6
- package/src/managers/braze-instance.js +96 -106
- package/src/managers/device-manager.js +17 -17
- package/src/managers/network-manager.js +27 -27
- package/src/managers/server-config-manager.js +13 -13
- package/src/managers/session-manager.js +8 -8
- package/src/managers/storage-manager-factory.js +7 -7
- package/src/managers/storage-manager.js +104 -104
- package/src/managers/subscription-manager.js +2 -2
- package/src/models/braze-event.js +5 -5
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +1 -1
- package/src/models/push-token.js +1 -1
- package/src/models/server-config.js +6 -6
- package/src/request-controller.js +52 -52
- package/src/triggers/models/custom-event-data.js +1 -1
- package/src/triggers/models/custom-event-property-data.js +6 -6
- package/src/triggers/models/filter-set.js +8 -8
- package/src/triggers/models/filter.js +25 -25
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/purchase-data.js +1 -1
- 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 +14 -14
- package/src/triggers/models/trigger-events.js +1 -1
- package/src/triggers/models/trigger.js +11 -11
- package/src/triggers/triggers-provider.js +38 -38
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/feed-css.js +5 -5
- package/src/ui/js/iam-css.js +4 -4
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +4 -4
- package/src/util/browser-detector.js +14 -14
- package/src/util/client-hints-parser.js +2 -2
- package/src/util/component-utils.js +2 -2
- package/src/util/device-constants.js +4 -5
- package/src/util/dom-utils.js +5 -5
- package/src/util/request-header-utils.js +4 -4
- package/src/util/user-agent-parser.js +10 -15
- package/src/Card/models/banner.js +0 -31
- package/src/ContentCards/log-content-cards-displayed.js +0 -5
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
CONTENT_CARDS_RATE_LIMIT_CAPACITY_DEFAULT as Vt,
|
|
8
8
|
CONTENT_CARDS_RATE_LIMIT_REFILL_RATE_DEFAULT as Gt,
|
|
9
9
|
} from "../common/constants.js";
|
|
10
|
-
export default class
|
|
10
|
+
export default class jt {
|
|
11
11
|
constructor(t) {
|
|
12
12
|
(this.u = t),
|
|
13
13
|
(this.u = t),
|
|
@@ -46,24 +46,24 @@ export default class Mt {
|
|
|
46
46
|
let r = !1;
|
|
47
47
|
null != t.ml.enabled && this.oi() !== t.ml.enabled && (r = !0);
|
|
48
48
|
let n = !1;
|
|
49
|
-
null != t.
|
|
49
|
+
null != t.gi.enabled && this.yi() !== t.gi.enabled && (n = !0),
|
|
50
50
|
(this.rl = t),
|
|
51
|
-
this.u.D(i.k.hl, t.
|
|
52
|
-
s && this.tl.
|
|
53
|
-
r && this.el.
|
|
54
|
-
n && this.sl.
|
|
51
|
+
this.u.D(i.k.hl, t.tt()),
|
|
52
|
+
s && this.tl.Dt(),
|
|
53
|
+
r && this.el.Dt(),
|
|
54
|
+
n && this.sl.Dt();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
Rn(t) {
|
|
59
|
-
const e = this.tl.
|
|
59
|
+
const e = this.tl.It(t);
|
|
60
60
|
return this.il && this.tl.removeSubscription(this.il), (this.il = e), e;
|
|
61
61
|
}
|
|
62
62
|
Ps(t) {
|
|
63
|
-
return this.el.
|
|
63
|
+
return this.el.It(t);
|
|
64
64
|
}
|
|
65
65
|
Ci(t) {
|
|
66
|
-
return this.sl.
|
|
66
|
+
return this.sl.It(t);
|
|
67
67
|
}
|
|
68
68
|
ge(t) {
|
|
69
69
|
return -1 !== this.ll().cl.indexOf(t);
|
|
@@ -97,12 +97,12 @@ export default class Mt {
|
|
|
97
97
|
const t = this.ll().ml.rate_limit;
|
|
98
98
|
return null == t.refill_rate ? Gt : t.refill_rate <= 0 ? -1 : t.refill_rate;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
return this.ll().
|
|
100
|
+
yi() {
|
|
101
|
+
return this.ll().gi.enabled && null == this.Mi()
|
|
102
102
|
? (s.N(r.q.qs, { e: "Missing feature flag refresh_rate_limit." }), !1)
|
|
103
|
-
: this.ll().
|
|
103
|
+
: this.ll().gi.enabled || !1;
|
|
104
104
|
}
|
|
105
105
|
Mi() {
|
|
106
|
-
return this.ll().
|
|
106
|
+
return this.ll().gi.refresh_rate_limit;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { STORAGE_KEYS as i } from "../managers/storage-manager.js";
|
|
2
|
-
import
|
|
2
|
+
import ue from "../models/braze-event.js";
|
|
3
3
|
import _t from "../models/identifier.js";
|
|
4
4
|
import { convertMsToSeconds as h } from "../util/date-utils.js";
|
|
5
5
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
6
6
|
export default class Dt {
|
|
7
7
|
constructor(s, t, i, e) {
|
|
8
8
|
(this.u = s),
|
|
9
|
-
(this.
|
|
10
|
-
(this.
|
|
9
|
+
(this.wt = t),
|
|
10
|
+
(this.yt = i),
|
|
11
11
|
(this.wl = e),
|
|
12
12
|
(this.u = s),
|
|
13
|
-
(this.
|
|
14
|
-
(this.
|
|
13
|
+
(this.wt = t),
|
|
14
|
+
(this.yt = i),
|
|
15
15
|
(this.Sl = 1e3),
|
|
16
16
|
(null == e || isNaN(e)) && (e = 1800),
|
|
17
17
|
e < this.Sl / 1e3 &&
|
|
@@ -26,7 +26,7 @@ export default class Dt {
|
|
|
26
26
|
(this.wl = e);
|
|
27
27
|
}
|
|
28
28
|
jl(s, t) {
|
|
29
|
-
return new
|
|
29
|
+
return new ue(this.wt.getUserId(), r.q.xl, s, t.iu, { d: h(s - t.vl) });
|
|
30
30
|
}
|
|
31
31
|
Yh() {
|
|
32
32
|
const s = this.u.tu(i.eu.Dl);
|
|
@@ -34,7 +34,7 @@ export default class Dt {
|
|
|
34
34
|
}
|
|
35
35
|
El() {
|
|
36
36
|
const s = new Date().valueOf(),
|
|
37
|
-
t = this.
|
|
37
|
+
t = this.yt.dl(),
|
|
38
38
|
e = this.u.v(i.k.zl);
|
|
39
39
|
if (null != e && null == t) return !1;
|
|
40
40
|
let n = !1;
|
|
@@ -61,7 +61,7 @@ export default class Dt {
|
|
|
61
61
|
}
|
|
62
62
|
(n += ". Will expire " + t.valueOf()), r.j.info(n);
|
|
63
63
|
const l = new _t(r.Z.Y(), t);
|
|
64
|
-
this.u.Hl(new
|
|
64
|
+
this.u.Hl(new ue(this.wt.getUserId(), r.q.Wl, s, l.iu)),
|
|
65
65
|
this.u.uu(i.eu.Dl, l);
|
|
66
66
|
return null == this.u.v(i.k.zl) && this.u.D(i.k.zl, s), l.iu;
|
|
67
67
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import J, { STORAGE_KEYS as i } from "./storage-manager.js";
|
|
2
2
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
3
|
-
const
|
|
3
|
+
const Mt = {
|
|
4
4
|
xo: function (e, o = !1) {
|
|
5
5
|
let t = !1;
|
|
6
6
|
try {
|
|
@@ -24,12 +24,12 @@ const Bt = {
|
|
|
24
24
|
} catch (e) {
|
|
25
25
|
r.j.info("Local Storage not supported!");
|
|
26
26
|
}
|
|
27
|
-
const a =
|
|
28
|
-
n = new
|
|
27
|
+
const a = Mt.Ga(),
|
|
28
|
+
n = new J.Ja(e, a && !o, t);
|
|
29
29
|
let c;
|
|
30
|
-
return (c = t ? new
|
|
30
|
+
return (c = t ? new J.Va(e) : new J.Ya()), new J(n, c);
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
Ga: function () {
|
|
33
33
|
return (
|
|
34
34
|
navigator.cookieEnabled ||
|
|
35
35
|
("cookie" in document &&
|
|
@@ -39,4 +39,4 @@ const Bt = {
|
|
|
39
39
|
);
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
export default
|
|
42
|
+
export default Mt;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ue from "../models/braze-event.js";
|
|
2
2
|
import _t from "../models/identifier.js";
|
|
3
3
|
import {
|
|
4
4
|
isArray as p,
|
|
5
5
|
keys as oo,
|
|
6
|
-
validateValueIsFromEnum as
|
|
6
|
+
validateValueIsFromEnum as G,
|
|
7
7
|
values as Pt,
|
|
8
8
|
} from "../util/code-utils.js";
|
|
9
9
|
import r from "../../shared-lib/braze-shared-lib.js";
|
|
10
10
|
import { User } from "../User/index.js";
|
|
11
|
-
import
|
|
11
|
+
import Q from "../util/browser-detector.js";
|
|
12
12
|
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
|
+
Xo: "ab.storage.deviceId",
|
|
17
17
|
Dl: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
19
|
k: {
|
|
20
20
|
Qa: "ab.test",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
Za: "ab.storage.events",
|
|
22
|
+
tE: "ab.storage.attributes",
|
|
23
|
+
eE: "ab.storage.attributes.anonymous_user",
|
|
24
|
+
Ca: "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,76 +29,76 @@ 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
|
+
sE: "ab.storage.triggers",
|
|
33
|
+
rE: "ab.storage.triggers.ts",
|
|
34
34
|
zl: "ab.storage.messagingSessionStart",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
gs: "ab.storage.cc",
|
|
36
|
+
js: "ab.storage.ccLastFullSync",
|
|
37
|
+
Rs: "ab.storage.ccLastCardUpdated",
|
|
38
38
|
Vs: "ab.storage.ccLastClientRequest",
|
|
39
39
|
ci: "ab.storage.ccRateLimitCurrentTokenCount",
|
|
40
40
|
C: "ab.storage.ccClicks",
|
|
41
41
|
K: "ab.storage.ccImpressions",
|
|
42
42
|
G: "ab.storage.ccDismissals",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
oE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
44
|
+
nE: "ab.storage.lastDisplayedTriggerTime",
|
|
45
|
+
iE: "ab.storage.triggerFireInstancesById",
|
|
46
46
|
xh: "ab.storage.signature",
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
zs: "ab.storage.brazeSyncRetryCount",
|
|
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
|
+
aE: "ab.storage.lastReqToEndpoint",
|
|
53
|
+
EE: "ab.storage.requestAttempts",
|
|
54
54
|
rn: "ab.storage.deferredIam",
|
|
55
55
|
},
|
|
56
56
|
re: "ab.optOut",
|
|
57
57
|
};
|
|
58
|
-
export default class
|
|
58
|
+
export default class J {
|
|
59
59
|
constructor(t, e) {
|
|
60
|
-
(this.
|
|
60
|
+
(this.lE = t), (this.SE = e), (this.lE = t), (this.SE = e);
|
|
61
61
|
}
|
|
62
62
|
Jo(t) {
|
|
63
63
|
const e = oo(STORAGE_KEYS.eu),
|
|
64
|
-
s = new
|
|
64
|
+
s = new J.ee(t);
|
|
65
65
|
for (const t of e) s.remove(STORAGE_KEYS.eu[t]);
|
|
66
66
|
}
|
|
67
67
|
uu(t, e) {
|
|
68
68
|
let s = null;
|
|
69
|
-
null != e && e instanceof _t && (s = e.
|
|
69
|
+
null != e && e instanceof _t && (s = e.tt()), this.lE.store(t, s);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
_E(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.lE.jr(t));
|
|
77
77
|
}
|
|
78
78
|
ql(t) {
|
|
79
|
-
this.
|
|
79
|
+
this.lE.remove(t);
|
|
80
80
|
}
|
|
81
81
|
bo(t) {
|
|
82
82
|
let e;
|
|
83
83
|
if (null == t || 0 === t.length) return !1;
|
|
84
84
|
e = p(t) ? t : [t];
|
|
85
|
-
let s = this.
|
|
85
|
+
let s = this.SE.jr(STORAGE_KEYS.k.Za);
|
|
86
86
|
(null != s && p(s)) || (s = []);
|
|
87
|
-
for (let t = 0; t < e.length; t++) s.push(e[t].
|
|
88
|
-
return this.
|
|
87
|
+
for (let t = 0; t < e.length; t++) s.push(e[t].tt());
|
|
88
|
+
return this.SE.store(STORAGE_KEYS.k.Za, s);
|
|
89
89
|
}
|
|
90
90
|
Hl(t) {
|
|
91
91
|
return null != t && this.bo([t]);
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
let t = this.
|
|
95
|
-
this.
|
|
93
|
+
uE() {
|
|
94
|
+
let t = this.SE.jr(STORAGE_KEYS.k.Za);
|
|
95
|
+
this.SE.remove(STORAGE_KEYS.k.Za), null == t && (t = []);
|
|
96
96
|
const e = [];
|
|
97
97
|
let s = !1,
|
|
98
98
|
o = null;
|
|
99
99
|
if (p(t))
|
|
100
100
|
for (let s = 0; s < t.length; s++)
|
|
101
|
-
|
|
101
|
+
ue.cE(t[s]) ? e.push(ue.Yn(t[s])) : (o = s);
|
|
102
102
|
else s = !0;
|
|
103
103
|
if (s || null != o) {
|
|
104
104
|
let n = "Stored events could not be deserialized as Events";
|
|
@@ -111,38 +111,38 @@ export default class O {
|
|
|
111
111
|
typeof t +
|
|
112
112
|
": " +
|
|
113
113
|
JSON.stringify(t)),
|
|
114
|
-
e.push(new
|
|
114
|
+
e.push(new ue(null, r.q.qs, new Date().valueOf(), null, { e: n }));
|
|
115
115
|
}
|
|
116
116
|
return e;
|
|
117
117
|
}
|
|
118
118
|
D(t, e) {
|
|
119
119
|
return (
|
|
120
|
-
!!
|
|
120
|
+
!!G(
|
|
121
121
|
STORAGE_KEYS.k,
|
|
122
122
|
t,
|
|
123
123
|
"StorageManager cannot store object.",
|
|
124
124
|
"STORAGE_KEYS.OBJECTS",
|
|
125
|
-
) && this.
|
|
125
|
+
) && this.SE.store(t, e)
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
v(t) {
|
|
129
129
|
return (
|
|
130
|
-
!!
|
|
130
|
+
!!G(
|
|
131
131
|
STORAGE_KEYS.k,
|
|
132
132
|
t,
|
|
133
133
|
"StorageManager cannot retrieve object.",
|
|
134
134
|
"STORAGE_KEYS.OBJECTS",
|
|
135
|
-
) && this.
|
|
135
|
+
) && this.SE.jr(t)
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
ni(t) {
|
|
139
139
|
return (
|
|
140
|
-
!!
|
|
140
|
+
!!G(
|
|
141
141
|
STORAGE_KEYS.k,
|
|
142
142
|
t,
|
|
143
143
|
"StorageManager cannot remove object.",
|
|
144
144
|
"STORAGE_KEYS.OBJECTS",
|
|
145
|
-
) && (this.
|
|
145
|
+
) && (this.SE.remove(t), !0)
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
clearData() {
|
|
@@ -150,20 +150,20 @@ export default class O {
|
|
|
150
150
|
e = oo(STORAGE_KEYS.k);
|
|
151
151
|
for (let e = 0; e < t.length; e++) {
|
|
152
152
|
const s = t[e];
|
|
153
|
-
this.
|
|
153
|
+
this.lE.remove(STORAGE_KEYS.eu[s]);
|
|
154
154
|
}
|
|
155
155
|
for (let t = 0; t < e.length; t++) {
|
|
156
156
|
const s = e[t];
|
|
157
|
-
this.
|
|
157
|
+
this.SE.remove(STORAGE_KEYS.k[s]);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
return t || STORAGE_KEYS.k.
|
|
160
|
+
TE(t) {
|
|
161
|
+
return t || STORAGE_KEYS.k.eE;
|
|
162
162
|
}
|
|
163
163
|
Ha(t) {
|
|
164
|
-
let e = this.
|
|
164
|
+
let e = this.SE.jr(STORAGE_KEYS.k.tE);
|
|
165
165
|
null == e && (e = {});
|
|
166
|
-
const s = this.
|
|
166
|
+
const s = this.TE(t[User.bu]),
|
|
167
167
|
r = e[s];
|
|
168
168
|
for (const o in t)
|
|
169
169
|
o !== User.bu &&
|
|
@@ -171,9 +171,9 @@ export default class O {
|
|
|
171
171
|
this.mu(t[User.bu], o, t[o]);
|
|
172
172
|
}
|
|
173
173
|
mu(t, e, s) {
|
|
174
|
-
let r = this.
|
|
174
|
+
let r = this.SE.jr(STORAGE_KEYS.k.tE);
|
|
175
175
|
null == r && (r = {});
|
|
176
|
-
const o = this.
|
|
176
|
+
const o = this.TE(t);
|
|
177
177
|
let n = r[o];
|
|
178
178
|
if (
|
|
179
179
|
(null == n && ((n = {}), null != t && (n[User.bu] = t)), e === User.lu)
|
|
@@ -181,51 +181,51 @@ export default class O {
|
|
|
181
181
|
null == n[e] && (n[e] = {});
|
|
182
182
|
for (const t in s) n[e][t] = s[t];
|
|
183
183
|
} else null != s && (n[e] = s);
|
|
184
|
-
return (r[o] = n), this.
|
|
184
|
+
return (r[o] = n), this.SE.store(STORAGE_KEYS.k.tE, r);
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
const t = this.
|
|
188
|
-
this.
|
|
186
|
+
hE() {
|
|
187
|
+
const t = this.SE.jr(STORAGE_KEYS.k.tE);
|
|
188
|
+
this.SE.remove(STORAGE_KEYS.k.tE);
|
|
189
189
|
const e = [];
|
|
190
190
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
191
191
|
return e;
|
|
192
192
|
}
|
|
193
193
|
ou(t) {
|
|
194
|
-
const e = this.
|
|
194
|
+
const e = this.SE.jr(STORAGE_KEYS.k.tE);
|
|
195
195
|
if (null != e) {
|
|
196
|
-
const s = this.
|
|
196
|
+
const s = this.TE(null),
|
|
197
197
|
r = e[s];
|
|
198
198
|
null != r &&
|
|
199
199
|
((e[s] = void 0),
|
|
200
|
-
this.
|
|
200
|
+
this.SE.store(STORAGE_KEYS.k.tE, e),
|
|
201
201
|
(r[User.bu] = t),
|
|
202
202
|
this.Ha(r));
|
|
203
203
|
}
|
|
204
204
|
const s = this.tu(STORAGE_KEYS.eu.Dl);
|
|
205
205
|
let r = null;
|
|
206
206
|
null != s && (r = s.iu);
|
|
207
|
-
const o = this.
|
|
207
|
+
const o = this.uE();
|
|
208
208
|
if (null != o)
|
|
209
209
|
for (let e = 0; e < o.length; e++) {
|
|
210
210
|
const s = o[e];
|
|
211
211
|
null == s.userId && s.sessionId == r && (s.userId = t), this.Hl(s);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
return this.
|
|
214
|
+
AE() {
|
|
215
|
+
return this.SE.RE;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
(
|
|
218
|
+
(J.Va = class {
|
|
219
219
|
constructor(t) {
|
|
220
|
-
(this.cn = t), (this.cn = t), (this.
|
|
220
|
+
(this.cn = t), (this.cn = t), (this.RE = Q.gE() ? 3 : 10);
|
|
221
221
|
}
|
|
222
|
-
|
|
222
|
+
OE(t) {
|
|
223
223
|
return t + "." + this.cn;
|
|
224
224
|
}
|
|
225
225
|
store(t, e) {
|
|
226
226
|
const s = { v: e };
|
|
227
227
|
try {
|
|
228
|
-
return localStorage.setItem(this.
|
|
228
|
+
return localStorage.setItem(this.OE(t), JSON.stringify(s)), !0;
|
|
229
229
|
} catch (t) {
|
|
230
230
|
return r.j.info("Storage failure: " + ei(t)), !1;
|
|
231
231
|
}
|
|
@@ -233,7 +233,7 @@ export default class O {
|
|
|
233
233
|
jr(t) {
|
|
234
234
|
try {
|
|
235
235
|
let e = null;
|
|
236
|
-
const s = localStorage.getItem(this.
|
|
236
|
+
const s = localStorage.getItem(this.OE(t));
|
|
237
237
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
238
238
|
} catch (t) {
|
|
239
239
|
return r.j.info("Storage retrieval failure: " + ei(t)), null;
|
|
@@ -241,30 +241,30 @@ export default class O {
|
|
|
241
241
|
}
|
|
242
242
|
remove(t) {
|
|
243
243
|
try {
|
|
244
|
-
localStorage.removeItem(this.
|
|
244
|
+
localStorage.removeItem(this.OE(t));
|
|
245
245
|
} catch (t) {
|
|
246
246
|
return r.j.info("Storage removal failure: " + ei(t)), !1;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
}),
|
|
250
|
-
(
|
|
250
|
+
(J.Ya = class {
|
|
251
251
|
constructor() {
|
|
252
|
-
(this.
|
|
252
|
+
(this.dE = {}), (this.fE = 5242880), (this.RE = 3);
|
|
253
253
|
}
|
|
254
254
|
store(t, e) {
|
|
255
255
|
const s = { value: e },
|
|
256
|
-
o = this.
|
|
257
|
-
return o > this.
|
|
256
|
+
o = this.bE(e);
|
|
257
|
+
return o > this.fE
|
|
258
258
|
? (r.j.info(
|
|
259
259
|
"Storage failure: object is ≈" +
|
|
260
260
|
o +
|
|
261
261
|
" bytes which is greater than the max of " +
|
|
262
|
-
this.
|
|
262
|
+
this.fE,
|
|
263
263
|
),
|
|
264
264
|
!1)
|
|
265
|
-
: ((this.
|
|
265
|
+
: ((this.dE[t] = s), !0);
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
bE(t) {
|
|
268
268
|
const e = [],
|
|
269
269
|
s = [t];
|
|
270
270
|
let r = 0;
|
|
@@ -282,26 +282,26 @@ export default class O {
|
|
|
282
282
|
return r;
|
|
283
283
|
}
|
|
284
284
|
jr(t) {
|
|
285
|
-
const e = this.
|
|
285
|
+
const e = this.dE[t];
|
|
286
286
|
return null == e ? null : e.value;
|
|
287
287
|
}
|
|
288
288
|
remove(t) {
|
|
289
|
-
this.
|
|
289
|
+
this.dE[t] = null;
|
|
290
290
|
}
|
|
291
291
|
}),
|
|
292
|
-
(
|
|
292
|
+
(J.ee = class {
|
|
293
293
|
constructor(t, e) {
|
|
294
294
|
(this.cn = t),
|
|
295
|
-
(this.
|
|
295
|
+
(this.IE = e),
|
|
296
296
|
(this.cn = t),
|
|
297
|
-
(this.
|
|
298
|
-
(this.
|
|
299
|
-
(this.
|
|
297
|
+
(this.mE = this.KE()),
|
|
298
|
+
(this.YE = 576e3),
|
|
299
|
+
(this.IE = !!e);
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
OE(t) {
|
|
302
302
|
return null != this.cn ? t + "." + this.cn : t;
|
|
303
303
|
}
|
|
304
|
-
|
|
304
|
+
KE() {
|
|
305
305
|
let t = 0,
|
|
306
306
|
e = document.location.hostname;
|
|
307
307
|
const s = e.split("."),
|
|
@@ -318,9 +318,9 @@ export default class O {
|
|
|
318
318
|
}
|
|
319
319
|
ae() {
|
|
320
320
|
const t = new Date();
|
|
321
|
-
return t.setTime(t.getTime() + 60 * this.
|
|
321
|
+
return t.setTime(t.getTime() + 60 * this.YE * 1e3), t.getFullYear();
|
|
322
322
|
}
|
|
323
|
-
|
|
323
|
+
NE() {
|
|
324
324
|
const t = Pt(STORAGE_KEYS.eu),
|
|
325
325
|
e = document.cookie.split(";");
|
|
326
326
|
for (let s = 0; s < e.length; s++) {
|
|
@@ -334,19 +334,19 @@ export default class O {
|
|
|
334
334
|
}
|
|
335
335
|
if (o) {
|
|
336
336
|
const t = r.split("=")[0];
|
|
337
|
-
-1 === t.indexOf("." + this.cn) && this.
|
|
337
|
+
-1 === t.indexOf("." + this.cn) && this.DE(t);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
store(t, e) {
|
|
342
|
-
this.
|
|
342
|
+
this.NE();
|
|
343
343
|
const s = new Date();
|
|
344
|
-
s.setTime(s.getTime() + 60 * this.
|
|
344
|
+
s.setTime(s.getTime() + 60 * this.YE * 1e3);
|
|
345
345
|
const o = "expires=" + s.toUTCString(),
|
|
346
|
-
n = "domain=" + this.
|
|
346
|
+
n = "domain=" + this.mE;
|
|
347
347
|
let i;
|
|
348
|
-
i = this.
|
|
349
|
-
const a = this.
|
|
348
|
+
i = this.IE ? e : encodeURIComponent(JSON.stringify(e));
|
|
349
|
+
const a = this.OE(t) + "=" + i + ";" + o + ";" + n + ";path=/";
|
|
350
350
|
return a.length >= 4093
|
|
351
351
|
? (r.j.info(
|
|
352
352
|
"Storage failure: string is " +
|
|
@@ -358,7 +358,7 @@ export default class O {
|
|
|
358
358
|
}
|
|
359
359
|
jr(t) {
|
|
360
360
|
const e = [],
|
|
361
|
-
s = this.
|
|
361
|
+
s = this.OE(t) + "=",
|
|
362
362
|
o = document.cookie.split(";");
|
|
363
363
|
for (let n = 0; n < o.length; n++) {
|
|
364
364
|
let i = o[n];
|
|
@@ -366,7 +366,7 @@ export default class O {
|
|
|
366
366
|
if (0 === i.indexOf(s))
|
|
367
367
|
try {
|
|
368
368
|
let t;
|
|
369
|
-
(t = this.
|
|
369
|
+
(t = this.IE
|
|
370
370
|
? i.substring(s.length, i.length)
|
|
371
371
|
: JSON.parse(
|
|
372
372
|
decodeURIComponent(i.substring(s.length, i.length)),
|
|
@@ -383,37 +383,37 @@ export default class O {
|
|
|
383
383
|
return e.length > 0 ? e[e.length - 1] : null;
|
|
384
384
|
}
|
|
385
385
|
remove(t) {
|
|
386
|
-
this.
|
|
386
|
+
this.DE(this.OE(t));
|
|
387
387
|
}
|
|
388
|
-
|
|
388
|
+
DE(t) {
|
|
389
389
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
390
390
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
391
|
-
const s = e + ";domain=" + this.
|
|
391
|
+
const s = e + ";domain=" + this.mE;
|
|
392
392
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
393
393
|
}
|
|
394
394
|
}),
|
|
395
|
-
(
|
|
395
|
+
(J.Ja = class {
|
|
396
396
|
constructor(t, e, s) {
|
|
397
397
|
(this.cn = t),
|
|
398
|
-
(this.
|
|
399
|
-
e && this.
|
|
400
|
-
s && this.
|
|
401
|
-
this.
|
|
398
|
+
(this.CE = []),
|
|
399
|
+
e && this.CE.push(new J.ee(t)),
|
|
400
|
+
s && this.CE.push(new J.Va(t)),
|
|
401
|
+
this.CE.push(new J.Ya());
|
|
402
402
|
}
|
|
403
403
|
store(t, e) {
|
|
404
404
|
let s = !0;
|
|
405
|
-
for (let r = 0; r < this.
|
|
405
|
+
for (let r = 0; r < this.CE.length; r++) s = this.CE[r].store(t, e) && s;
|
|
406
406
|
return s;
|
|
407
407
|
}
|
|
408
408
|
jr(t) {
|
|
409
|
-
for (let e = 0; e < this.
|
|
410
|
-
const s = this.
|
|
409
|
+
for (let e = 0; e < this.CE.length; e++) {
|
|
410
|
+
const s = this.CE[e].jr(t);
|
|
411
411
|
if (null != s) return s;
|
|
412
412
|
}
|
|
413
413
|
return null;
|
|
414
414
|
}
|
|
415
415
|
remove(t) {
|
|
416
|
-
new
|
|
417
|
-
for (let e = 0; e < this.
|
|
416
|
+
new J.ee(this.cn).remove(t);
|
|
417
|
+
for (let e = 0; e < this.CE.length; e++) this.CE[e].remove(t);
|
|
418
418
|
}
|
|
419
419
|
});
|
|
@@ -3,7 +3,7 @@ export default class E {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
this.Ve = {};
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
It(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
8
|
const i = r.Z.Y();
|
|
9
9
|
return (this.Ve[i] = t), i;
|
|
@@ -17,7 +17,7 @@ export default class E {
|
|
|
17
17
|
tc() {
|
|
18
18
|
return Object.keys(this.Ve).length;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
Dt(t) {
|
|
21
21
|
const i = [];
|
|
22
22
|
for (const r in this.Ve) {
|
|
23
23
|
const s = this.Ve[r];
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
convertMsToSeconds as h,
|
|
4
4
|
timestampOrNow as Jt,
|
|
5
5
|
} from "../util/date-utils.js";
|
|
6
|
-
export default class
|
|
6
|
+
export default class ue {
|
|
7
7
|
constructor(t, i, s, r, e) {
|
|
8
8
|
(this.userId = t),
|
|
9
9
|
(this.type = i),
|
|
@@ -26,7 +26,7 @@ export default class be {
|
|
|
26
26
|
};
|
|
27
27
|
return null != this.userId && (t.user_id = this.userId), t;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
tt() {
|
|
30
30
|
return {
|
|
31
31
|
u: this.userId,
|
|
32
32
|
t: this.type,
|
|
@@ -36,12 +36,12 @@ export default class be {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
static fromJson(t) {
|
|
39
|
-
return new
|
|
39
|
+
return new ue(t.user_id, t.name, t.time, t.session_id, t.data);
|
|
40
40
|
}
|
|
41
|
-
static
|
|
41
|
+
static cE(t) {
|
|
42
42
|
return null != t && Nt(t) && null != t.t && "" !== t.t;
|
|
43
43
|
}
|
|
44
44
|
static Yn(t) {
|
|
45
|
-
return new
|
|
45
|
+
return new ue(t.u, t.t, t.ts, t.s, t.d);
|
|
46
46
|
}
|
|
47
47
|
}
|
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.Zo && (s.browser_version = this.Zo),
|
|
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),
|