mon-reactive-h5 1.0.8 → 1.0.9

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.
@@ -1,32 +1,32 @@
1
- import { BaseReportData, ReportResult } from './types';
2
- /**
3
- * 使用img标签方式上报数据
4
- * @param data 上报数据
5
- * @param url 上报地址(优先使用,为空时使用默认接口)
6
- * @returns 是否上报成功
7
- */
8
- export declare function reportByImg(data: BaseReportData, url: string): boolean;
9
- /**
10
- * 使用sendBeacon方式上报数据
11
- * @param data 上报数据
12
- * @param url 上报地址(优先使用,为空时使用默认接口)
13
- * @returns 是否上报成功
14
- */
15
- 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
- export declare function reportByApi(data: BaseReportData, url: string, options?: {
24
- timeout?: number;
25
- }): Promise<ReportResult>;
26
- /**
27
- * 带降级策略的上报方法
28
- * @param data 上报数据
29
- * @param url 上报地址
30
- * @returns 是否至少有一种上报方式成功
31
- */
32
- export declare function reportWithFallback(data: BaseReportData, url: string): Promise<boolean>;
1
+ import { BaseReportData, ReportResult } from './types';
2
+ /**
3
+ * 使用img标签方式上报数据
4
+ * @param data 上报数据
5
+ * @param url 上报地址(优先使用,为空时使用默认接口)
6
+ * @returns 是否上报成功
7
+ */
8
+ export declare function reportByImg(data: BaseReportData, url: string): boolean;
9
+ /**
10
+ * 使用sendBeacon方式上报数据
11
+ * @param data 上报数据
12
+ * @param url 上报地址(优先使用,为空时使用默认接口)
13
+ * @returns 是否上报成功
14
+ */
15
+ 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
+ export declare function reportByApi(data: BaseReportData, url: string, options?: {
24
+ timeout?: number;
25
+ }): Promise<ReportResult>;
26
+ /**
27
+ * 带降级策略的上报方法
28
+ * @param data 上报数据
29
+ * @param url 上报地址
30
+ * @returns 是否至少有一种上报方式成功
31
+ */
32
+ export declare function reportWithFallback(data: BaseReportData, url: string): Promise<boolean>;
package/dist/reporters.js CHANGED
@@ -32,15 +32,12 @@ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P
32
32
  Object.defineProperty(exports, "__esModule", {
33
33
  value: true
34
34
  });
35
- exports.reportByImg = reportByImg;
36
- exports.reportByBeacon = reportByBeacon;
37
- exports.reportByApi = reportByApi;
38
- exports.reportWithFallback = reportWithFallback;
39
- /**
40
- * 使用img标签方式上报数据
41
- * @param data 上报数据
42
- * @param url 上报地址(优先使用,为空时使用默认接口)
43
- * @returns 是否上报成功
35
+ exports.reportWithFallback = exports.reportByApi = exports.reportByBeacon = exports.reportByImg = void 0;
36
+ /**
37
+ * 使用img标签方式上报数据
38
+ * @param data 上报数据
39
+ * @param url 上报地址(优先使用,为空时使用默认接口)
40
+ * @returns 是否上报成功
44
41
  */
