@slan-health/tracker 1.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.
@@ -0,0 +1,194 @@
1
+ import TrackerMode from "./TrackerMode";
2
+ import EventType from "./EventType";
3
+ import EventTimer from "./EventTimer";
4
+ import createLib from "./utils/lib";
5
+ import request from "./utils/request";
6
+ import Devices from "./utils/devices";
7
+ import { log } from "./utils/SlLog";
8
+ import {
9
+ createDeviceId,
10
+ setLoginId,
11
+ getLoginId,
12
+ removeLoginId,
13
+ getPointList,
14
+ } from "./utils/DbHelper";
15
+ import { Queue } from "./Queue";
16
+ import { setActiveTracker } from "./trackerStore";
17
+
18
+ export function createTracker(config) {
19
+ const lib = createLib(config.appVersion);
20
+
21
+ const devices = createDevices();
22
+
23
+ const eventTimers = new Map();
24
+
25
+ let loginId = getLoginId();
26
+
27
+ const queue = new Queue(getPointList());
28
+
29
+ const win =
30
+ typeof window !== "undefined"
31
+ ? window
32
+ : {
33
+ addEventListener: () => {},
34
+ };
35
+
36
+ win.addEventListener("load", () => {
37
+ trackNativeEvent(
38
+ EventType.APP_START,
39
+ EventType.APP_START,
40
+ undefined,
41
+ loginId
42
+ );
43
+ });
44
+
45
+ win.addEventListener("beforeunload", () => {
46
+ trackNativeEvent(EventType.APP_END, EventType.APP_END, undefined, loginId);
47
+ });
48
+
49
+ function createDevices() {
50
+ const devices = new Devices(createDeviceId()).valueOf();
51
+ return devices;
52
+ }
53
+
54
+ function isDebug() {
55
+ return config.trackerMode == TrackerMode.DEBUG_ONLY;
56
+ }
57
+
58
+ function trackEvent(eventName, property) {
59
+ trackNativeEvent(eventName, EventType.TRACK, property, loginId);
60
+ }
61
+
62
+ function startTrackTime(eventName) {
63
+ eventTimers.set(eventName, new EventTimer(Date.now()));
64
+ }
65
+ function pauseTrackTime(eventName) {
66
+ const eventTimer = eventTimers.get(eventName);
67
+ eventTimer && eventTimer.pause(Date.now());
68
+ }
69
+ function resumeTrackTime(eventName) {
70
+ const eventTimer = eventTimers.get(eventName);
71
+ eventTimer && eventTimer.resume(Date.now());
72
+ }
73
+
74
+ function endTrackTime(eventName, property) {
75
+ const eventTimer = eventTimers.get(eventName);
76
+ if (eventTimer) {
77
+ eventTimer.setEndTime(Date.now());
78
+ trackNativeEvent(eventName, EventType.TRACK_TIME, property, loginId);
79
+ }
80
+ }
81
+
82
+ function login(id) {
83
+ setLoginId(id);
84
+ loginId = id;
85
+ }
86
+
87
+ function logOut() {
88
+ removeLoginId();
89
+ loginId = undefined;
90
+ }
91
+
92
+ function flush() {
93
+ uploadData(true);
94
+ }
95
+
96
+ function trackNativeEvent(eventName, type, property, loginId) {
97
+ if (config.trackerMode == TrackerMode.DISABLE) {
98
+ //禁用的时候不做收集
99
+ return;
100
+ }
101
+ log({ eventName, type, property, loginId });
102
+
103
+ let event = {
104
+ name: eventName,
105
+ type: type,
106
+ time: Date.now(),
107
+ };
108
+
109
+ if (type == EventType.TRACK_TIME && eventTimers.get(eventName)) {
110
+ const duration = eventTimers.get(eventName).duration();
111
+ if (duration != -1) {
112
+ event["duration"] = duration;
113
+ }
114
+ eventTimers.delete(eventName);
115
+ }
116
+
117
+ let data = {
118
+ event,
119
+ devices: devices,
120
+ lib: lib,
121
+ };
122
+ if (loginId && loginId != "") {
123
+ data["distinct_id"] = loginId;
124
+ }
125
+ if (property) {
126
+ data["properties"] = property;
127
+ }
128
+ queue.push(data);
129
+ uploadData(false);
130
+ }
131
+
132
+ function uploadData(force = false) {
133
+ if (
134
+ queue.empty() ||
135
+ (queue.size() < (config.reportThreshold || 10) && !isDebug() && !force)
136
+ ) {
137
+ return;
138
+ }
139
+ const data = queue.flush();
140
+ if (config.trackerMode == TrackerMode.CONSOLE_LOG) {
141
+ //log模式的时候只打印,不发送
142
+ console.log(data);
143
+ return;
144
+ }
145
+ requestData(JSON.stringify(data));
146
+ }
147
+
148
+ function requestData(dataString) {
149
+ let options = {
150
+ url: config.serverUrl,
151
+ method: "POST",
152
+ header: {
153
+ "content-type": "application/json",
154
+ ...(config.headers || {}),
155
+ },
156
+ data: {
157
+ app_id: config.appId,
158
+ data_list: dataString,
159
+ },
160
+ };
161
+ if (config.requestInterceptors?.length > 0) {
162
+ options = config.requestInterceptors.reduce(
163
+ (pre, func) => func(pre),
164
+ options
165
+ );
166
+ }
167
+
168
+ request(options)
169
+ .then((res) => {
170
+ const { code } = res;
171
+ if (code !== 0) {
172
+ queue.unshift(JSON.parse(dataString));
173
+ }
174
+ })
175
+ .catch(() => {
176
+ queue.unshift(JSON.parse(dataString));
177
+ });
178
+ }
179
+
180
+ const tracker = {
181
+ trackEvent,
182
+ startTrackTime,
183
+ pauseTrackTime,
184
+ resumeTrackTime,
185
+ endTrackTime,
186
+ login,
187
+ logOut,
188
+ flush,
189
+ isDebug,
190
+ };
191
+
192
+ setActiveTracker(tracker);
193
+ return tracker;
194
+ }
@@ -0,0 +1,7 @@
1
+ let activeTracker;
2
+
3
+ export const setActiveTracker = (tracker) => {
4
+ activeTracker = tracker;
5
+ };
6
+
7
+ export const getActiveTracker = () => activeTracker;
@@ -0,0 +1,32 @@
1
+ import uuid from "./uuid";
2
+
3
+ export const POINT_DATA = "sl-tracker-point-data";
4
+
5
+ export function createDeviceId() {
6
+ let id = localStorage.getItem("sl-tracker-uuid");
7
+ if (!id) {
8
+ id = uuid();
9
+ localStorage.setItem("sl-tracker-uuid", id);
10
+ }
11
+ return id;
12
+ }
13
+
14
+ export function setLoginId(loginId) {
15
+ localStorage.setItem("sl-tracker-loginId", loginId);
16
+ }
17
+
18
+ export function getLoginId() {
19
+ return localStorage.getItem("sl-tracker-loginId");
20
+ }
21
+
22
+ export function removeLoginId() {
23
+ localStorage.setItem("sl-tracker-loginId", "");
24
+ }
25
+
26
+ export function setPointDataList(datas) {
27
+ localStorage.setItem(POINT_DATA, JSON.stringify(datas));
28
+ }
29
+
30
+ export function getPointList() {
31
+ return JSON.parse(localStorage.getItem(POINT_DATA)) ?? [];
32
+ }
@@ -0,0 +1,9 @@
1
+ import { getActiveTracker } from "../trackerStore";
2
+
3
+ const log = (message, ...optionalParams) => {
4
+ if (getActiveTracker()?.isDebug()) {
5
+ console.log(message, ...optionalParams);
6
+ }
7
+ };
8
+
9
+ export { log };
@@ -0,0 +1,437 @@
1
+ var win;
2
+
3
+ if (typeof window === "undefined") {
4
+ win = {
5
+ navigator: {
6
+ userAgent: "",
7
+ },
8
+ };
9
+ } else {
10
+ win = window;
11
+ }
12
+ const nav = win.navigator,
13
+ ua = nav.userAgent;
14
+
15
+ const infoMap = {
16
+ browser: [
17
+ "Safari",
18
+ "Chrome",
19
+ "Edge",
20
+ "IE",
21
+ "Firefox",
22
+ "Firefox Focus",
23
+ "Chromium",
24
+ "Opera",
25
+ "Vivaldi",
26
+ "Yandex",
27
+ "Arora",
28
+ "Lunascape",
29
+ "QupZilla",
30
+ "Coc Coc",
31
+ "Kindle",
32
+ "Iceweasel",
33
+ "Konqueror",
34
+ "Iceape",
35
+ "SeaMonkey",
36
+ "Epiphany",
37
+ "360",
38
+ "360SE",
39
+ "360EE",
40
+ "UC",
41
+ "QQBrowser",
42
+ "QQ",
43
+ "Baidu",
44
+ "Maxthon",
45
+ "Sogou",
46
+ "LBBROWSER",
47
+ "2345Explorer",
48
+ "TheWorld",
49
+ "XiaoMi",
50
+ "Quark",
51
+ "Qiyu",
52
+ "Wechat",
53
+ "Taobao",
54
+ "Alipay",
55
+ "Weibo",
56
+ "Douban",
57
+ "Suning",
58
+ "iQiYi",
59
+ ],
60
+ os: [
61
+ "Windows",
62
+ "Linux",
63
+ "Mac OS",
64
+ "Android",
65
+ "Ubuntu",
66
+ "FreeBSD",
67
+ "Debian",
68
+ "iOS",
69
+ "Windows Phone",
70
+ "BlackBerry",
71
+ "MeeGo",
72
+ "Symbian",
73
+ "Chrome OS",
74
+ "WebOS",
75
+ ],
76
+ device: ["Mobile", "Tablet", "iPad"],
77
+ };
78
+
79
+ const DeviceMethod = {
80
+ getMatchMap: function (u) {
81
+ return {
82
+ // 浏览器
83
+ Safari: u.indexOf("Safari") > -1,
84
+ Chrome: u.indexOf("Chrome") > -1 || u.indexOf("CriOS") > -1,
85
+ IE: u.indexOf("MSIE") > -1 || u.indexOf("Trident") > -1,
86
+ Edge: u.indexOf("Edge") > -1,
87
+ Firefox: u.indexOf("Firefox") > -1 || u.indexOf("FxiOS") > -1,
88
+ "Firefox Focus": u.indexOf("Focus") > -1,
89
+ Chromium: u.indexOf("Chromium") > -1,
90
+ Opera: u.indexOf("Opera") > -1 || u.indexOf("OPR") > -1,
91
+ Vivaldi: u.indexOf("Vivaldi") > -1,
92
+ Yandex: u.indexOf("YaBrowser") > -1,
93
+ Arora: u.indexOf("Arora") > -1,
94
+ Lunascape: u.indexOf("Lunascape") > -1,
95
+ QupZilla: u.indexOf("QupZilla") > -1,
96
+ "Coc Coc": u.indexOf("coc_coc_browser") > -1,
97
+ Kindle: u.indexOf("Kindle") > -1 || u.indexOf("Silk/") > -1,
98
+ Iceweasel: u.indexOf("Iceweasel") > -1,
99
+ Konqueror: u.indexOf("Konqueror") > -1,
100
+ Iceape: u.indexOf("Iceape") > -1,
101
+ SeaMonkey: u.indexOf("SeaMonkey") > -1,
102
+ Epiphany: u.indexOf("Epiphany") > -1,
103
+ 360: u.indexOf("QihooBrowser") > -1 || u.indexOf("QHBrowser") > -1,
104
+ "360EE": u.indexOf("360EE") > -1,
105
+ "360SE": u.indexOf("360SE") > -1,
106
+ UC: u.indexOf("UC") > -1 || u.indexOf(" UBrowser") > -1,
107
+ QQBrowser: u.indexOf("QQBrowser") > -1,
108
+ QQ: u.indexOf("QQ/") > -1,
109
+ Baidu: u.indexOf("Baidu") > -1 || u.indexOf("BIDUBrowser") > -1,
110
+ Maxthon: u.indexOf("Maxthon") > -1,
111
+ Sogou: u.indexOf("MetaSr") > -1 || u.indexOf("Sogou") > -1,
112
+ LBBROWSER: u.indexOf("LBBROWSER") > -1,
113
+ "2345Explorer": u.indexOf("2345Explorer") > -1,
114
+ TheWorld: u.indexOf("TheWorld") > -1,
115
+ XiaoMi: u.indexOf("MiuiBrowser") > -1,
116
+ Quark: u.indexOf("Quark") > -1,
117
+ Qiyu: u.indexOf("Qiyu") > -1,
118
+ Wechat: u.indexOf("MicroMessenger") > -1,
119
+ Taobao: u.indexOf("AliApp(TB") > -1,
120
+ Alipay: u.indexOf("AliApp(AP") > -1,
121
+ Weibo: u.indexOf("Weibo") > -1,
122
+ Douban: u.indexOf("com.douban.frodo") > -1,
123
+ Suning: u.indexOf("SNEBUY-APP") > -1,
124
+ iQiYi: u.indexOf("IqiyiApp") > -1,
125
+ // 系统或平台
126
+ Windows: u.indexOf("Windows") > -1,
127
+ Linux: u.indexOf("Linux") > -1 || u.indexOf("X11") > -1,
128
+ "Mac OS": u.indexOf("Macintosh") > -1,
129
+ Android: u.indexOf("Android") > -1 || u.indexOf("Adr") > -1,
130
+ Ubuntu: u.indexOf("Ubuntu") > -1,
131
+ FreeBSD: u.indexOf("FreeBSD") > -1,
132
+ Debian: u.indexOf("Debian") > -1,
133
+ "Windows Phone":
134
+ u.indexOf("IEMobile") > -1 || u.indexOf("Windows Phone") > -1,
135
+ BlackBerry: u.indexOf("BlackBerry") > -1 || u.indexOf("RIM") > -1,
136
+ MeeGo: u.indexOf("MeeGo") > -1,
137
+ Symbian: u.indexOf("Symbian") > -1,
138
+ iOS: u.indexOf("like Mac OS X") > -1,
139
+ "Chrome OS": u.indexOf("CrOS") > -1,
140
+ WebOS: u.indexOf("hpwOS") > -1,
141
+ // 设备
142
+ Mobile:
143
+ u.indexOf("Mobi") > -1 ||
144
+ u.indexOf("iPh") > -1 ||
145
+ u.indexOf("480") > -1,
146
+ Tablet: u.indexOf("Tablet") > -1 || u.indexOf("Nexus 7") > -1,
147
+ iPad: u.indexOf("iPad") > -1,
148
+ };
149
+ },
150
+
151
+ matchInfoMap: function (_this) {
152
+ var match = DeviceMethod.getMatchMap(ua);
153
+ for (var s in infoMap) {
154
+ for (var i = 0; i < infoMap[s].length; i++) {
155
+ var value = infoMap[s][i];
156
+ if (match[value]) {
157
+ _this[s] = value;
158
+ }
159
+ }
160
+ }
161
+ },
162
+
163
+ getOS: function () {
164
+ var _this = this;
165
+ DeviceMethod.matchInfoMap(_this);
166
+ return _this.os;
167
+ },
168
+
169
+ getOSVersion: function () {
170
+ var _this = this;
171
+ var u = ua;
172
+ _this.osVersion = "";
173
+ // 系统版本信息
174
+ var osVersion = {
175
+ Windows: function () {
176
+ var v = u.replace(/^.*Windows NT ([\d.]+);.*$/, "$1");
177
+ var oldWindowsVersionMap = {
178
+ 6.4: "10",
179
+ 6.3: "8.1",
180
+ 6.2: "8",
181
+ 6.1: "7",
182
+ "6.0": "Vista",
183
+ 5.2: "XP",
184
+ 5.1: "XP",
185
+ "5.0": "2000",
186
+ };
187
+ return oldWindowsVersionMap[v] || v;
188
+ },
189
+ Android: function () {
190
+ return u.replace(/^.*Android ([\d.]+);.*$/, "$1");
191
+ },
192
+ iOS: function () {
193
+ return u.replace(/^.*OS ([\d_]+) like.*$/, "$1").replace(/_/g, ".");
194
+ },
195
+ Debian: function () {
196
+ return u.replace(/^.*Debian\/([\d.]+).*$/, "$1");
197
+ },
198
+ "Windows Phone": function () {
199
+ return u.replace(/^.*Windows Phone( OS)? ([\d.]+);.*$/, "$2");
200
+ },
201
+ "Mac OS": function () {
202
+ return u.replace(/^.*Mac OS X ([\d_]+).*$/, "$1").replace(/_/g, ".");
203
+ },
204
+ WebOS: function () {
205
+ return u.replace(/^.*hpwOS\/([\d.]+);.*$/, "$1");
206
+ },
207
+ };
208
+ if (osVersion[_this.os]) {
209
+ _this.osVersion = osVersion[_this.os]();
210
+ if (_this.osVersion == u) {
211
+ _this.osVersion = "";
212
+ }
213
+ }
214
+ return _this.osVersion;
215
+ },
216
+
217
+ getDeviceType: function () {
218
+ var _this = this;
219
+ _this.device = "PC";
220
+ DeviceMethod.matchInfoMap(_this);
221
+ return _this.device;
222
+ },
223
+
224
+ getNetwork: function () {
225
+ var netWork = nav && nav.connection && nav.connection.effectiveType;
226
+ return netWork || "未知";
227
+ },
228
+
229
+ getBrowserInfo: function () {
230
+ var _this = this;
231
+ DeviceMethod.matchInfoMap(_this);
232
+
233
+ var u = ua;
234
+
235
+ var match = DeviceMethod.getMatchMap(u);
236
+
237
+ if (match["Baidu"] && match["Opera"]) {
238
+ match["Baidu"] = false;
239
+ }
240
+ if (match["Mobile"]) {
241
+ match["Mobile"] = !(u.indexOf("iPad") > -1);
242
+ }
243
+
244
+ var browerVersionMap = {
245
+ Safari: function () {
246
+ return u.replace(/^.*Version\/([\d.]+).*$/, "$1");
247
+ },
248
+ Chrome: function () {
249
+ return u
250
+ .replace(/^.*Chrome\/([\d.]+).*$/, "$1")
251
+ .replace(/^.*CriOS\/([\d.]+).*$/, "$1");
252
+ },
253
+ IE: function () {
254
+ return u
255
+ .replace(/^.*MSIE ([\d.]+).*$/, "$1")
256
+ .replace(/^.*rv:([\d.]+).*$/, "$1");
257
+ },
258
+ Edge: function () {
259
+ return u.replace(/^.*Edge\/([\d.]+).*$/, "$1");
260
+ },
261
+ Firefox: function () {
262
+ return u
263
+ .replace(/^.*Firefox\/([\d.]+).*$/, "$1")
264
+ .replace(/^.*FxiOS\/([\d.]+).*$/, "$1");
265
+ },
266
+ "Firefox Focus": function () {
267
+ return u.replace(/^.*Focus\/([\d.]+).*$/, "$1");
268
+ },
269
+ Chromium: function () {
270
+ return u.replace(/^.*Chromium\/([\d.]+).*$/, "$1");
271
+ },
272
+ Opera: function () {
273
+ return u
274
+ .replace(/^.*Opera\/([\d.]+).*$/, "$1")
275
+ .replace(/^.*OPR\/([\d.]+).*$/, "$1");
276
+ },
277
+ Vivaldi: function () {
278
+ return u.replace(/^.*Vivaldi\/([\d.]+).*$/, "$1");
279
+ },
280
+ Yandex: function () {
281
+ return u.replace(/^.*YaBrowser\/([\d.]+).*$/, "$1");
282
+ },
283
+ Arora: function () {
284
+ return u.replace(/^.*Arora\/([\d.]+).*$/, "$1");
285
+ },
286
+ Lunascape: function () {
287
+ return u.replace(/^.*Lunascape[/\s]([\d.]+).*$/, "$1");
288
+ },
289
+ QupZilla: function () {
290
+ return u.replace(/^.*QupZilla[/\s]([\d.]+).*$/, "$1");
291
+ },
292
+ "Coc Coc": function () {
293
+ return u.replace(/^.*coc_coc_browser\/([\d.]+).*$/, "$1");
294
+ },
295
+ Kindle: function () {
296
+ return u.replace(/^.*Version\/([\d.]+).*$/, "$1");
297
+ },
298
+ Iceweasel: function () {
299
+ return u.replace(/^.*Iceweasel\/([\d.]+).*$/, "$1");
300
+ },
301
+ Konqueror: function () {
302
+ return u.replace(/^.*Konqueror\/([\d.]+).*$/, "$1");
303
+ },
304
+ Iceape: function () {
305
+ return u.replace(/^.*Iceape\/([\d.]+).*$/, "$1");
306
+ },
307
+ SeaMonkey: function () {
308
+ return u.replace(/^.*SeaMonkey\/([\d.]+).*$/, "$1");
309
+ },
310
+ Epiphany: function () {
311
+ return u.replace(/^.*Epiphany\/([\d.]+).*$/, "$1");
312
+ },
313
+ 360: function () {
314
+ return u.replace(/^.*QihooBrowser\/([\d.]+).*$/, "$1");
315
+ },
316
+ "360SE": function () {
317
+ var hash = {
318
+ 63: "10.0",
319
+ 55: "9.1",
320
+ 45: "8.1",
321
+ 42: "8.0",
322
+ 31: "7.0",
323
+ 21: "6.3",
324
+ };
325
+ var chrome_vision = u.replace(/^.*Chrome\/([\d]+).*$/, "$1");
326
+ return hash[chrome_vision] || "";
327
+ },
328
+ "360EE": function () {
329
+ var hash = { 69: "11.0", 63: "9.5", 55: "9.0", 50: "8.7", 30: "7.5" };
330
+ var chrome_vision = u.replace(/^.*Chrome\/([\d]+).*$/, "$1");
331
+ return hash[chrome_vision] || "";
332
+ },
333
+ Maxthon: function () {
334
+ return u.replace(/^.*Maxthon\/([\d.]+).*$/, "$1");
335
+ },
336
+ QQBrowser: function () {
337
+ return u.replace(/^.*QQBrowser\/([\d.]+).*$/, "$1");
338
+ },
339
+ QQ: function () {
340
+ return u.replace(/^.*QQ\/([\d.]+).*$/, "$1");
341
+ },
342
+ Baidu: function () {
343
+ return u.replace(/^.*BIDUBrowser[\s/]([\d.]+).*$/, "$1");
344
+ },
345
+ UC: function () {
346
+ return u.replace(/^.*UC?Browser\/([\d.]+).*$/, "$1");
347
+ },
348
+ Sogou: function () {
349
+ return u
350
+ .replace(/^.*SE ([\d.X]+).*$/, "$1")
351
+ .replace(/^.*SogouMobileBrowser\/([\d.]+).*$/, "$1");
352
+ },
353
+ LBBROWSER: function () {
354
+ var hash = {
355
+ 57: "6.5",
356
+ 49: "6.0",
357
+ 46: "5.9",
358
+ 42: "5.3",
359
+ 39: "5.2",
360
+ 34: "5.0",
361
+ 29: "4.5",
362
+ 21: "4.0",
363
+ };
364
+ var chrome_vision = u.replace(/^.*Chrome\/([\d]+).*$/, "$1");
365
+ return hash[chrome_vision] || "";
366
+ },
367
+ "2345Explorer": function () {
368
+ return u.replace(/^.*2345Explorer\/([\d.]+).*$/, "$1");
369
+ },
370
+ TheWorld: function () {
371
+ return u.replace(/^.*TheWorld ([\d.]+).*$/, "$1");
372
+ },
373
+ XiaoMi: function () {
374
+ return u.replace(/^.*MiuiBrowser\/([\d.]+).*$/, "$1");
375
+ },
376
+ Quark: function () {
377
+ return u.replace(/^.*Quark\/([\d.]+).*$/, "$1");
378
+ },
379
+ Qiyu: function () {
380
+ return u.replace(/^.*Qiyu\/([\d.]+).*$/, "$1");
381
+ },
382
+ Wechat: function () {
383
+ return u.replace(/^.*MicroMessenger\/([\d.]+).*$/, "$1");
384
+ },
385
+ Taobao: function () {
386
+ return u.replace(/^.*AliApp\(TB\/([\d.]+).*$/, "$1");
387
+ },
388
+ Alipay: function () {
389
+ return u.replace(/^.*AliApp\(AP\/([\d.]+).*$/, "$1");
390
+ },
391
+ Weibo: function () {
392
+ return u.replace(/^.*weibo__([\d.]+).*$/, "$1");
393
+ },
394
+ Douban: function () {
395
+ return u.replace(/^.*com.douban.frodo\/([\d.]+).*$/, "$1");
396
+ },
397
+ Suning: function () {
398
+ return u.replace(/^.*SNEBUY-APP([\d.]+).*$/, "$1");
399
+ },
400
+ iQiYi: function () {
401
+ return u.replace(/^.*IqiyiVersion\/([\d.]+).*$/, "$1");
402
+ },
403
+ };
404
+
405
+ _this.browserVersion = "";
406
+ if (browerVersionMap[_this.browser]) {
407
+ _this.browserVersion = browerVersionMap[_this.browser]();
408
+ if (_this.browserVersion == u) {
409
+ _this.browserVersion = "";
410
+ }
411
+ }
412
+
413
+ return _this.browser + " " + _this.browserVersion;
414
+ },
415
+ };
416
+
417
+ class Devices {
418
+ constructor(device_id) {
419
+ this.device_id = device_id;
420
+ }
421
+
422
+ valueOf() {
423
+ return {
424
+ device_id: this.device_id,
425
+ os_version: DeviceMethod.getBrowserInfo(),
426
+ model:
427
+ DeviceMethod.getOS() +
428
+ " " +
429
+ DeviceMethod.getOSVersion() +
430
+ " " +
431
+ DeviceMethod.getDeviceType(),
432
+ network_type: DeviceMethod.getNetwork(),
433
+ };
434
+ }
435
+ }
436
+
437
+ export default Devices;
@@ -0,0 +1,8 @@
1
+ const lib = (appVersion) => ({
2
+ lib: "web-app",
3
+ lib_version: "0.0.2",
4
+
5
+ app_version: appVersion,
6
+ });
7
+
8
+ export default lib;