@braze/web-sdk 5.0.1 → 5.1.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/README.md +1 -1
- package/index.d.ts +10 -5
- package/package.json +1 -1
- package/shared-lib/encoding-utils.js +3 -3
- package/shared-lib/event-types.js +29 -29
- package/shared-lib/guid.js +3 -3
- package/shared-lib/index.js +6 -0
- package/shared-lib/indexed-db-adapter.js +70 -70
- package/shared-lib/logger.js +18 -18
- package/shared-lib/supported-options.js +21 -21
- package/src/Card/card-manager.js +43 -45
- package/src/Card/display/card-display.js +60 -60
- package/src/Card/log-card-click.js +4 -4
- package/src/Card/log-card-dismissal.js +2 -3
- package/src/Card/log-card-impressions.js +7 -7
- package/src/Card/models/captioned-image.js +21 -21
- package/src/Card/models/card.js +73 -73
- package/src/Card/models/classic-card.js +21 -21
- package/src/Card/models/control-card.js +11 -11
- package/src/Card/models/image-only.js +19 -19
- package/src/Card/util/card-factory.js +68 -68
- package/src/ContentCards/content-cards-provider-factory.js +3 -3
- package/src/ContentCards/content-cards-provider.js +255 -245
- package/src/ContentCards/content-cards.js +2 -2
- 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 +6 -6
- package/src/ContentCards/ui/hide-content-cards.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +24 -24
- package/src/ContentCards/ui/toggle-content-cards.js +1 -1
- package/src/Core/add-sdk-metadata.js +21 -19
- package/src/Core/change-user.js +10 -10
- package/src/Core/destroy.js +2 -2
- package/src/Core/disable-sdk.js +11 -11
- package/src/Core/enable-sdk.js +7 -7
- package/src/Core/get-device-id.js +6 -6
- package/src/Core/get-user.js +1 -1
- package/src/Core/handle-braze-action.js +41 -41
- package/src/Core/is-disabled.js +2 -2
- package/src/Core/log-custom-event.js +15 -15
- package/src/Core/log-purchase.js +31 -37
- package/src/Core/open-session.js +12 -12
- package/src/Core/remove-all-subscriptions.js +1 -1
- package/src/Core/remove-subscription.js +1 -1
- package/src/Core/request-immediate-data-flush.js +1 -1
- package/src/Core/set-logger.js +2 -2
- package/src/Core/set-sdk-authentication-signature.js +3 -3
- package/src/Core/subscribe-to-sdk-authentication-failures.js +6 -4
- package/src/Core/toggle-logging.js +2 -2
- package/src/Core/wipe-data.js +9 -9
- package/src/FeatureFlags/feature-flag-factory.js +12 -12
- package/src/FeatureFlags/feature-flag.js +10 -10
- package/src/FeatureFlags/feature-flags-provider-factory.js +3 -2
- package/src/FeatureFlags/feature-flags-provider.js +108 -80
- package/src/FeatureFlags/get-all-feature-flags.js +5 -5
- package/src/FeatureFlags/get-feature-flag.js +6 -6
- package/src/FeatureFlags/log-feature-flag-impression.js +15 -13
- package/src/FeatureFlags/refresh-feature-flags.js +1 -1
- package/src/FeatureFlags/subscribe-to-feature-flags-updates.js +7 -4
- package/src/Feed/feed-provider-factory.js +2 -2
- package/src/Feed/feed-provider.js +44 -44
- package/src/Feed/feed.js +1 -1
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/log-feed-displayed.js +4 -4
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/hide-feed.js +1 -1
- package/src/Feed/ui/show-feed.js +28 -28
- package/src/Feed/ui/toggle-feed.js +1 -1
- package/src/InAppMessage/defer-in-app-message.js +5 -5
- package/src/InAppMessage/display/html-message-to-html.js +54 -54
- package/src/InAppMessage/display/in-app-message-to-html.js +79 -79
- package/src/InAppMessage/display/modal-utils.js +8 -8
- package/src/InAppMessage/get-deferred-in-app-message.js +1 -1
- package/src/InAppMessage/in-app-message-factory.js +49 -49
- package/src/InAppMessage/in-app-message-manager-factory.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +143 -138
- package/src/InAppMessage/log-in-app-message-button-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-click.js +9 -9
- package/src/InAppMessage/log-in-app-message-html-click.js +12 -12
- package/src/InAppMessage/log-in-app-message-impression.js +6 -6
- package/src/InAppMessage/models/full-screen-message.js +33 -33
- package/src/InAppMessage/models/html-message.js +20 -20
- package/src/InAppMessage/models/in-app-message-button.js +6 -6
- package/src/InAppMessage/models/in-app-message.js +99 -99
- package/src/InAppMessage/models/modal-message.js +32 -32
- package/src/InAppMessage/models/slide-up-message.js +28 -28
- package/src/InAppMessage/models/templated-in-app-message.js +8 -8
- package/src/InAppMessage/subscribe-to-in-app-message.js +2 -2
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +4 -4
- package/src/InAppMessage/ui/show-in-app-message.js +81 -81
- package/src/Push/is-push-blocked.js +1 -1
- package/src/Push/is-push-permission-granted.js +1 -1
- package/src/Push/is-push-supported.js +1 -1
- package/src/Push/push-manager-factory.js +5 -5
- package/src/Push/push-manager.js +176 -173
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/Push/utils/push-utils.js +4 -4
- package/src/User/user-manager.js +29 -29
- package/src/User/user.js +72 -74
- package/src/common/base-feed.js +7 -7
- package/src/common/base-provider.js +1 -1
- package/src/common/constants.js +2 -0
- package/src/common/event-logger.js +21 -18
- package/src/common/feed-display.js +44 -44
- package/src/l10n/l10n-manager-factory.js +3 -3
- package/src/l10n/l10n-manager.js +7 -7
- package/src/managers/auth-manager.js +32 -32
- package/src/managers/braze-instance.js +188 -190
- package/src/managers/device-manager.js +28 -28
- package/src/managers/network-manager.js +189 -138
- package/src/managers/server-config-manager.js +69 -53
- package/src/managers/session-manager.js +34 -30
- package/src/managers/storage-manager-factory.js +16 -16
- package/src/managers/storage-manager.js +178 -163
- package/src/managers/subscription-manager.js +12 -12
- package/src/models/backend-errors.js +5 -5
- package/src/models/braze-event.js +4 -4
- package/src/models/device.js +2 -2
- package/src/models/identifier.js +34 -14
- package/src/models/push-token.js +8 -8
- package/src/models/request-result.js +3 -3
- package/src/models/server-config.js +32 -23
- package/src/request-controller.js +186 -179
- package/src/triggers/models/custom-event-data.js +7 -7
- package/src/triggers/models/custom-event-property-data.js +10 -10
- package/src/triggers/models/filter-set.js +13 -13
- package/src/triggers/models/filter.js +45 -45
- package/src/triggers/models/in-app-message-click-data.js +12 -12
- package/src/triggers/models/purchase-data.js +2 -2
- package/src/triggers/models/purchase-property-data.js +10 -10
- package/src/triggers/models/push-click-data.js +7 -7
- package/src/triggers/models/trigger-condition.js +57 -59
- package/src/triggers/models/trigger-events.js +4 -4
- package/src/triggers/models/trigger.js +38 -38
- package/src/triggers/triggers-provider-factory.js +4 -4
- package/src/triggers/triggers-provider.js +127 -130
- package/src/ui/js/attach-css.js +2 -2
- package/src/ui/js/iam-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +3 -3
- package/src/util/braze-actions.js +35 -35
- package/src/util/browser-detector.js +21 -21
- package/src/util/client-hints-parser.js +8 -8
- package/src/util/code-utils.js +2 -2
- package/src/util/component-utils.js +1 -1
- package/src/util/deprecation-utils.js +4 -4
- package/src/util/device-constants.js +1 -1
- package/src/util/dom-utils.js +18 -18
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +18 -18
- package/src/util/request-header-utils.js +39 -37
- package/src/util/string-utils.js +10 -10
- package/src/util/user-agent-parser.js +18 -18
- package/src/util/validation-utils.js +37 -39
- package/src/util/window-utils.js +3 -3
- package/shared-lib/braze-shared-lib.js +0 -8
|
@@ -1,151 +1,168 @@
|
|
|
1
1
|
import ue from "../models/braze-event.js";
|
|
2
2
|
import _t from "../models/identifier.js";
|
|
3
3
|
import {
|
|
4
|
-
isArray as
|
|
5
|
-
keys as
|
|
6
|
-
validateValueIsFromEnum as
|
|
4
|
+
isArray as j,
|
|
5
|
+
keys as to,
|
|
6
|
+
validateValueIsFromEnum as J,
|
|
7
7
|
values as Pt,
|
|
8
8
|
} from "../util/code-utils.js";
|
|
9
|
-
import r from "../../shared-lib/
|
|
9
|
+
import { logger as r, EventTypes as i } from "../../shared-lib/index.js";
|
|
10
10
|
import { User } from "../User/index.js";
|
|
11
|
-
import
|
|
12
|
-
import { getErrorMessage as
|
|
11
|
+
import X from "../util/browser-detector.js";
|
|
12
|
+
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
|
-
|
|
16
|
+
Ta: "ab.storage.deviceId",
|
|
17
17
|
Dl: "ab.storage.sessionId",
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
C: {
|
|
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
|
-
|
|
30
|
-
|
|
24
|
+
Ja: "ab.storage.device",
|
|
25
|
+
Na: "ab.storage.sdk_metadata",
|
|
26
|
+
$a: "ab.storage.session_id_for_cached_metadata",
|
|
27
|
+
zn: "ab.storage.pushToken",
|
|
28
|
+
Hi: "ab.storage.newsFeed",
|
|
29
|
+
Ji: "ab.storage.lastNewsFeedRefresh",
|
|
30
|
+
J: "ab.storage.cardImpressions",
|
|
31
31
|
hl: "ab.storage.serverConfig",
|
|
32
32
|
rE: "ab.storage.triggers",
|
|
33
33
|
oE: "ab.storage.triggers.ts",
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
Gl: "ab.storage.messagingSessionStart",
|
|
35
|
+
Cs: "ab.storage.cc",
|
|
36
|
+
gs: "ab.storage.ccLastFullSync",
|
|
37
|
+
ys: "ab.storage.ccLastCardUpdated",
|
|
38
|
+
Ks: "ab.storage.ccLastClientRequest",
|
|
39
|
+
ai: "ab.storage.ccRateLimitCurrentTokenCount",
|
|
40
|
+
Ru: "ab.storage.globalRateLimitCurrentTokenCount",
|
|
41
|
+
v: "ab.storage.ccClicks",
|
|
42
|
+
H: "ab.storage.ccImpressions",
|
|
43
|
+
A: "ab.storage.ccDismissals",
|
|
43
44
|
nE: "ab.storage.lastDisplayedTriggerTimesById",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
aE: "ab.storage.lastDisplayedTriggerTime",
|
|
46
|
+
iE: "ab.storage.triggerFireInstancesById",
|
|
47
|
+
jh: "ab.storage.signature",
|
|
48
|
+
As: "ab.storage.brazeSyncRetryCount",
|
|
49
|
+
Ds: "ab.storage.sdkVersion",
|
|
50
|
+
Ti: "ab.storage.ff",
|
|
51
|
+
Ii: "ab.storage.ffImpressions",
|
|
52
|
+
Bi: "ab.storage.ffLastRefreshAt",
|
|
53
|
+
Ui: "ab.storage.ff.sessionId",
|
|
52
54
|
EE: "ab.storage.lastReqToEndpoint",
|
|
53
55
|
lE: "ab.storage.requestAttempts",
|
|
54
|
-
|
|
56
|
+
Wr: "ab.storage.deferredIam",
|
|
57
|
+
fu: "ab.storage.lastSdkReq",
|
|
55
58
|
},
|
|
56
|
-
|
|
59
|
+
se: "ab.optOut",
|
|
57
60
|
};
|
|
58
|
-
export default class
|
|
61
|
+
export default class Q {
|
|
59
62
|
constructor(t, e) {
|
|
60
63
|
(this.SE = t), (this._E = e), (this.SE = t), (this._E = e);
|
|
61
64
|
}
|
|
62
|
-
|
|
63
|
-
const e =
|
|
64
|
-
s = new
|
|
65
|
-
for (const t of e) s.remove(STORAGE_KEYS.
|
|
65
|
+
Vh(t) {
|
|
66
|
+
const e = to(STORAGE_KEYS.iu),
|
|
67
|
+
s = new Q.ee(t);
|
|
68
|
+
for (const t of e) s.remove(STORAGE_KEYS.iu[t]);
|
|
66
69
|
}
|
|
67
70
|
uu(t, e) {
|
|
68
71
|
let s = null;
|
|
69
|
-
null != e && e instanceof _t && (s = e.
|
|
72
|
+
null != e && e instanceof _t && (s = e.Y()), this.SE.store(t, s);
|
|
70
73
|
}
|
|
71
74
|
uE(t) {
|
|
72
75
|
const e = this.tu(t);
|
|
73
|
-
null != e && ((e.
|
|
76
|
+
null != e && ((e.Hl = new Date().valueOf()), this.uu(t, e));
|
|
74
77
|
}
|
|
75
78
|
tu(t) {
|
|
76
|
-
|
|
79
|
+
const e = this.SE.br(t),
|
|
80
|
+
s = ((t) => {
|
|
81
|
+
let e;
|
|
82
|
+
try {
|
|
83
|
+
e = JSON.parse(t);
|
|
84
|
+
} catch (t) {
|
|
85
|
+
e = null;
|
|
86
|
+
}
|
|
87
|
+
return e;
|
|
88
|
+
})(e);
|
|
89
|
+
let r;
|
|
90
|
+
return (
|
|
91
|
+
s ? ((r = _t.En(s) || null), r && this.uu(t, r)) : (r = _t.En(e) || null),
|
|
92
|
+
r
|
|
93
|
+
);
|
|
77
94
|
}
|
|
78
|
-
|
|
95
|
+
yl(t) {
|
|
79
96
|
this.SE.remove(t);
|
|
80
97
|
}
|
|
81
|
-
|
|
82
|
-
const t =
|
|
98
|
+
Kh() {
|
|
99
|
+
const t = to(STORAGE_KEYS.iu);
|
|
83
100
|
let e;
|
|
84
101
|
for (const s of t)
|
|
85
|
-
(e = this.tu(STORAGE_KEYS.
|
|
86
|
-
null != e && this.uu(STORAGE_KEYS.
|
|
102
|
+
(e = this.tu(STORAGE_KEYS.iu[s])),
|
|
103
|
+
null != e && this.uu(STORAGE_KEYS.iu[s], e);
|
|
87
104
|
}
|
|
88
|
-
|
|
105
|
+
zo(t) {
|
|
89
106
|
let e;
|
|
90
107
|
if (null == t || 0 === t.length) return !1;
|
|
91
|
-
e =
|
|
92
|
-
let s = this._E.
|
|
93
|
-
(null != s &&
|
|
94
|
-
for (let t = 0; t < e.length; t++) s.push(e[t].
|
|
95
|
-
return this._E.store(STORAGE_KEYS.
|
|
108
|
+
e = j(t) ? t : [t];
|
|
109
|
+
let s = this._E.br(STORAGE_KEYS.C.tE);
|
|
110
|
+
(null != s && j(s)) || (s = []);
|
|
111
|
+
for (let t = 0; t < e.length; t++) s.push(e[t].Y());
|
|
112
|
+
return this._E.store(STORAGE_KEYS.C.tE, s);
|
|
96
113
|
}
|
|
97
|
-
|
|
98
|
-
return null != t && this.
|
|
114
|
+
Wl(t) {
|
|
115
|
+
return null != t && this.zo([t]);
|
|
99
116
|
}
|
|
100
|
-
|
|
101
|
-
let t = this._E.
|
|
102
|
-
this._E.remove(STORAGE_KEYS.
|
|
117
|
+
TE() {
|
|
118
|
+
let t = this._E.br(STORAGE_KEYS.C.tE);
|
|
119
|
+
this._E.remove(STORAGE_KEYS.C.tE), null == t && (t = []);
|
|
103
120
|
const e = [];
|
|
104
121
|
let s = !1,
|
|
105
|
-
|
|
106
|
-
if (
|
|
122
|
+
r = null;
|
|
123
|
+
if (j(t))
|
|
107
124
|
for (let s = 0; s < t.length; s++)
|
|
108
|
-
ue.
|
|
125
|
+
ue.cE(t[s]) ? e.push(ue.En(t[s])) : (r = s);
|
|
109
126
|
else s = !0;
|
|
110
|
-
if (s || null !=
|
|
111
|
-
let
|
|
127
|
+
if (s || null != r) {
|
|
128
|
+
let o = "Stored events could not be deserialized as Events";
|
|
112
129
|
s &&
|
|
113
|
-
(
|
|
114
|
-
null !=
|
|
115
|
-
(
|
|
116
|
-
(
|
|
130
|
+
(o += ", was " + Object.prototype.toString.call(t) + " not an array"),
|
|
131
|
+
null != r &&
|
|
132
|
+
(o += ", value at index " + r + " does not look like an event"),
|
|
133
|
+
(o +=
|
|
117
134
|
", serialized values were of type " +
|
|
118
135
|
typeof t +
|
|
119
136
|
": " +
|
|
120
137
|
JSON.stringify(t)),
|
|
121
|
-
e.push(new ue(null,
|
|
138
|
+
e.push(new ue(null, i.Ms, new Date().valueOf(), null, { e: o }));
|
|
122
139
|
}
|
|
123
140
|
return e;
|
|
124
141
|
}
|
|
125
|
-
|
|
142
|
+
k(t, e) {
|
|
126
143
|
return (
|
|
127
|
-
!!
|
|
128
|
-
STORAGE_KEYS.
|
|
144
|
+
!!J(
|
|
145
|
+
STORAGE_KEYS.C,
|
|
129
146
|
t,
|
|
130
147
|
"StorageManager cannot store object.",
|
|
131
148
|
"STORAGE_KEYS.OBJECTS",
|
|
132
149
|
) && this._E.store(t, e)
|
|
133
150
|
);
|
|
134
151
|
}
|
|
135
|
-
|
|
152
|
+
j(t) {
|
|
136
153
|
return (
|
|
137
|
-
!!
|
|
138
|
-
STORAGE_KEYS.
|
|
154
|
+
!!J(
|
|
155
|
+
STORAGE_KEYS.C,
|
|
139
156
|
t,
|
|
140
157
|
"StorageManager cannot retrieve object.",
|
|
141
158
|
"STORAGE_KEYS.OBJECTS",
|
|
142
|
-
) && this._E.
|
|
159
|
+
) && this._E.br(t)
|
|
143
160
|
);
|
|
144
161
|
}
|
|
145
|
-
|
|
162
|
+
hi(t) {
|
|
146
163
|
return (
|
|
147
|
-
!!
|
|
148
|
-
STORAGE_KEYS.
|
|
164
|
+
!!J(
|
|
165
|
+
STORAGE_KEYS.C,
|
|
149
166
|
t,
|
|
150
167
|
"StorageManager cannot remove object.",
|
|
151
168
|
"STORAGE_KEYS.OBJECTS",
|
|
@@ -153,125 +170,125 @@ export default class J {
|
|
|
153
170
|
);
|
|
154
171
|
}
|
|
155
172
|
clearData() {
|
|
156
|
-
const t =
|
|
157
|
-
e =
|
|
173
|
+
const t = to(STORAGE_KEYS.iu),
|
|
174
|
+
e = to(STORAGE_KEYS.C);
|
|
158
175
|
for (let e = 0; e < t.length; e++) {
|
|
159
176
|
const s = t[e];
|
|
160
|
-
this.SE.remove(STORAGE_KEYS.
|
|
177
|
+
this.SE.remove(STORAGE_KEYS.iu[s]);
|
|
161
178
|
}
|
|
162
179
|
for (let t = 0; t < e.length; t++) {
|
|
163
180
|
const s = e[t];
|
|
164
|
-
this._E.remove(STORAGE_KEYS.
|
|
181
|
+
this._E.remove(STORAGE_KEYS.C[s]);
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
184
|
hE(t) {
|
|
168
|
-
return t || STORAGE_KEYS.
|
|
185
|
+
return t || STORAGE_KEYS.C.sE;
|
|
169
186
|
}
|
|
170
|
-
|
|
171
|
-
let e = this._E.
|
|
187
|
+
Va(t) {
|
|
188
|
+
let e = this._E.br(STORAGE_KEYS.C.eE);
|
|
172
189
|
null == e && (e = {});
|
|
173
|
-
const s = this.hE(t[User.
|
|
190
|
+
const s = this.hE(t[User.Qn]),
|
|
174
191
|
r = e[s];
|
|
175
192
|
for (const o in t)
|
|
176
|
-
o !== User.
|
|
193
|
+
o !== User.Qn &&
|
|
177
194
|
(null == e[s] || (r && null == r[o])) &&
|
|
178
|
-
this.mu(t[User.
|
|
195
|
+
this.mu(t[User.Qn], o, t[o]);
|
|
179
196
|
}
|
|
180
197
|
mu(t, e, s) {
|
|
181
|
-
let r = this._E.
|
|
198
|
+
let r = this._E.br(STORAGE_KEYS.C.eE);
|
|
182
199
|
null == r && (r = {});
|
|
183
200
|
const o = this.hE(t);
|
|
184
201
|
let n = r[o];
|
|
185
202
|
if (
|
|
186
|
-
(null == n && ((n = {}), null != t && (n[User.
|
|
203
|
+
(null == n && ((n = {}), null != t && (n[User.Qn] = t)), e === User.lu)
|
|
187
204
|
) {
|
|
188
205
|
null == n[e] && (n[e] = {});
|
|
189
206
|
for (const t in s) n[e][t] = s[t];
|
|
190
207
|
} else n[e] = s;
|
|
191
|
-
return (r[o] = n), this._E.store(STORAGE_KEYS.
|
|
208
|
+
return (r[o] = n), this._E.store(STORAGE_KEYS.C.eE, r);
|
|
192
209
|
}
|
|
193
210
|
AE() {
|
|
194
|
-
const t = this._E.
|
|
195
|
-
this._E.remove(STORAGE_KEYS.
|
|
211
|
+
const t = this._E.br(STORAGE_KEYS.C.eE);
|
|
212
|
+
this._E.remove(STORAGE_KEYS.C.eE);
|
|
196
213
|
const e = [];
|
|
197
214
|
for (const s in t) null != t[s] && e.push(t[s]);
|
|
198
215
|
return e;
|
|
199
216
|
}
|
|
200
|
-
|
|
201
|
-
const e = this._E.
|
|
217
|
+
ru(t) {
|
|
218
|
+
const e = this._E.br(STORAGE_KEYS.C.eE);
|
|
202
219
|
if (null != e) {
|
|
203
220
|
const s = this.hE(null),
|
|
204
221
|
r = e[s];
|
|
205
222
|
null != r &&
|
|
206
223
|
((e[s] = void 0),
|
|
207
|
-
this._E.store(STORAGE_KEYS.
|
|
208
|
-
(r[User.
|
|
209
|
-
this.
|
|
224
|
+
this._E.store(STORAGE_KEYS.C.eE, e),
|
|
225
|
+
(r[User.Qn] = t),
|
|
226
|
+
this.Va(r));
|
|
210
227
|
}
|
|
211
|
-
const s = this.tu(STORAGE_KEYS.
|
|
228
|
+
const s = this.tu(STORAGE_KEYS.iu.Dl);
|
|
212
229
|
let r = null;
|
|
213
|
-
null != s && (r = s.
|
|
214
|
-
const o = this.
|
|
230
|
+
null != s && (r = s.eu);
|
|
231
|
+
const o = this.TE();
|
|
215
232
|
if (null != o)
|
|
216
233
|
for (let e = 0; e < o.length; e++) {
|
|
217
234
|
const s = o[e];
|
|
218
|
-
null == s.userId && s.sessionId == r && (s.userId = t), this.
|
|
235
|
+
null == s.userId && s.sessionId == r && (s.userId = t), this.Wl(s);
|
|
219
236
|
}
|
|
220
237
|
}
|
|
221
238
|
RE() {
|
|
222
|
-
return this._E.
|
|
239
|
+
return this._E.gE;
|
|
223
240
|
}
|
|
224
241
|
}
|
|
225
|
-
(
|
|
242
|
+
(Q.rc = class {
|
|
226
243
|
constructor(t) {
|
|
227
|
-
(this.
|
|
244
|
+
(this.an = t), (this.an = t), (this.gE = X.OE() ? 3 : 10);
|
|
228
245
|
}
|
|
229
246
|
dE(t) {
|
|
230
|
-
return t + "." + this.
|
|
247
|
+
return t + "." + this.an;
|
|
231
248
|
}
|
|
232
249
|
store(t, e) {
|
|
233
250
|
const s = { v: e };
|
|
234
251
|
try {
|
|
235
252
|
return localStorage.setItem(this.dE(t), JSON.stringify(s)), !0;
|
|
236
253
|
} catch (t) {
|
|
237
|
-
return r.
|
|
254
|
+
return r.info("Storage failure: " + si(t)), !1;
|
|
238
255
|
}
|
|
239
256
|
}
|
|
240
|
-
|
|
257
|
+
br(t) {
|
|
241
258
|
try {
|
|
242
259
|
let e = null;
|
|
243
260
|
const s = localStorage.getItem(this.dE(t));
|
|
244
261
|
return null != s && (e = JSON.parse(s)), null == e ? null : e.v;
|
|
245
262
|
} catch (t) {
|
|
246
|
-
return r.
|
|
263
|
+
return r.info("Storage retrieval failure: " + si(t)), null;
|
|
247
264
|
}
|
|
248
265
|
}
|
|
249
266
|
remove(t) {
|
|
250
267
|
try {
|
|
251
268
|
localStorage.removeItem(this.dE(t));
|
|
252
269
|
} catch (t) {
|
|
253
|
-
return r.
|
|
270
|
+
return r.info("Storage removal failure: " + si(t)), !1;
|
|
254
271
|
}
|
|
255
272
|
}
|
|
256
273
|
}),
|
|
257
|
-
(
|
|
274
|
+
(Q.ac = class {
|
|
258
275
|
constructor() {
|
|
259
|
-
(this.fE = {}), (this.
|
|
276
|
+
(this.fE = {}), (this.IE = 5242880), (this.gE = 3);
|
|
260
277
|
}
|
|
261
278
|
store(t, e) {
|
|
262
279
|
const s = { value: e },
|
|
263
|
-
o = this.
|
|
264
|
-
return o > this.
|
|
265
|
-
? (r.
|
|
280
|
+
o = this.bE(e);
|
|
281
|
+
return o > this.IE
|
|
282
|
+
? (r.info(
|
|
266
283
|
"Storage failure: object is ≈" +
|
|
267
284
|
o +
|
|
268
285
|
" bytes which is greater than the max of " +
|
|
269
|
-
this.
|
|
286
|
+
this.IE,
|
|
270
287
|
),
|
|
271
288
|
!1)
|
|
272
289
|
: ((this.fE[t] = s), !0);
|
|
273
290
|
}
|
|
274
|
-
|
|
291
|
+
bE(t) {
|
|
275
292
|
const e = [],
|
|
276
293
|
s = [t];
|
|
277
294
|
let r = 0;
|
|
@@ -288,7 +305,7 @@ export default class J {
|
|
|
288
305
|
}
|
|
289
306
|
return r;
|
|
290
307
|
}
|
|
291
|
-
|
|
308
|
+
br(t) {
|
|
292
309
|
const e = this.fE[t];
|
|
293
310
|
return null == e ? null : e.value;
|
|
294
311
|
}
|
|
@@ -296,17 +313,17 @@ export default class J {
|
|
|
296
313
|
this.fE[t] = null;
|
|
297
314
|
}
|
|
298
315
|
}),
|
|
299
|
-
(
|
|
316
|
+
(Q.ee = class {
|
|
300
317
|
constructor(t, e) {
|
|
301
|
-
(this.
|
|
302
|
-
(this.
|
|
303
|
-
(this.
|
|
304
|
-
(this.
|
|
318
|
+
(this.an = t),
|
|
319
|
+
(this.KE = e),
|
|
320
|
+
(this.an = t),
|
|
321
|
+
(this.mE = this.YE()),
|
|
305
322
|
(this.NE = 576e3),
|
|
306
|
-
(this.
|
|
323
|
+
(this.KE = !!e);
|
|
307
324
|
}
|
|
308
325
|
dE(t) {
|
|
309
|
-
return null != this.
|
|
326
|
+
return null != this.an ? t + "." + this.an : t;
|
|
310
327
|
}
|
|
311
328
|
YE() {
|
|
312
329
|
let t = 0,
|
|
@@ -323,12 +340,12 @@ export default class J {
|
|
|
323
340
|
e
|
|
324
341
|
);
|
|
325
342
|
}
|
|
326
|
-
|
|
343
|
+
ne() {
|
|
327
344
|
const t = new Date();
|
|
328
345
|
return t.setTime(t.getTime() + 60 * this.NE * 1e3), t.getFullYear();
|
|
329
346
|
}
|
|
330
|
-
|
|
331
|
-
const t = Pt(STORAGE_KEYS.
|
|
347
|
+
CE() {
|
|
348
|
+
const t = Pt(STORAGE_KEYS.iu),
|
|
332
349
|
e = document.cookie.split(";");
|
|
333
350
|
for (let s = 0; s < e.length; s++) {
|
|
334
351
|
let r = e[s];
|
|
@@ -341,47 +358,45 @@ export default class J {
|
|
|
341
358
|
}
|
|
342
359
|
if (o) {
|
|
343
360
|
const t = r.split("=")[0];
|
|
344
|
-
-1 === t.indexOf("." + this.
|
|
361
|
+
-1 === t.indexOf("." + this.an) && this.GE(t);
|
|
345
362
|
}
|
|
346
363
|
}
|
|
347
364
|
}
|
|
348
365
|
store(t, e) {
|
|
349
|
-
this.
|
|
366
|
+
this.CE();
|
|
350
367
|
const s = new Date();
|
|
351
368
|
s.setTime(s.getTime() + 60 * this.NE * 1e3);
|
|
352
369
|
const o = "expires=" + s.toUTCString(),
|
|
353
|
-
n = "domain=" + this.
|
|
354
|
-
let
|
|
355
|
-
|
|
356
|
-
const
|
|
357
|
-
return
|
|
358
|
-
? (r.
|
|
370
|
+
n = "domain=" + this.mE;
|
|
371
|
+
let a;
|
|
372
|
+
a = this.KE ? e : encodeURIComponent(e);
|
|
373
|
+
const i = this.dE(t) + "=" + a + ";" + o + ";" + n + ";path=/";
|
|
374
|
+
return i.length >= 4093
|
|
375
|
+
? (r.info(
|
|
359
376
|
"Storage failure: string is " +
|
|
360
|
-
|
|
377
|
+
i.length +
|
|
361
378
|
" chars which is too large to store as a cookie.",
|
|
362
379
|
),
|
|
363
380
|
!1)
|
|
364
|
-
: ((document.cookie =
|
|
381
|
+
: ((document.cookie = i), !0);
|
|
365
382
|
}
|
|
366
|
-
|
|
383
|
+
br(t) {
|
|
367
384
|
const e = [],
|
|
368
385
|
s = this.dE(t) + "=",
|
|
369
386
|
o = document.cookie.split(";");
|
|
370
387
|
for (let n = 0; n < o.length; n++) {
|
|
371
|
-
let
|
|
372
|
-
for (; " " ===
|
|
373
|
-
if (0 ===
|
|
388
|
+
let a = o[n];
|
|
389
|
+
for (; " " === a.charAt(0); ) a = a.substring(1);
|
|
390
|
+
if (0 === a.indexOf(s))
|
|
374
391
|
try {
|
|
375
392
|
let t;
|
|
376
|
-
(t = this.
|
|
377
|
-
?
|
|
378
|
-
:
|
|
379
|
-
decodeURIComponent(i.substring(s.length, i.length)),
|
|
380
|
-
)),
|
|
393
|
+
(t = this.KE
|
|
394
|
+
? a.substring(s.length, a.length)
|
|
395
|
+
: decodeURIComponent(a.substring(s.length, a.length))),
|
|
381
396
|
e.push(t);
|
|
382
397
|
} catch (e) {
|
|
383
398
|
return (
|
|
384
|
-
r.
|
|
399
|
+
r.info("Storage retrieval failure: " + si(e)),
|
|
385
400
|
this.remove(t),
|
|
386
401
|
null
|
|
387
402
|
);
|
|
@@ -395,32 +410,32 @@ export default class J {
|
|
|
395
410
|
GE(t) {
|
|
396
411
|
const e = t + "=;expires=" + new Date(0).toUTCString();
|
|
397
412
|
(document.cookie = e), (document.cookie = e + ";path=/");
|
|
398
|
-
const s = e + ";domain=" + this.
|
|
413
|
+
const s = e + ";domain=" + this.mE;
|
|
399
414
|
(document.cookie = s), (document.cookie = s + ";path=/");
|
|
400
415
|
}
|
|
401
416
|
}),
|
|
402
|
-
(
|
|
417
|
+
(Q.tc = class {
|
|
403
418
|
constructor(t, e, s) {
|
|
404
|
-
(this.
|
|
405
|
-
(this.
|
|
406
|
-
e && this.
|
|
407
|
-
s && this.
|
|
408
|
-
this.
|
|
419
|
+
(this.an = t),
|
|
420
|
+
(this.DE = []),
|
|
421
|
+
e && this.DE.push(new Q.ee(t)),
|
|
422
|
+
s && this.DE.push(new Q.rc(t)),
|
|
423
|
+
this.DE.push(new Q.ac());
|
|
409
424
|
}
|
|
410
425
|
store(t, e) {
|
|
411
426
|
let s = !0;
|
|
412
|
-
for (let r = 0; r < this.
|
|
427
|
+
for (let r = 0; r < this.DE.length; r++) s = this.DE[r].store(t, e) && s;
|
|
413
428
|
return s;
|
|
414
429
|
}
|
|
415
|
-
|
|
416
|
-
for (let e = 0; e < this.
|
|
417
|
-
const s = this.
|
|
430
|
+
br(t) {
|
|
431
|
+
for (let e = 0; e < this.DE.length; e++) {
|
|
432
|
+
const s = this.DE[e].br(t);
|
|
418
433
|
if (null != s) return s;
|
|
419
434
|
}
|
|
420
435
|
return null;
|
|
421
436
|
}
|
|
422
437
|
remove(t) {
|
|
423
|
-
new
|
|
424
|
-
for (let e = 0; e < this.
|
|
438
|
+
new Q.ee(this.an).remove(t);
|
|
439
|
+
for (let e = 0; e < this.DE.length; e++) this.DE[e].remove(t);
|
|
425
440
|
}
|
|
426
441
|
});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class
|
|
1
|
+
import { Guid as p } from "../../shared-lib/index.js";
|
|
2
|
+
export default class T {
|
|
3
3
|
constructor() {
|
|
4
|
-
this.
|
|
4
|
+
this._e = {};
|
|
5
5
|
}
|
|
6
6
|
It(t) {
|
|
7
7
|
if ("function" != typeof t) return null;
|
|
8
|
-
const i =
|
|
9
|
-
return (this.
|
|
8
|
+
const i = p.W();
|
|
9
|
+
return (this._e[i] = t), i;
|
|
10
10
|
}
|
|
11
11
|
removeSubscription(t) {
|
|
12
|
-
delete this.
|
|
12
|
+
delete this._e[t];
|
|
13
13
|
}
|
|
14
14
|
removeAllSubscriptions() {
|
|
15
|
-
this.
|
|
15
|
+
this._e = {};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
return Object.keys(this.
|
|
17
|
+
ic() {
|
|
18
|
+
return Object.keys(this._e).length;
|
|
19
19
|
}
|
|
20
20
|
Dt(t) {
|
|
21
21
|
const i = [];
|
|
22
|
-
for (const
|
|
23
|
-
const
|
|
24
|
-
i.push(
|
|
22
|
+
for (const s in this._e) {
|
|
23
|
+
const r = this._e[s];
|
|
24
|
+
i.push(r(t));
|
|
25
25
|
}
|
|
26
26
|
return i;
|
|
27
27
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Pa: "invalid_api_key",
|
|
3
|
+
Ua: "blacklisted",
|
|
4
|
+
Ha: "no_device_identifier",
|
|
5
|
+
La: "invalid_json_response",
|
|
6
|
+
Ka: "empty_response",
|
|
7
7
|
__: "sdk_auth_error",
|
|
8
8
|
};
|
|
@@ -16,7 +16,7 @@ export default class ue {
|
|
|
16
16
|
(this.sessionId = r),
|
|
17
17
|
(this.data = e);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
Gr() {
|
|
20
20
|
const t = {
|
|
21
21
|
name: this.type,
|
|
22
22
|
time: h(this.time),
|
|
@@ -26,7 +26,7 @@ export default class ue {
|
|
|
26
26
|
};
|
|
27
27
|
return null != this.userId && (t.user_id = this.userId), t;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
Y() {
|
|
30
30
|
return {
|
|
31
31
|
u: this.userId,
|
|
32
32
|
t: this.type,
|
|
@@ -38,10 +38,10 @@ export default class ue {
|
|
|
38
38
|
static fromJson(t) {
|
|
39
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
|
-
static
|
|
44
|
+
static En(t) {
|
|
45
45
|
return new ue(t.u, t.t, t.ts, t.s, t.d);
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/models/device.js
CHANGED
|
@@ -2,11 +2,11 @@ export default class xt {
|
|
|
2
2
|
constructor(s) {
|
|
3
3
|
(this.id = s), (this.id = s);
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
Gr() {
|
|
6
6
|
const s = {};
|
|
7
7
|
return (
|
|
8
8
|
null != this.browser && (s.browser = this.browser),
|
|
9
|
-
null != this.
|
|
9
|
+
null != this.Da && (s.browser_version = this.Da),
|
|
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),
|