monitor-track 1.10.2 → 1.12.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/CHANGELOG.md +26 -0
- package/README.md +15 -5
- package/cjs/config/index.d.ts +0 -4
- package/cjs/constant.d.ts +2 -2
- package/cjs/handlers/pv.d.ts +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +1103 -1078
- package/cjs/reporter.d.ts +18 -7
- package/cjs/types/global.d.ts +16 -2
- package/cjs/types/index.d.ts +10 -5
- package/esm/config/global.js +17 -11
- package/esm/config/index.d.ts +0 -4
- package/esm/config/index.js +0 -4
- package/esm/constant.d.ts +2 -2
- package/esm/constant.js +3 -3
- package/esm/handlers/error.js +3 -8
- package/esm/handlers/pv.d.ts +1 -0
- package/esm/handlers/pv.js +19 -8
- package/esm/handlers/user-activity.js +2 -7
- package/esm/index.d.ts +4 -0
- package/esm/index.js +21 -5
- package/esm/package.json.js +1 -1
- package/esm/reporter.d.ts +18 -7
- package/esm/reporter.js +20 -10
- package/esm/types/global.d.ts +16 -2
- package/esm/types/index.d.ts +10 -5
- package/esm/utils/index.js +12 -16
- package/index.js +1454 -1422
- package/package.json +1 -1
package/esm/types/global.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IErrorInfo, INavigator, IPv, IUserActivity
|
|
1
|
+
import { IErrorInfo, INavigator, IPerformance, IPv, IUserActivity } from '.';
|
|
2
2
|
/**
|
|
3
3
|
* @description 上报信息
|
|
4
4
|
*/
|
|
@@ -34,9 +34,23 @@ export interface IReport extends INavigator {
|
|
|
34
34
|
/** dpr */
|
|
35
35
|
dpr: number;
|
|
36
36
|
pv: IPv | null;
|
|
37
|
+
lag: {
|
|
38
|
+
lagTime: number;
|
|
39
|
+
} | null;
|
|
37
40
|
error: IErrorInfo | null;
|
|
38
41
|
ua: IUserActivity | null;
|
|
39
42
|
perf: IPerformance | null;
|
|
43
|
+
req: {
|
|
44
|
+
requestType: string;
|
|
45
|
+
responseURL: string;
|
|
46
|
+
status: number;
|
|
47
|
+
loadTime: number;
|
|
48
|
+
statusText: string;
|
|
49
|
+
reason: 'slow' | 'failed' | string;
|
|
50
|
+
detail: string;
|
|
51
|
+
requestData: string;
|
|
52
|
+
method: string;
|
|
53
|
+
} | null;
|
|
40
54
|
vD?: {
|
|
41
55
|
/** 埋点名称 */
|
|
42
56
|
trackName: string;
|
|
@@ -64,7 +78,7 @@ export interface IReport extends INavigator {
|
|
|
64
78
|
* @type visual 可视化埋点上报
|
|
65
79
|
* @type manual 手动上报
|
|
66
80
|
*/
|
|
67
|
-
export type IType = 'pv' | 'error' | 'ua' | 'api' | 'per' | 'init' | 'request' | 'visual' | 'manual';
|
|
81
|
+
export type IType = 'pv' | 'error' | 'ua' | 'api' | 'per' | 'init' | 'request' | 'visual' | 'manual' | 'lag';
|
|
68
82
|
export interface Navigator {
|
|
69
83
|
connection: any;
|
|
70
84
|
}
|
package/esm/types/index.d.ts
CHANGED
|
@@ -153,13 +153,16 @@ export interface IPerformance {
|
|
|
153
153
|
domContentLoadedEventEnd: number;
|
|
154
154
|
/** 是一个无符号long long 型的毫秒数,返回当解析器发送DOMContentLoaded (en-US) 事件,即所有需要被执行的脚本已经被解析时的Unix毫秒时间戳。 */
|
|
155
155
|
domContentLoadedEventStart: number;
|
|
156
|
-
/** 是一个无符号long long 型的毫秒数,返回当前网页DOM结构结束解析、开始加载内嵌资源时(即Document.readyState属性变为“interactive
|
|
156
|
+
/** 是一个无符号long long 型的毫秒数,返回当前网页DOM结构结束解析、开始加载内嵌资源时(即Document.readyState属性变为“interactive”、
|
|
157
|
+
* 相应的readystatechange (en-US)事件触发时)的Unix毫秒时间戳。 */
|
|
157
158
|
domInteractive: number;
|
|
158
159
|
/** 是一个无符号long long 型的毫秒数,返回当前网页DOM结构开始解析时(即Document.readyState属性变为“loading”、相应的 readystatechange (en-US)事件触发时)的Unix毫秒时间戳。 */
|
|
159
160
|
domLoading: number;
|
|
160
|
-
/** 是一个无符号long long 型的毫秒数,表征了域名查询结束的UNIX时间戳。如果使用了持续连接(persistent connection)
|
|
161
|
+
/** 是一个无符号long long 型的毫秒数,表征了域名查询结束的UNIX时间戳。如果使用了持续连接(persistent connection),
|
|
162
|
+
* 或者这个信息存储到了缓存或者本地资源上,这个值将和 PerformanceTiming.fetchStart一致。 */
|
|
161
163
|
domainLookupEnd: number;
|
|
162
|
-
/** 是一个无符号long long 型的毫秒数,表征了域名查询开始的UNIX时间戳。如果使用了持续连接(persistent connection)
|
|
164
|
+
/** 是一个无符号long long 型的毫秒数,表征了域名查询开始的UNIX时间戳。如果使用了持续连接(persistent connection),
|
|
165
|
+
* 或者这个信息存储到了缓存或者本地资源上,这个值将和 PerformanceTiming.fetchStart一致。 */
|
|
163
166
|
domainLookupStart: number;
|
|
164
167
|
/** 是一个无符号long long 型的毫秒数,表征了浏览器准备好使用HTTP请求来获取(fetch)文档的UNIX时间戳。这个时间点会在检查任何应用缓存之前。 */
|
|
165
168
|
fetchStart: number;
|
|
@@ -181,9 +184,11 @@ export interface IPerformance {
|
|
|
181
184
|
responseStart: number;
|
|
182
185
|
/** 是一个无符号long long 型的毫秒数,返回浏览器与服务器开始安全链接的握手时的Unix毫秒时间戳。如果当前网页不要求安全连接,则返回0。 */
|
|
183
186
|
secureConnectionStart: number;
|
|
184
|
-
/** 是一个无符号long long 型的毫秒数,表征了unload (en-US)事件处理完成时的UNIX时间戳。如果没有上一个文档,
|
|
187
|
+
/** 是一个无符号long long 型的毫秒数,表征了unload (en-US)事件处理完成时的UNIX时间戳。如果没有上一个文档,
|
|
188
|
+
* or if the previous document, or one of the needed redirects, is not of the same origin, 这个值会返回0. */
|
|
185
189
|
unloadEventEnd: number;
|
|
186
|
-
/** 是一个无符号long long 型的毫秒数,表征了unload (en-US)事件抛出时的UNIX时间戳。如果没有上一个文档,
|
|
190
|
+
/** 是一个无符号long long 型的毫秒数,表征了unload (en-US)事件抛出时的UNIX时间戳。如果没有上一个文档,
|
|
191
|
+
* or if the previous document, or one of the needed redirects, is not of the same origin, 这个值会返回0. */
|
|
187
192
|
unloadEventStart: number;
|
|
188
193
|
};
|
|
189
194
|
}
|
package/esm/utils/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import { v4 } from 'uuid';
|
|
4
3
|
import { UAParser } from 'ua-parser-js';
|
|
5
|
-
import {
|
|
6
|
-
import { setReportValue, getReport } from '../config/global.js';
|
|
7
|
-
import { report } from '../reporter.js';
|
|
8
|
-
import { Config } from '../config/index.js';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
9
5
|
import { version } from '../package.json.js';
|
|
10
|
-
import {
|
|
6
|
+
import { Config } from '../config/index.js';
|
|
7
|
+
import { setReportValue, getReport } from '../config/global.js';
|
|
8
|
+
import { monitorTrackSessionId, monitorTrackId } from '../constant.js';
|
|
11
9
|
import { handleHistoryChange } from '../handlers/pv.js';
|
|
10
|
+
import { getUserEvents, getFullScreenShoot } from '../handlers/error.js';
|
|
11
|
+
import { report } from '../reporter.js';
|
|
12
12
|
|
|
13
13
|
const parser = new UAParser();
|
|
14
14
|
/**
|
|
15
15
|
* @description 获取uuid
|
|
16
16
|
*/
|
|
17
17
|
function getUid() {
|
|
18
|
-
let uid = localStorage.getItem(
|
|
18
|
+
let uid = localStorage.getItem(monitorTrackId) || '';
|
|
19
19
|
if (!uid) {
|
|
20
20
|
uid = v4();
|
|
21
|
-
localStorage.setItem(
|
|
21
|
+
localStorage.setItem(monitorTrackId, uid);
|
|
22
22
|
}
|
|
23
23
|
return uid;
|
|
24
24
|
}
|
|
@@ -26,13 +26,13 @@ function getUid() {
|
|
|
26
26
|
* @description 获取session id
|
|
27
27
|
*/
|
|
28
28
|
function getSessionId() {
|
|
29
|
-
const sessionId = sessionStorage.getItem(
|
|
29
|
+
const sessionId = sessionStorage.getItem(monitorTrackSessionId);
|
|
30
30
|
if (sessionId) {
|
|
31
31
|
return sessionId;
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const id = v4();
|
|
35
|
-
sessionStorage.setItem(
|
|
35
|
+
sessionStorage.setItem(monitorTrackSessionId, id);
|
|
36
36
|
return id;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -195,9 +195,7 @@ const visualTrackFunc = () => {
|
|
|
195
195
|
timeout = setTimeout(() => {
|
|
196
196
|
timeout = null;
|
|
197
197
|
const url = location.href.split('?')[0];
|
|
198
|
-
axios
|
|
199
|
-
.get(`${Config.reportUrl.replace('/s/r', '')}/visual/get_data_list?url=${encodeURIComponent(url)}`)
|
|
200
|
-
.then((res) => {
|
|
198
|
+
axios.get(`${Config.reportUrl.replace('/s/r', '')}/visual/get_data_list?url=${encodeURIComponent(url)}`).then((res) => {
|
|
201
199
|
var _a, _b;
|
|
202
200
|
const listData = (_b = (_a = res.data.result) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.dataList;
|
|
203
201
|
if (Array.isArray(listData)) {
|
|
@@ -207,9 +205,7 @@ const visualTrackFunc = () => {
|
|
|
207
205
|
visualReportEvent(item);
|
|
208
206
|
}
|
|
209
207
|
else {
|
|
210
|
-
const element = document
|
|
211
|
-
.evaluate(formatTrackElementXPath(item.trackElementXPath), document)
|
|
212
|
-
.iterateNext();
|
|
208
|
+
const element = document.evaluate(formatTrackElementXPath(item.trackElementXPath), document).iterateNext();
|
|
213
209
|
const key = url + item.trackElementXPath;
|
|
214
210
|
if (element) {
|
|
215
211
|
if (!existTrackListenEvent[key]) {
|