45
42
  function reportByImg(data, url) {
46
43
  try {
@@ -59,11 +56,12 @@ function reportByImg(data, url) {
59
56
  return false;
60
57
  }
61
58
  }
62
- /**
63
- * 使用sendBeacon方式上报数据
64
- * @param data 上报数据
65
- * @param url 上报地址(优先使用,为空时使用默认接口)
66
- * @returns 是否上报成功
59
+ exports.reportByImg = reportByImg;
60
+ /**
61
+ * 使用sendBeacon方式上报数据
62
+ * @param data 上报数据
63
+ * @param url 上报地址(优先使用,为空时使用默认接口)
64
+ * @returns 是否上报成功
67
65
  */
68
66
  function reportByBeacon(data, url) {
69
67
  try {
@@ -81,72 +79,72 @@ function reportByBeacon(data, url) {
81
79
  return false;
82
80
  }
83
81
  }
84
- /**
85
- * 使用接口方式上报数据
86
- * @param data 上报数据
87
- * @param url 上报地址(优先使用,为空时使用默认接口)
88
- * @param options 配置项
89
- * @returns Promise<ReportResult>
82
+ exports.reportByBeacon = reportByBeacon;
83
+ /**
84
+ * 使用接口方式上报数据
85
+ * @param data 上报数据
86
+ * @param url 上报地址(优先使用,为空时使用默认接口)
87
+ * @param options 配置项
88
+ * @returns Promise<ReportResult>
90
89
  */
91
- function reportByApi(data_1, url_1) {
92
- return __awaiter(this, arguments, void 0, function (data, url) {
93
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
94
- return /*#__PURE__*/_regenerator().m(function _callee() {
95
- var controller, timeoutId, apiReportUrl, response, result, _t;
96
- return _regenerator().w(function (_context) {
97
- while (1) switch (_context.p = _context.n) {
98
- case 0:
99
- _context.p = 0;
100
- controller = new AbortController();
101
- timeoutId = setTimeout(function () {
102
- return controller.abort();
103
- }, options.timeout || 5000); // 优先使用传入的url,为空时使用默认接口
104
- apiReportUrl = url + '/api/report/collect';
105
- _context.n = 1;
106
- return fetch(apiReportUrl, {
107
- method: 'POST',
108
- headers: {
109
- 'Content-Type': 'application/json',
110
- 'x-sdk-internal': 'true' // 添加SDK内部请求标记,避免被SDK自身的fetch拦截器拦截
111
- },
112
- body: JSON.stringify(data),
113
- signal: controller.signal
114
- });
115
- case 1:
116
- response = _context.v;
117
- clearTimeout(timeoutId);
118
- if (response.ok) {
119
- _context.n = 2;
120
- break;
121
- }
122
- throw new Error("HTTP error! status: ".concat(response.status));
123
- case 2:
124
- _context.n = 3;
125
- return response.json();
126
- case 3:
127
- result = _context.v;
128
- return _context.a(2, {
129
- success: true,
130
- data: result
131
- });
132
- case 4:
133
- _context.p = 4;
134
- _t = _context.v;
135
- console.error('接口上报失败:', _t);
136
- return _context.a(2, {
137
- success: false,
138
- error: _t
139
- });
140
- }
141
- }, _callee, null, [[0, 4]]);
142
- })();
143
- });
90
+ function reportByApi(data, url) {
91
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
92
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
93
+ var controller, timeoutId, apiReportUrl, response, result, _t;
94
+ return _regenerator().w(function (_context) {
95
+ while (1) switch (_context.p = _context.n) {
96
+ case 0:
97
+ _context.p = 0;
98
+ controller = new AbortController();
99
+ timeoutId = setTimeout(function () {
100
+ return controller.abort();
101
+ }, options.timeout || 5000); // 优先使用传入的url,为空时使用默认接口
102
+ apiReportUrl = url + '/api/report/collect';
103
+ _context.n = 1;
104
+ return fetch(apiReportUrl, {
105
+ method: 'POST',
106
+ headers: {
107
+ 'Content-Type': 'application/json',
108
+ 'x-sdk-internal': 'true' // 添加SDK内部请求标记,避免被SDK自身的fetch拦截器拦截
109
+ },
110
+ body: JSON.stringify(data),
111
+ signal: controller.signal
112
+ });
113
+ case 1:
114
+ response = _context.v;
115
+ clearTimeout(timeoutId);
116
+ if (response.ok) {
117
+ _context.n = 2;
118
+ break;
119
+ }
120
+ throw new Error("HTTP error! status: ".concat(response.status));
121
+ case 2:
122
+ _context.n = 3;
123
+ return response.json();
124
+ case 3:
125
+ result = _context.v;
126
+ return _context.a(2, {
127
+ success: true,
128
+ data: result
129
+ });
130
+ case 4:
131
+ _context.p = 4;
132
+ _t = _context.v;
133
+ console.error('接口上报失败:', _t);
134
+ return _context.a(2, {
135
+ success: false,
136
+ error: _t
137
+ });
138
+ }
139
+ }, _callee, null, [[0, 4]]);
140
+ }));
144
141
  }
