mon-reactive-h5 1.0.10 → 1.0.12
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/MonitorSDK.js +2 -2
- package/dist/MonitorSDK.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/reporters.js +26 -41
- package/dist/reporters.js.map +1 -1
- package/dist/umd/BatchReporter.js +396 -0
- package/dist/umd/BatchReporter.js.map +1 -0
- package/dist/umd/MonitorSDK.js +1079 -0
- package/dist/umd/MonitorSDK.js.map +1 -0
- package/dist/umd/index.js +131 -0
- package/dist/umd/index.js.map +1 -0
- package/dist/umd/mon-reactive-h5.js +21 -0
- package/dist/umd/mon-reactive-h5.js.map +1 -0
- package/dist/umd/reporters.js +336 -0
- package/dist/umd/reporters.js.map +1 -0
- package/dist/umd/types.js +26 -0
- package/dist/umd/types.js.map +1 -0
- package/package.json +14 -3
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _regenerator() {
|
|
4
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,
|
|
5
|
+
t,
|
|
6
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
7
|
+
n = r.iterator || "@@iterator",
|
|
8
|
+
o = r.toStringTag || "@@toStringTag";
|
|
9
|
+
function i(r, n, o, i) {
|
|
10
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
11
|
+
u = Object.create(c.prototype);
|
|
12
|
+
return _regeneratorDefine2(u, "_invoke", function (r, n, o) {
|
|
13
|
+
var i,
|
|
14
|
+
c,
|
|
15
|
+
u,
|
|
16
|
+
f = 0,
|
|
17
|
+
p = o || [],
|
|
18
|
+
y = !1,
|
|
19
|
+
G = {
|
|
20
|
+
p: 0,
|
|
21
|
+
n: 0,
|
|
22
|
+
v: e,
|
|
23
|
+
a: d,
|
|
24
|
+
f: d.bind(e, 4),
|
|
25
|
+
d: function d(t, r) {
|
|
26
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function d(r, n) {
|
|
30
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
31
|
+
var o,
|
|
32
|
+
i = p[t],
|
|
33
|
+
d = G.p,
|
|
34
|
+
l = i[2];
|
|
35
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
36
|
+
}
|
|
37
|
+
if (o || r > 1) return a;
|
|
38
|
+
throw y = !0, n;
|
|
39
|
+
}
|
|
40
|
+
return function (o, p, l) {
|
|
41
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
42
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
43
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
44
|
+
try {
|
|
45
|
+
if (f = 2, i) {
|
|
46
|
+
if (c || (o = "next"), t = i[o]) {
|
|
47
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
48
|
+
if (!t.done) return t;
|
|
49
|
+
u = t.value, c < 2 && (c = 0);
|
|
50
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
51
|
+
i = e;
|
|
52
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
53
|
+
} catch (t) {
|
|
54
|
+
i = e, c = 1, u = t;
|
|
55
|
+
} finally {
|
|
56
|
+
f = 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
value: t,
|
|
61
|
+
done: y
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
}(r, o, i), !0), u;
|
|
65
|
+
}
|
|
66
|
+
var a = {};
|
|
67
|
+
function Generator() {}
|
|
68
|
+
function GeneratorFunction() {}
|
|
69
|
+
function GeneratorFunctionPrototype() {}
|
|
70
|
+
t = Object.getPrototypeOf;
|
|
71
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () {
|
|
72
|
+
return this;
|
|
73
|
+
}), t),
|
|
74
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
75
|
+
function f(e) {
|
|
76
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
77
|
+
}
|
|
78
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () {
|
|
79
|
+
return this;
|
|
80
|
+
}), _regeneratorDefine2(u, "toString", function () {
|
|
81
|
+
return "[object Generator]";
|
|
82
|
+
}), (_regenerator = function _regenerator() {
|
|
83
|
+
return {
|
|
84
|
+
w: i,
|
|
85
|
+
m: f
|
|
86
|
+
};
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
function _regeneratorDefine2(e, r, n, t) {
|
|
90
|
+
var i = Object.defineProperty;
|
|
91
|
+
try {
|
|
92
|
+
i({}, "", {});
|
|
93
|
+
} catch (e) {
|
|
94
|
+
i = 0;
|
|
95
|
+
}
|
|
96
|
+
_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) {
|
|
97
|
+
function o(r, n) {
|
|
98
|
+
_regeneratorDefine2(e, r, function (e) {
|
|
99
|
+
return this._invoke(r, n, e);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
r ? i ? i(e, r, {
|
|
103
|
+
value: n,
|
|
104
|
+
enumerable: !t,
|
|
105
|
+
configurable: !t,
|
|
106
|
+
writable: !t
|
|
107
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
108
|
+
}, _regeneratorDefine2(e, r, n, t);
|
|
109
|
+
}
|
|
110
|
+
function _typeof(o) {
|
|
111
|
+
"@babel/helpers - typeof";
|
|
112
|
+
|
|
113
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
114
|
+
return typeof o;
|
|
115
|
+
} : function (o) {
|
|
116
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
117
|
+
}, _typeof(o);
|
|
118
|
+
}
|
|
119
|
+
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
120
|
+
function adopt(value) {
|
|
121
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
122
|
+
resolve(value);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
126
|
+
function fulfilled(value) {
|
|
127
|
+
try {
|
|
128
|
+
step(generator.next(value));
|
|
129
|
+
} catch (e) {
|
|
130
|
+
reject(e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function rejected(value) {
|
|
134
|
+
try {
|
|
135
|
+
step(generator["throw"](value));
|
|
136
|
+
} catch (e) {
|
|
137
|
+
reject(e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function step(result) {
|
|
141
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
142
|
+
}
|
|
143
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
(function (factory) {
|
|
147
|
+
if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" && _typeof(module.exports) === "object") {
|
|
148
|
+
var v = factory(require, exports);
|
|
149
|
+
if (v !== undefined) module.exports = v;
|
|
150
|
+
} else if (typeof define === "function" && define.amd) {
|
|
151
|
+
define(["require", "exports"], factory);
|
|
152
|
+
}
|
|
153
|
+
})(function (require, exports) {
|
|
154
|
+
"use strict";
|
|
155
|
+
|
|
156
|
+
Object.defineProperty(exports, "__esModule", {
|
|
157
|
+
value: true
|
|
158
|
+
});
|
|
159
|
+
exports.reportWithFallback = exports.reportByApi = exports.reportByBeacon = exports.reportByImg = void 0;
|
|
160
|
+
/**
|
|
161
|
+
* 使用img标签方式上报数据
|
|
162
|
+
* @param data 上报数据
|
|
163
|
+
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
164
|
+
* @returns 是否上报成功
|
|
165
|
+
*/
|
|
166
|
+
function reportByImg(data, url) {
|
|
167
|
+
try {
|
|
168
|
+
var img = new Image();
|
|
169
|
+
var params = encodeURIComponent(JSON.stringify(data));
|
|
170
|
+
// 优先使用传入的url,为空时使用默认接口
|
|
171
|
+
var imgReportUrl = url + '/v1/report/collectImg';
|
|
172
|
+
img.src = "".concat(imgReportUrl, "?data=").concat(params);
|
|
173
|
+
img.onload = img.onerror = function () {
|
|
174
|
+
// 清理引用
|
|
175
|
+
img.onload = img.onerror = null;
|
|
176
|
+
};
|
|
177
|
+
return true;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('img上报失败:', error);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.reportByImg = reportByImg;
|
|
184
|
+
/**
|
|
185
|
+
* 使用sendBeacon方式上报数据
|
|
186
|
+
* @param data 上报数据
|
|
187
|
+
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
188
|
+
* @returns 是否上报成功
|
|
189
|
+
*/
|
|
190
|
+
function reportByBeacon(data, url) {
|
|
191
|
+
try {
|
|
192
|
+
if (navigator.sendBeacon) {
|
|
193
|
+
var blob = new Blob([JSON.stringify(data)], {
|
|
194
|
+
type: 'application/json'
|
|
195
|
+
});
|
|
196
|
+
// 优先使用传入的url,为空时使用默认接口
|
|
197
|
+
var apiReportUrl = url + '/v1/report/collect';
|
|
198
|
+
return navigator.sendBeacon(apiReportUrl, blob);
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error('sendBeacon上报失败:', error);
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.reportByBeacon = reportByBeacon;
|
|
207
|
+
/**
|
|
208
|
+
* 使用接口方式上报数据
|
|
209
|
+
* @param data 上报数据
|
|
210
|
+
* @param url 上报地址(优先使用,为空时使用默认接口)
|
|
211
|
+
* @param options 配置项
|
|
212
|
+
* @returns Promise<ReportResult>
|
|
213
|
+
*/
|
|
214
|
+
function reportByApi(data, url) {
|
|
215
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
216
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
|
|
217
|
+
var controller, timeoutId, apiReportUrl, response, result, _t;
|
|
218
|
+
return _regenerator().w(function (_context) {
|
|
219
|
+
while (1) switch (_context.p = _context.n) {
|
|
220
|
+
case 0:
|
|
221
|
+
_context.p = 0;
|
|
222
|
+
controller = new AbortController();
|
|
223
|
+
timeoutId = setTimeout(function () {
|
|
224
|
+
return controller.abort();
|
|
225
|
+
}, options.timeout || 5000); // 优先使用传入的url,为空时使用默认接口
|
|
226
|
+
apiReportUrl = url + '/api/report/collect';
|
|
227
|
+
_context.n = 1;
|
|
228
|
+
return fetch(apiReportUrl, {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
headers: {
|
|
231
|
+
'Content-Type': 'application/json',
|
|
232
|
+
'x-sdk-internal': 'true' // 添加SDK内部请求标记,避免被SDK自身的fetch拦截器拦截
|
|
233
|
+
},
|
|
234
|
+
body: JSON.stringify(data),
|
|
235
|
+
signal: controller.signal
|
|
236
|
+
});
|
|
237
|
+
case 1:
|
|
238
|
+
response = _context.v;
|
|
239
|
+
clearTimeout(timeoutId);
|
|
240
|
+
if (response.ok) {
|
|
241
|
+
_context.n = 2;
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
throw new Error("HTTP error! status: ".concat(response.status));
|
|
245
|
+
case 2:
|
|
246
|
+
_context.n = 3;
|
|
247
|
+
return response.json();
|
|
248
|
+
case 3:
|
|
249
|
+
result = _context.v;
|
|
250
|
+
return _context.a(2, {
|
|
251
|
+
success: true,
|
|
252
|
+
data: result
|
|
253
|
+
});
|
|
254
|
+
case 4:
|
|
255
|
+
_context.p = 4;
|
|
256
|
+
_t = _context.v;
|
|
257
|
+
console.error('接口上报失败:', _t);
|
|
258
|
+
return _context.a(2, {
|
|
259
|
+
success: false,
|
|
260
|
+
error: _t
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}, _callee, null, [[0, 4]]);
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
exports.reportByApi = reportByApi;
|
|
267
|
+
/**
|
|
268
|
+
* 带降级策略的上报方法
|
|
269
|
+
* @param data 上报数据
|
|
270
|
+
* @param url 上报地址
|
|
271
|
+
* @returns 是否至少有一种上报方式成功
|
|
272
|
+
*/
|
|
273
|
+
function reportWithFallback(data, url) {
|
|
274
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
|
|
275
|
+
var img, params, imgReportUrl, blob, success, apiReportUrl, _t2, _t3, _t4;
|
|
276
|
+
return _regenerator().w(function (_context2) {
|
|
277
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
278
|
+
case 0:
|
|
279
|
+
_context2.p = 0;
|
|
280
|
+
img = new Image();
|
|
281
|
+
params = encodeURIComponent(JSON.stringify(data)); // 优先使用传入的url,为空时使用默认接口
|
|
282
|
+
imgReportUrl = url + '/v1/report/collectImg';
|
|
283
|
+
img.src = "".concat(imgReportUrl, "?data=").concat(params);
|
|
284
|
+
return _context2.a(2, true);
|
|
285
|
+
case 1:
|
|
286
|
+
_context2.p = 1;
|
|
287
|
+
_t2 = _context2.v;
|
|
288
|
+
_context2.p = 2;
|
|
289
|
+
if (!navigator.sendBeacon) {
|
|
290
|
+
_context2.n = 3;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
blob = new Blob([JSON.stringify(data)], {
|
|
294
|
+
type: 'application/json'
|
|
295
|
+
});
|
|
296
|
+
success = navigator.sendBeacon(url, blob);
|
|
297
|
+
if (!success) {
|
|
298
|
+
_context2.n = 3;
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
return _context2.a(2, true);
|
|
302
|
+
case 3:
|
|
303
|
+
_context2.n = 5;
|
|
304
|
+
break;
|
|
305
|
+
case 4:
|
|
306
|
+
_context2.p = 4;
|
|
307
|
+
_t3 = _context2.v;
|
|
308
|
+
console.error('sendBeacon上报失败:', _t3);
|
|
309
|
+
case 5:
|
|
310
|
+
_context2.p = 5;
|
|
311
|
+
// 优先使用传入的url,为空时使用默认接口
|
|
312
|
+
apiReportUrl = url + '/v1/report/collect';
|
|
313
|
+
_context2.n = 6;
|
|
314
|
+
return fetch(apiReportUrl, {
|
|
315
|
+
method: 'POST',
|
|
316
|
+
headers: {
|
|
317
|
+
'Content-Type': 'application/json',
|
|
318
|
+
'x-sdk-internal': 'true' // 添加SDK内部请求标记,避免被SDK自身的fetch拦截器拦截
|
|
319
|
+
},
|
|
320
|
+
body: JSON.stringify(data),
|
|
321
|
+
keepalive: true // 尝试使用keepalive
|
|
322
|
+
});
|
|
323
|
+
case 6:
|
|
324
|
+
return _context2.a(2, true);
|
|
325
|
+
case 7:
|
|
326
|
+
_context2.p = 7;
|
|
327
|
+
_t4 = _context2.v;
|
|
328
|
+
console.error('所有上报方式均失败:', _t4);
|
|
329
|
+
return _context2.a(2, false);
|
|
330
|
+
}
|
|
331
|
+
}, _callee2, null, [[5, 7], [2, 4], [0, 1]]);
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
exports.reportWithFallback = reportWithFallback;
|
|
335
|
+
});
|
|
336
|
+
//# sourceMappingURL=reporters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporters.js","names":["e","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","return","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","_regenerator","w","m","defineProperty","_regeneratorDefine","_invoke","enumerable","configurable","writable","_typeof","constructor","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","rejected","result","then","apply","factory","module","exports","require","undefined","define","amd","reportWithFallback","reportByApi","reportByBeacon","reportByImg","data","url","img","Image","params","encodeURIComponent","JSON","stringify","imgReportUrl","src","concat","onload","onerror","error","console","navigator","sendBeacon","blob","Blob","type","apiReportUrl","options","arguments","_callee","controller","timeoutId","response","_t","_context","AbortController","setTimeout","abort","timeout","fetch","method","headers","body","signal","clearTimeout","ok","Error","status","json","success","_callee2","_t2","_t3","_t4","_context2","keepalive"],"sources":["reporters.js"],"sourcesContent":["var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\n(function (factory) {\r\n if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n var v = factory(require, exports);\r\n if (v !== undefined) module.exports = v;\r\n }\r\n else if (typeof define === \"function\" && define.amd) {\r\n define([\"require\", \"exports\"], factory);\r\n }\r\n})(function (require, exports) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n exports.reportWithFallback = exports.reportByApi = exports.reportByBeacon = exports.reportByImg = void 0;\r\n /**\r\n * 使用img标签方式上报数据\r\n * @param data 上报数据\r\n * @param url 上报地址(优先使用,为空时使用默认接口)\r\n * @returns 是否上报成功\r\n */\r\n function reportByImg(data, url) {\r\n try {\r\n const img = new Image();\r\n const params = encodeURIComponent(JSON.stringify(data));\r\n // 优先使用传入的url,为空时使用默认接口\r\n const imgReportUrl = url + '/v1/report/collectImg';\r\n img.src = `${imgReportUrl}?data=${params}`;\r\n img.onload = img.onerror = function () {\r\n // 清理引用\r\n img.onload = img.onerror = null;\r\n };\r\n return true;\r\n }\r\n catch (error) {\r\n console.error('img上报失败:', error);\r\n return false;\r\n }\r\n }\r\n exports.reportByImg = reportByImg;\r\n /**\r\n * 使用sendBeacon方式上报数据\r\n * @param data 上报数据\r\n * @param url 上报地址(优先使用,为空时使用默认接口)\r\n * @returns 是否上报成功\r\n */\r\n function reportByBeacon(data, url) {\r\n try {\r\n if (navigator.sendBeacon) {\r\n const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });\r\n // 优先使用传入的url,为空时使用默认接口\r\n const apiReportUrl = url + '/v1/report/collect';\r\n return navigator.sendBeacon(apiReportUrl, blob);\r\n }\r\n return false;\r\n }\r\n catch (error) {\r\n console.error('sendBeacon上报失败:', error);\r\n return false;\r\n }\r\n }\r\n exports.reportByBeacon = reportByBeacon;\r\n /**\r\n * 使用接口方式上报数据\r\n * @param data 上报数据\r\n * @param url 上报地址(优先使用,为空时使用默认接口)\r\n * @param options 配置项\r\n * @returns Promise<ReportResult>\r\n */\r\n function reportByApi(data, url, options = {}) {\r\n return __awaiter(this, void 0, void 0, function* () {\r\n try {\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), options.timeout || 5000);\r\n // 优先使用传入的url,为空时使用默认接口\r\n const apiReportUrl = url + '/api/report/collect';\r\n const response = yield fetch(apiReportUrl, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'x-sdk-internal': 'true' // 添加SDK内部请求标记,避免被SDK自身的fetch拦截器拦截\r\n },\r\n body: JSON.stringify(data),\r\n signal: controller.signal,\r\n });\r\n clearTimeout(timeoutId);\r\n if (!response.ok) {\r\n throw new Error(`HTTP error! status: ${response.status}`);\r\n }\r\n const result = yield response.json();\r\n return {\r\n success: true,\r\n data: result\r\n };\r\n }\r\n catch (error) {\r\n console.error('接口上报失败:', error);\r\n return {\r\n success: false,\r\n error: error\r\n };\r\n }\r\n });\r\n }\r\n exports.reportByApi = reportByApi;\r\n /**\r\n * 带降级策略的上报方法\r\n * @param data 上报数据\r\n * @param url 上报地址\r\n * @returns 是否至少有一种上报方式成功\r\n */\r\n function reportWithFallback(data, url) {\r\n return __awaiter(this, void 0, void 0, function* () {\r\n // 1. 降级到 img 上报\r\n try {\r\n const img = new Image();\r\n const params = encodeURIComponent(JSON.stringify(data));\r\n // 优先使用传入的url,为空时使用默认接口\r\n const imgReportUrl = url + '/v1/report/collectImg';\r\n img.src = `${imgReportUrl}?data=${params}`;\r\n return true;\r\n }\r\n catch (e) {\r\n try {\r\n // 1. 优先尝试 sendBeacon\r\n if (navigator.sendBeacon) {\r\n const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });\r\n const success = navigator.sendBeacon(url, blob);\r\n if (success)\r\n return true;\r\n }\r\n }\r\n catch (e) {\r\n console.error('sendBeacon上报失败:', e);\r\n }\r\n // 3. 最后降级到 fetch API上报\r\n try {\r\n // 优先使用传入的url,为空时使用默认接口\r\n const apiReportUrl = url + '/v1/report/collect';\r\n yield fetch(apiReportUrl, {\r\n method: 'POST',\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'x-sdk-internal': 'true' // 添加SDK内部请求标记,避免被SDK自身的fetch拦截器拦截\r\n },\r\n body: JSON.stringify(data),\r\n keepalive: true, // 尝试使用keepalive\r\n });\r\n return true;\r\n }\r\n catch (e) {\r\n console.error('所有上报方式均失败:', e);\r\n return false;\r\n }\r\n }\r\n });\r\n }\r\n exports.reportWithFallback = reportWithFallback;\r\n});\r\n"],"mappings":";;;EACA,sKAAAA,CAAA;IAAAC,CAAA;IAAAC,CAAA,wBAAAC,MAAA,GAAAA,MAAA;IAAAC,CAAA,GAAAF,CAAA,CAAAG,QAAA;IAAAC,CAAA,GAAAJ,CAAA,CAAAK,WAAA;EAAA,SAAAC,EAAAN,CAAA,EAAAE,CAAA,EAAAE,CAAA,EAAAE,CAAA;IAAA,IAAAC,CAAA,GAAAL,CAAA,IAAAA,CAAA,CAAAM,SAAA,YAAAC,SAAA,GAAAP,CAAA,GAAAO,SAAA;MAAAC,CAAA,GAAAC,MAAA,CAAAC,MAAA,CAAAL,CAAA,CAAAC,SAAA;IAAA,OAAAK,mBAAA,CAAAH,CAAA,uBAAAV,CAAA,EAAAE,CAAA,EAAAE,CAAA;MAAA,IAAAE,CAAA;QAAAC,CAAA;QAAAG,CAAA;QAAAI,CAAA;QAAAC,CAAA,GAAAX,CAAA;QAAAY,CAAA;QAAAC,CAAA;UAAAF,CAAA;UAAAb,CAAA;UAAAgB,CAAA,EAAApB,CAAA;UAAAqB,CAAA,EAAAC,CAAA;UAAAN,CAAA,EAAAM,CAAA,CAAAC,IAAA,CAAAvB,CAAA;UAAAsB,CAAA,WAAAA,EAAArB,CAAA,EAAAC,CAAA;YAAA,OAAAM,CAAA,GAAAP,CAAA,EAAAQ,CAAA,MAAAG,CAAA,GAAAZ,CAAA,EAAAmB,CAAA,CAAAf,CAAA,GAAAF,CAAA,EAAAmB,CAAA;UAAA;QAAA;MAAA,SAAAC,EAAApB,C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AA;YAIpC;YACM8E,YAAY,GAAGnB,GAAG,GAAG,oBAAoB;YAAA+C,SAAA,CAAAvH,CAAA;YAC/C,OAAMwG,KAAK,CAACb,YAAY,EAAE;cACtBc,MAAM,EAAE,MAAM;cACdC,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,gBAAgB,EAAE,MAAM,CAAC;cAC7B,CAAC;cACDC,IAAI,EAAE9B,IAAI,CAACC,SAAS,CAACP,IAAI,CAAC;cAC1BiD,SAAS,EAAE,IAAI,CAAE;YACrB,CAAC,CAAC;UAAA;YAAA,OAAAD,SAAA,CAAAtG,CAAA,IACK,IAAI;UAAA;YAAAsG,SAAA,CAAA1G,CAAA;YAAAyG,GAAA,GAAAC,SAAA,CAAAvG,CAAA;YAGXqE,OAAO,CAACD,KAAK,CAAC,YAAY,EAAAkC,GAAG,CAAC;YAAC,OAAAC,SAAA,CAAAtG,CAAA,IACxB,KAAK;QAAA;MAAA,GAAAkG,QAAA;IAAA,CAGvB,EAAC;EACN;EACArD,OAAO,CAACK,kBAAkB,GAAGA,kBAAkB;AACnD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) {
|
|
4
|
+
"@babel/helpers - typeof";
|
|
5
|
+
|
|
6
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
7
|
+
return typeof o;
|
|
8
|
+
} : function (o) {
|
|
9
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
10
|
+
}, _typeof(o);
|
|
11
|
+
}
|
|
12
|
+
(function (factory) {
|
|
13
|
+
if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" && _typeof(module.exports) === "object") {
|
|
14
|
+
var v = factory(require, exports);
|
|
15
|
+
if (v !== undefined) module.exports = v;
|
|
16
|
+
} else if (typeof define === "function" && define.amd) {
|
|
17
|
+
define(["require", "exports"], factory);
|
|
18
|
+
}
|
|
19
|
+
})(function (require, exports) {
|
|
20
|
+
"use strict";
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["factory","module","_typeof","exports","v","require","undefined","define","amd","Object","defineProperty","value"],"sources":["types.js"],"sourcesContent":["(function (factory) {\r\n if (typeof module === \"object\" && typeof module.exports === \"object\") {\r\n var v = factory(require, exports);\r\n if (v !== undefined) module.exports = v;\r\n }\r\n else if (typeof define === \"function\" && define.amd) {\r\n define([\"require\", \"exports\"], factory);\r\n }\r\n})(function (require, exports) {\r\n \"use strict\";\r\n Object.defineProperty(exports, \"__esModule\", { value: true });\r\n});\r\n"],"mappings":";;;;;;;;;;;AAAA,CAAC,UAAUA,OAAO,EAAE;EAChB,IAAI,QAAOC,MAAM,iCAAAC,OAAA,CAAND,MAAM,OAAK,QAAQ,IAAIC,OAAA,CAAOD,MAAM,CAACE,OAAO,MAAK,QAAQ,EAAE;IAClE,IAAIC,CAAC,GAAGJ,OAAO,CAACK,OAAO,EAAEF,OAAO,CAAC;IACjC,IAAIC,CAAC,KAAKE,SAAS,EAAEL,MAAM,CAACE,OAAO,GAAGC,CAAC;EAC3C,CAAC,MACI,IAAI,OAAOG,MAAM,KAAK,UAAU,IAAIA,MAAM,CAACC,GAAG,EAAE;IACjDD,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,EAAEP,OAAO,CAAC;EAC3C;AACJ,CAAC,EAAE,UAAUK,OAAO,EAAEF,OAAO,EAAE;EAC3B,YAAY;;EACZM,MAAM,CAACC,cAAc,CAACP,OAAO,EAAE,YAAY,EAAE;IAAEQ,KAAK,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mon-reactive-h5",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "前端监控SDK - 支持页面浏览、JS错误、API请求、资源错误监控",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"browser": "dist/umd/mon-reactive-h5.js",
|
|
8
|
+
"unpkg": "dist/umd/mon-reactive-h5.js",
|
|
9
|
+
"jsdelivr": "dist/umd/mon-reactive-h5.js",
|
|
7
10
|
"files": [
|
|
8
11
|
"dist",
|
|
9
12
|
"README.md",
|
|
@@ -11,8 +14,12 @@
|
|
|
11
14
|
],
|
|
12
15
|
"scripts": {
|
|
13
16
|
"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",
|
|
17
|
+
"build:umd": "powershell -Command \"mkdir -Force dist/umd; Copy-Item umd-wrapper.js dist/umd/mon-reactive-h5.js; Write-Host 'UMD包装已创建,用于CDN引入'\"",
|
|
18
|
+
"build:cdn": "npm run build && powershell -Command \"mkdir -Force dist/umd; Copy-Item umd-wrapper.js dist/umd/mon-reactive-h5.js; Write-Host 'CDN版本已构建完成'\"",
|
|
19
|
+
"prepare-cdn": "powershell -Command \"mkdir -Force dist/umd; Copy-Item umd-wrapper.js dist/umd/mon-reactive-h5.js; Write-Host 'CDN版本已准备完成'\"",
|
|
20
|
+
"build:all": "npm run build && npm run build:umd",
|
|
14
21
|
"dev": "tsc --watch",
|
|
15
|
-
"prepublishOnly": "npm run build",
|
|
22
|
+
"prepublishOnly": "npm run build:all",
|
|
16
23
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
24
|
},
|
|
18
25
|
"keywords": [
|
|
@@ -38,7 +45,11 @@
|
|
|
38
45
|
"@babel/preset-env": "^7.22.0",
|
|
39
46
|
"@babel/plugin-transform-nullish-coalescing-operator": "^7.22.0",
|
|
40
47
|
"@babel/plugin-transform-optional-chaining": "^7.22.0",
|
|
41
|
-
"typescript": "^4.5.5"
|
|
48
|
+
"typescript": "^4.5.5",
|
|
49
|
+
"webpack": "^5.88.0",
|
|
50
|
+
"webpack-cli": "^5.1.0",
|
|
51
|
+
"@types/node": "^20.0.0",
|
|
52
|
+
"clean-webpack-plugin": "^4.0.0"
|
|
42
53
|
},
|
|
43
54
|
"engines": {
|
|
44
55
|
"node": ">=12.0.0"
|