@haluo/util 1.0.30 → 1.0.32
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.
|
@@ -31,6 +31,8 @@ function injectXHR(data) {
|
|
|
31
31
|
var handler = function (type) { return function (event) {
|
|
32
32
|
if (_this.logData.url.indexOf('app/collect/original/info/report/v2') > -1)
|
|
33
33
|
return;
|
|
34
|
+
// status = 0 是在跨域与404的情况下
|
|
35
|
+
// 当前都是在readyState为4(请求已完成)的情况下,进行处理
|
|
34
36
|
if (type !== 'error' || _this.status === 0)
|
|
35
37
|
return;
|
|
36
38
|
var duration = Date.now() - startTime_1;
|
|
@@ -11,8 +11,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var
|
|
15
|
-
// import RavenVue from 'raven-js/plugins/vue';
|
|
14
|
+
var browser_1 = __importDefault(require("@sentry/browser"));
|
|
16
15
|
var Report = /** @class */ (function () {
|
|
17
16
|
function Report(Vue, options) {
|
|
18
17
|
if (options === void 0) { options = {}; }
|
|
@@ -36,9 +35,9 @@ var Report = /** @class */ (function () {
|
|
|
36
35
|
// }).addPlugin(RavenVue, this.Vue).install();
|
|
37
36
|
// raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
|
|
38
37
|
// 记录用户信息
|
|
39
|
-
|
|
38
|
+
browser_1.default.setUser({ user: this.options.user || '' });
|
|
40
39
|
// 设置全局tag标签
|
|
41
|
-
|
|
40
|
+
browser_1.default.setTag('environment', this.options.env || '');
|
|
42
41
|
}
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
@@ -52,22 +51,20 @@ var Report = /** @class */ (function () {
|
|
|
52
51
|
if (type === void 0) { type = 'error'; }
|
|
53
52
|
if (options === void 0) { options = {}; }
|
|
54
53
|
// 添加面包屑
|
|
55
|
-
|
|
54
|
+
browser_1.default.addBreadcrumb({
|
|
56
55
|
message: data,
|
|
57
56
|
category: 'manual message',
|
|
58
57
|
});
|
|
59
58
|
// 异常上报
|
|
60
59
|
if (data instanceof Error) {
|
|
61
|
-
|
|
60
|
+
browser_1.default.captureException(data, {
|
|
62
61
|
level: type,
|
|
63
|
-
logger: 'manual exception',
|
|
64
62
|
tags: { options: options },
|
|
65
63
|
});
|
|
66
64
|
}
|
|
67
65
|
else {
|
|
68
|
-
|
|
66
|
+
browser_1.default.captureException('error', {
|
|
69
67
|
level: type,
|
|
70
|
-
logger: 'manual data',
|
|
71
68
|
extra: {
|
|
72
69
|
data: data,
|
|
73
70
|
options: this.options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haluo/util",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.32",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "<wanghui@jddmoto.com>",
|
|
6
6
|
"description": "哈罗摩托工具库",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"@haluo/util"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@sentry/browser": "^7.31.1",
|
|
29
30
|
"@types/jest": "^26.0.24",
|
|
30
|
-
"axios": "^
|
|
31
|
+
"axios": "^1.2.3",
|
|
31
32
|
"clipboard-copy": "^4.0.1",
|
|
32
33
|
"jest": "^27.0.6",
|
|
33
|
-
"raven-js": "^3.27.2",
|
|
34
34
|
"ua-parser-js": "^1.0.2",
|
|
35
35
|
"uuid": "^8.3.2"
|
|
36
36
|
},
|
|
@@ -13,6 +13,8 @@ export default function injectXHR(data:any={}){
|
|
|
13
13
|
const startTime = Date.now()
|
|
14
14
|
const handler = (type:string) => (event:any) => {
|
|
15
15
|
if(this.logData.url.indexOf('app/collect/original/info/report/v2') > -1 ) return
|
|
16
|
+
// status = 0 是在跨域与404的情况下
|
|
17
|
+
// 当前都是在readyState为4(请求已完成)的情况下,进行处理
|
|
16
18
|
if(type !== 'error' || this.status === 0) return
|
|
17
19
|
let duration = Date.now() - startTime
|
|
18
20
|
let status = this.status
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
'use strict'
|
|
10
10
|
|
|
11
|
-
import Raven from '
|
|
12
|
-
// import RavenVue from 'raven-js/plugins/vue';
|
|
11
|
+
import Raven from '@sentry/browser';
|
|
13
12
|
|
|
14
13
|
class Report {
|
|
15
14
|
static instance: any;
|
|
@@ -39,10 +38,10 @@ class Report {
|
|
|
39
38
|
// raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
|
|
40
39
|
|
|
41
40
|
// 记录用户信息
|
|
42
|
-
Raven.
|
|
41
|
+
Raven.setUser({ user: this.options.user || '' });
|
|
43
42
|
|
|
44
43
|
// 设置全局tag标签
|
|
45
|
-
Raven.
|
|
44
|
+
Raven.setTag('environment', this.options.env || '');
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
|
|
@@ -54,7 +53,7 @@ class Report {
|
|
|
54
53
|
*/
|
|
55
54
|
log(data: any = null, type: any = 'error', options: any = {}) {
|
|
56
55
|
// 添加面包屑
|
|
57
|
-
Raven.
|
|
56
|
+
Raven.addBreadcrumb({
|
|
58
57
|
message: data,
|
|
59
58
|
category: 'manual message',
|
|
60
59
|
});
|
|
@@ -62,13 +61,11 @@ class Report {
|
|
|
62
61
|
if (data instanceof Error) {
|
|
63
62
|
Raven.captureException(data, {
|
|
64
63
|
level: type,
|
|
65
|
-
logger: 'manual exception',
|
|
66
64
|
tags: { options },
|
|
67
65
|
});
|
|
68
66
|
} else {
|
|
69
67
|
Raven.captureException('error', {
|
|
70
68
|
level: type,
|
|
71
|
-
logger: 'manual data',
|
|
72
69
|
extra: {
|
|
73
70
|
data,
|
|
74
71
|
options: this.options,
|