145
- /**
146
- * 带降级策略的上报方法
147
- * @param data 上报数据
148
- * @param url 上报地址
149
- * @returns 是否至少有一种上报方式成功
142
+ exports.reportByApi = reportByApi;
143
+ /**
144
+ * 带降级策略的上报方法
145
+ * @param data 上报数据
146
+ * @param url 上报地址
147
+ * @returns 是否至少有一种上报方式成功
150
148
  */
151
149
  function reportWithFallback(data, url) {
152
150
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
@@ -209,4 +207,5 @@ function reportWithFallback(data, url) {
209
207
  }, _callee2, null, [[5, 7], [2, 4], [0, 1]]);
210
208
  }));
211
209
  }
210
+ exports.reportWithFallback = reportWithFallback;
212
211
  //# sourceMappingURL=reporters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reporters.js","names":["exports","reportByImg","reportByBeacon","reportByApi","reportWithFallback","data","url","img","Image","params","encodeURIComponent","JSON","stringify","imgReportUrl","src","concat","onload","onerror","error","console","navigator","sendBeacon","blob","Blob","type","apiReportUrl","data_1","url_1","options","arguments","length","undefined","_regenerator","m","_callee","controller","timeoutId","response","result","_t","w","_context","p","n","AbortController","setTimeout","abort","timeout","fetch","method","headers","body","signal","v","clearTimeout","ok","Error","status","json","a","success","_context2","_t2","_t3","keepalive","_t4","_callee2"],"sources":["../reporters.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQAA,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAwBAD,OAAA,CAAAE,cAAA,GAAAA,cAAA;AAsBAF,OAAA,CAAAG,WAAA,GAAAA,WAAA;AA+CAH,OAAA,CAAAI,kBAAA,GAAAA,kBAAA;AAnGA;;;;;;AAMA,SAAgBH,WAAWA,CAACI,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;IACvD;IACA,IAAMQ,YAAY,GAAGP,GAAG,GAAG,uBAAuB;IAClDC,GAAG,CAACO,GAAG,MAAAC,MAAA,CAAMF,YAAY,YAAAE,MAAA,CAASN,MAAM,CAAE;IAC1CF,GAAG,CAACS,MAAM,GAAGT,GAAG,CAACU,OAAO,GAAG;MACzB;MACAV,GAAG,CAACS,MAAM,GAAGT,GAAG,CAACU,OAAO,GAAG,IAAI;IACjC,CAAC;IACD,OAAO,IAAI;EACb,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,UAAU,EAAEA,KAAK,CAAC;IAChC,OAAO,K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,SAAA,CAAAR,CAAA;UAEXlC,OAAO,CAACD,KAAK,CAAC,YAAY,EAAA+C,GAAG,CAAC;UAAC,OAAAJ,SAAA,CAAAF,CAAA,IACxB,KAAK;MAAA;IAAA,GAAAO,QAAA;EAAA,CAGjB","ignoreList":[]}
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;AAMA,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;IACvD;IACA,IAAMQ,YAAY,GAAGP,GAAG,GAAG,uBAAuB;IAClDC,GAAG,CAACO,GAAG,MAAAC,MAAA,CAAMF,YAAY,YAAAE,MAAA,CAASN,MAAM,CAAE;IAC1CF,GAAG,CAACS,MAAM,GAAGT,GAAG,CAACU,OAAO,GAAG;MACzB;MACAV,GAAG,CAACS,MAAM,GAAGT,GAAG,CAACU,OAAO,GAAG,IAAI;IACjC,CAAC;IACD,OAAO,IAAI;GACZ,CAAC,OAAOC,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,UAAU,EAAEA,KAAK,CAAC;IAChC,OAAO,KAAK;;AAEhB;AAhBAE,OAAA,CAAAhB,WAAA,GAAAA,WAAA;AAkBA;;;;;;AAMA,SAAgB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portData {
2
- type: string;
3
- data?: any;
4
- version?: string;
5
- }
6
- export interface PageViewData {
7
- appId: string;
8
- version?: string;
9
- pageUrl: string;
10
- pageTitle: string;
11
- referrer: string;
12
- timestamp: number;
13
- duration: number;
14
- isFirstVisit: boolean;
15
- sessionId: string;
16
- userId?: string;
17
- deviceInfo: {
18
- browser: string;
19
- browserVersion: string;
20
- os: string;
21
- osVersion: string;
22
- deviceType: string;
23
- screenWidth: number;
24
- screenHeight: number;
25
- language: string;
26
- };
27
- networkInfo: {
28
- type: string;
29
- effectiveType: string;
30
- };
31
- performance: {
32
- navigationStart: number;
33
- domContentLoadedEventEnd: number;
34
- loadEventEnd: number;
35
- };
36
- }
37
- export interface JsErrorData {
38
- appId: string;
39
- version?: string;
40
- message: string;
41
- errorType: string;
42
- file: string;
43
- line: number;
44
- column: number;
45
- stack: string;
46
- timestamp: number;
47
- url: string;
48
- sessionId: string;
49
- userId?: string;
50
- deviceInfo: {
51
- browser: string;
52
- browserVersion: string;
53
- os: string;
54
- osVersion: string;
55
- deviceType: string;
56
- };
57
- }
58
- export interface ApiData {
59
- appId: string;
60
- version?: string;
61
- requestId: string;
62
- url: string;
63
- fullUrl: string;
64
- method: string;
65
- status: number;
66
- isError: boolean;
67
- errorType?: string;
68
- responseTime: number;
69
- timestamp: number;
70
- pageUrl: string;
71
- sessionId: string;
72
- userId?: string;
73
- requestHeaders?: Record<string, any>;
74
- requestBodySize?: number;
75
- responseBodySize?: number;
76
- networkInfo?: {
77
- type?: string;
78
- };
79
- }
80
- export interface ResourceData {
81
- appId: string;
82
- version?: string;
83
- url: string;
84
- type: string;
85
- status: number;
86
- errorType: string;
87
- timestamp: number;
88
- pageUrl: string;
89
- sessionId: string;
90
- userId?: string;
91
- duration: number;
92
- initiator: string;
93
- size: number;
94
- }
95
- export interface MonitorSDKConfig {
96
- appId: string;
97
- reportUrl: string;
98
- userId?: string;
99
- version?: string;
100
- sampleRates?: {
101
- pageview?: number;
102
- jserror?: number;
103
- api?: number;
104
- resource?: number;
105
- [key: string]: number | undefined;
106
- };
107
- batchSize?: number;
108
- interval?: number;
109
- }
110
- export interface BatchReporterConfig {
111
- url: string;
112
- batchSize: number;
113
- interval: number;
114
- }
115
- export type ReportDataType = 'pageview' | 'jserror' | 'api' | 'resource' | string;
116
- export interface ReportResult {
117
- success: boolean;
118
- data?: any;
119
- error?: Error;
120
- }
1
+ export interface BaseReportData {
2
+ type: string;
3
+ data?: any;
4
+ version?: string;
5
+ }
6
+ export interface PageViewData {
7
+ appId: string;
8
+ version?: string;
9
+ pageUrl: string;
10
+ pageTitle: string;
11
+ referrer: string;
12
+ timestamp: number;
13
+ duration: number;
14
+ isFirstVisit: boolean;
15
+ sessionId: string;
16
+ userId?: string;
17
+ deviceInfo: {
18
+ browser: string;
19
+ browserVersion: string;
20
+ os: string;
21
+ osVersion: string;
22
+ deviceType: string;
23
+ screenWidth: number;
24
+ screenHeight: number;
25
+ language: string;
26
+ };
27
+ networkInfo: {
28
+ type: string;
29
+ effectiveType: string;
30
+ };
31
+ performance: {
32
+ navigationStart: number;
33
+ domContentLoadedEventEnd: number;
34
+ loadEventEnd: number;
35
+ };
36
+ }
37
+ export interface JsErrorData {
38
+ appId: string;
39
+ version?: string;
40
+ message: string;
41
+ errorType: string;
42
+ file: string;
43
+ line: number;
44
+ column: number;
45
+ stack: string;
46
+ timestamp: number;
47
+ url: string;
48
+ sessionId: string;
49
+ userId?: string;
50
+ deviceInfo: {
51
+ browser: string;
52
+ browserVersion: string;
53
+ os: string;
54
+ osVersion: string;
55
+ deviceType: string;
56
+ };
57
+ }
58
+ export interface ApiData {
59
+ appId: string;
60
+ version?: string;
61
+ requestId: string;
62
+ url: string;
63
+ fullUrl: string;
64
+ method: string;
65
+ status: number;
66
+ isError: boolean;
67
+ errorType?: string;
68
+ responseTime: number;
69
+ timestamp: number;
70
+ pageUrl: string;
71
+ sessionId: string;
72
+ userId?: string;
73
+ requestHeaders?: Record<string, any>;
74
+ requestBodySize?: number;
75
+ responseBodySize?: number;
76
+ networkInfo?: {
77
+ type?: string;
78
+ };
79
+ }
80
+ export interface ResourceData {
81
+ appId: string;
82
+ version?: string;
83
+ url: string;
84
+ type: string;
85
+ status: number;
86
+ errorType: string;
87
+ timestamp: number;
88
+ pageUrl: string;
89
+ sessionId: string;
90
+ userId?: string;
91
+ duration: number;
92
+ initiator: string;
93
+ size: number;
94
+ }
95
+ export interface MonitorSDKConfig {
96
+ appId: string;
97
+ reportUrl: string;
98
+ userId?: string;
99
+ version?: string;
100
+ sampleRates?: {
101
+ pageview?: number;
102
+ jserror?: number;
103
+ api?: number;
104
+ resource?: number;
105
+ [key: string]: number | undefined;
106
+ };
107
+ batchSize?: number;
108
+ interval?: number;
109
+ }
110
+ export interface BatchReporterConfig {
111
+ url: string;
112
+ batchSize: number;
113
+ interval: number;
114
+ }
115
+ export type ReportDataType = 'pageview' | 'jserror' | 'api' | 'resource' | string;
116
+ export interface ReportResult {
117
+ success: boolean;
118
+ data?: any;
119
+ error?: Error;
120
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mon-reactive-h5",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "前端监控SDK - 支持页面浏览、JS错误、API请求、资源错误监控",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,15 +36,19 @@
36
36
  "@babel/cli": "^7.22.0",
37
37
  "@babel/core": "^7.22.0",
38
38
  "@babel/preset-env": "^7.22.0",
39
- "typescript": "^5.0.0"
39
+ "typescript": "^4.5.5"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=12.0.0"
43
43
  },
44
+ "dependencies": {
45
+ "fs-extra": "^9.1.0",
46
+ "core-js": "^3.30.0"
47
+ },
44
48
  "browserslist": [
45
49
  "> 1%",
46
50
  "last 2 versions",
47
51
  "not dead",
48
52
  "IE 11"
49
53
  ]
50
- }
54
+ }