mon-reactive-h5 1.0.9 → 1.0.10
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/dist/BatchReporter.d.ts +0 -34
- package/dist/BatchReporter.js +1 -44
- package/dist/BatchReporter.js.map +1 -1
- package/dist/MonitorSDK.d.ts +0 -94
- package/dist/MonitorSDK.js +14 -257
- package/dist/MonitorSDK.js.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/packages/basic-sdk.d.ts +0 -10
- package/dist/packages/basic-sdk.js +0 -13
- package/dist/packages/basic-sdk.js.map +1 -1
- package/dist/packages/index.js +0 -3
- package/dist/packages/index.js.map +1 -1
- package/dist/packages/premium-sdk.d.ts +0 -46
- package/dist/packages/premium-sdk.js +1 -55
- package/dist/packages/premium-sdk.js.map +1 -1
- package/dist/packages/standard-sdk.d.ts +0 -13
- package/dist/packages/standard-sdk.js +0 -16
- package/dist/packages/standard-sdk.js.map +1 -1
- package/dist/reporters.d.ts +0 -25
- package/dist/reporters.js +5 -34
- package/dist/reporters.js.map +1 -1
- package/package.json +4 -2
package/dist/reporters.d.ts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import { BaseReportData, ReportResult } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* 使用img标签方式上报数据
|
|
4
|
-
* @param data 上报数据
|
|
5
|
-
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
6
|
-
* @returns 是否上报成功
|
|
7
|
-
*/
|
|
8
2
|
export declare function reportByImg(data: BaseReportData, url: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* 使用sendBeacon方式上报数据
|
|
11
|
-
* @param data 上报数据
|
|
12
|
-
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
13
|
-
* @returns 是否上报成功
|
|
14
|
-
*/
|
|
15
3
|
export declare function reportByBeacon(data: BaseReportData, url: string): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* 使用接口方式上报数据
|
|
18
|
-
* @param data 上报数据
|
|
19
|
-
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
20
|
-
* @param options 配置项
|
|
21
|
-
* @returns Promise<ReportResult>
|
|
22
|
-
*/
|
|
23
4
|
export declare function reportByApi(data: BaseReportData, url: string, options?: {
|
|
24
5
|
timeout?: number;
|
|
25
6
|
}): Promise<ReportResult>;
|
|
26
|
-
/**
|
|
27
|
-
* 带降级策略的上报方法
|
|
28
|
-
* @param data 上报数据
|
|
29
|
-
* @param url 上报地址
|
|
30
|
-
* @returns 是否至少有一种上报方式成功
|
|
31
|
-
*/
|
|
32
7
|
export declare function reportWithFallback(data: BaseReportData, url: string): Promise<boolean>;
|
package/dist/reporters.js
CHANGED
|
@@ -33,21 +33,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
33
33
|
value: true
|
|
34
34
|
});
|
|
35
35
|
exports.reportWithFallback = exports.reportByApi = exports.reportByBeacon = exports.reportByImg = void 0;
|
|
36
|
-
/**
|
|
37
|
-
* 使用img标签方式上报数据
|
|
38
|
-
* @param data 上报数据
|
|
39
|
-
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
40
|
-
* @returns 是否上报成功
|
|
41
|
-
*/
|
|
42
36
|
function reportByImg(data, url) {
|
|
43
37
|
try {
|
|
44
38
|
var img = new Image();
|
|
45
39
|
var params = encodeURIComponent(JSON.stringify(data));
|
|
46
|
-
// 优先使用传入的url,为空时使用默认接口
|
|
47
40
|
var imgReportUrl = url + '/v1/report/collectImg';
|
|
48
41
|
img.src = "".concat(imgReportUrl, "?data=").concat(params);
|
|
49
42
|
img.onload = img.onerror = function () {
|
|
50
|
-
// 清理引用
|
|
51
43
|
img.onload = img.onerror = null;
|
|
52
44
|
};
|
|
53
45
|
return true;
|
|
@@ -57,19 +49,12 @@ function reportByImg(data, url) {
|
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
51
|
exports.reportByImg = reportByImg;
|
|
60
|
-
/**
|
|
61
|
-
* 使用sendBeacon方式上报数据
|
|
62
|
-
* @param data 上报数据
|
|
63
|
-
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
64
|
-
* @returns 是否上报成功
|
|
65
|
-
*/
|
|
66
52
|
function reportByBeacon(data, url) {
|
|
67
53
|
try {
|
|
68
54
|
if (navigator.sendBeacon) {
|
|
69
55
|
var blob = new Blob([JSON.stringify(data)], {
|
|
70
56
|
type: 'application/json'
|
|
71
57
|
});
|
|
72
|
-
// 优先使用传入的url,为空时使用默认接口
|
|
73
58
|
var apiReportUrl = url + '/v1/report/collect';
|
|
74
59
|
return navigator.sendBeacon(apiReportUrl, blob);
|
|
75
60
|
}
|
|
@@ -80,13 +65,6 @@ function reportByBeacon(data, url) {
|
|
|
80
65
|
}
|
|
81
66
|
}
|
|
82
67
|
exports.reportByBeacon = reportByBeacon;
|
|
83
|
-
/**
|
|
84
|
-
* 使用接口方式上报数据
|
|
85
|
-
* @param data 上报数据
|
|
86
|
-
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
87
|
-
* @param options 配置项
|
|
88
|
-
* @returns Promise<ReportResult>
|
|
89
|
-
*/
|
|
90
68
|
function reportByApi(data, url) {
|
|
91
69
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
92
70
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
|
|
@@ -98,14 +76,14 @@ function reportByApi(data, url) {
|
|
|
98
76
|
controller = new AbortController();
|
|
99
77
|
timeoutId = setTimeout(function () {
|
|
100
78
|
return controller.abort();
|
|
101
|
-
}, options.timeout || 5000);
|
|
79
|
+
}, options.timeout || 5000);
|
|
102
80
|
apiReportUrl = url + '/api/report/collect';
|
|
103
81
|
_context.n = 1;
|
|
104
82
|
return fetch(apiReportUrl, {
|
|
105
83
|
method: 'POST',
|
|
106
84
|
headers: {
|
|
107
85
|
'Content-Type': 'application/json',
|
|
108
|
-
'x-sdk-internal': 'true'
|
|
86
|
+
'x-sdk-internal': 'true'
|
|
109
87
|
},
|
|
110
88
|
body: JSON.stringify(data),
|
|
111
89
|
signal: controller.signal
|
|
@@ -140,12 +118,6 @@ function reportByApi(data, url) {
|
|
|
140
118
|
}));
|
|
141
119
|
}
|
|
142
120
|
exports.reportByApi = reportByApi;
|
|
143
|
-
/**
|
|
144
|
-
* 带降级策略的上报方法
|
|
145
|
-
* @param data 上报数据
|
|
146
|
-
* @param url 上报地址
|
|
147
|
-
* @returns 是否至少有一种上报方式成功
|
|
148
|
-
*/
|
|
149
121
|
function reportWithFallback(data, url) {
|
|
150
122
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
|
|
151
123
|
var img, params, imgReportUrl, blob, success, apiReportUrl, _t2, _t3, _t4;
|
|
@@ -154,7 +126,7 @@ function reportWithFallback(data, url) {
|
|
|
154
126
|
case 0:
|
|
155
127
|
_context2.p = 0;
|
|
156
128
|
img = new Image();
|
|
157
|
-
params = encodeURIComponent(JSON.stringify(data));
|
|
129
|
+
params = encodeURIComponent(JSON.stringify(data));
|
|
158
130
|
imgReportUrl = url + '/v1/report/collectImg';
|
|
159
131
|
img.src = "".concat(imgReportUrl, "?data=").concat(params);
|
|
160
132
|
return _context2.a(2, true);
|
|
@@ -184,17 +156,16 @@ function reportWithFallback(data, url) {
|
|
|
184
156
|
console.error('sendBeacon上报失败:', _t3);
|
|
185
157
|
case 5:
|
|
186
158
|
_context2.p = 5;
|
|
187
|
-
// 优先使用传入的url,为空时使用默认接口
|
|
188
159
|
apiReportUrl = url + '/v1/report/collect';
|
|
189
160
|
_context2.n = 6;
|
|
190
161
|
return fetch(apiReportUrl, {
|
|
191
162
|
method: 'POST',
|
|
192
163
|
headers: {
|
|
193
164
|
'Content-Type': 'application/json',
|
|
194
|
-
'x-sdk-internal': 'true'
|
|
165
|
+
'x-sdk-internal': 'true'
|
|
195
166
|
},
|
|
196
167
|
body: JSON.stringify(data),
|
|
197
|
-
keepalive: true
|
|
168
|
+
keepalive: true
|
|
198
169
|
});
|
|
199
170
|
case 6:
|
|
200
171
|
return _context2.a(2, true);
|
package/dist/reporters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporters.js","names":["reportByImg","data","url","img","Image","params","encodeURIComponent","JSON","stringify","imgReportUrl","src","concat","onload","onerror","error","console","exports","reportByBeacon","navigator","sendBeacon","blob","Blob","type","apiReportUrl","reportByApi","options","arguments","length","undefined","controller","AbortController","timeoutId","setTimeout","abort","timeout","_context","n","fetch","method","headers","body","signal","response","v","clearTimeout","ok","Error","status","json","result","a","success","p","_t","_callee","reportWithFallback","_context2","_t2","_t3","keepalive","_t4","_callee2"],"sources":["../reporters.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"reporters.js","names":["reportByImg","data","url","img","Image","params","encodeURIComponent","JSON","stringify","imgReportUrl","src","concat","onload","onerror","error","console","exports","reportByBeacon","navigator","sendBeacon","blob","Blob","type","apiReportUrl","reportByApi","options","arguments","length","undefined","controller","AbortController","timeoutId","setTimeout","abort","timeout","_context","n","fetch","method","headers","body","signal","response","v","clearTimeout","ok","Error","status","json","result","a","success","p","_t","_callee","reportWithFallback","_context2","_t2","_t3","keepalive","_t4","_callee2"],"sources":["../reporters.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,SAAgBA,WAAWA,CAACC,IAAoB,EAAEC,GAAW;EAC3D,IAAI;IACF,IAAMC,GAAG,GAAG,IAAIC,KAAK,EAAE;IACvB,IAAMC,MAAM,GAAGC,kBAAkB,CAACC,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC,CAAC;IAEvD,IAAMQ,YAAY,GAAGP,GAAG,GAAG,uBAAuB;IAClDC,GAAG,CAACO,GAAG,MAAAC,MAAA,CAAMF,YAAY,YAAAE,MAAA,CAASN,MAAM,CAAE;IAC1CF,GAAG,CAACS,MAAM,GAA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,GAAG,CAAC;UAAC,OAAAJ,SAAA,CAAAN,CAAA,IACxB,KAAK;MAAA;IAAA,GAAAW,QAAA;EAAA,CAGjB;;AAvCD7C,OAAA,CAAAuC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mon-reactive-h5",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "前端监控SDK - 支持页面浏览、JS错误、API请求、资源错误监控",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"LICENSE"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsc && babel dist --out-dir dist --presets=@babel/preset-env --source-maps",
|
|
13
|
+
"build": "tsc && babel dist --out-dir dist --presets=@babel/preset-env --plugins=@babel/plugin-transform-nullish-coalescing-operator,@babel/plugin-transform-optional-chaining --source-maps",
|
|
14
14
|
"dev": "tsc --watch",
|
|
15
15
|
"prepublishOnly": "npm run build",
|
|
16
16
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
"@babel/cli": "^7.22.0",
|
|
37
37
|
"@babel/core": "^7.22.0",
|
|
38
38
|
"@babel/preset-env": "^7.22.0",
|
|
39
|
+
"@babel/plugin-transform-nullish-coalescing-operator": "^7.22.0",
|
|
40
|
+
"@babel/plugin-transform-optional-chaining": "^7.22.0",
|
|
39
41
|
"typescript": "^4.5.5"
|
|
40
42
|
},
|
|
41
43
|
"engines": {
|