@haluo/util 2.0.5 → 2.0.7
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/README.md +1 -1
- package/dist/index.cjs.js +89 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.esm.js +87 -0
- package/dist/index.js +36 -50
- package/dist/lib-list.d.ts +2 -0
- package/dist/modules/cookie/index.d.ts +27 -0
- package/dist/modules/cookie/index.js +54 -55
- package/dist/modules/date/index.d.ts +1 -0
- package/dist/modules/date/index.js +192 -192
- package/dist/modules/dom/index.d.ts +1 -0
- package/dist/modules/dom/index.js +62 -62
- package/dist/modules/filter/index.d.ts +26 -0
- package/dist/modules/filter/index.js +57 -48
- package/dist/modules/format/index.d.ts +13 -0
- package/dist/modules/format/index.js +21 -22
- package/dist/modules/match/index.d.ts +1 -0
- package/dist/modules/match/index.js +31 -31
- package/dist/modules/monitor/index.js +17 -17
- package/dist/modules/monitor/lib/jsError.js +61 -53
- package/dist/modules/monitor/lib/timing.js +69 -69
- package/dist/modules/monitor/lib/xhr.js +50 -48
- package/dist/modules/monitor/utils/onload.js +11 -11
- package/dist/modules/monitor/utils/tracker.js +84 -63
- package/dist/modules/number/index.d.ts +39 -0
- package/dist/modules/number/index.js +102 -103
- package/dist/modules/sentry/index.d.ts +15 -0
- package/dist/modules/sentry/index.js +78 -81
- package/dist/modules/tools/index.d.ts +1 -0
- package/dist/modules/tools/index.js +393 -393
- package/dist/tsconfig.tsbuildinfo +2915 -1
- package/dist/types/index.d.ts +11 -32
- package/dist/types/index.js +2 -2
- package/dist/types/modules/cookie/index.d.ts +25 -27
- package/dist/types/modules/date/index.d.ts +1 -52
- package/dist/types/modules/dom/index.d.ts +1 -28
- package/dist/types/modules/filter/index.d.ts +26 -24
- package/dist/types/modules/format/index.d.ts +13 -15
- package/dist/types/modules/match/index.d.ts +1 -12
- package/dist/types/modules/monitor/index.d.ts +3 -3
- package/dist/types/modules/monitor/lib/jsError.d.ts +1 -1
- package/dist/types/modules/monitor/lib/timing.d.ts +1 -1
- package/dist/types/modules/monitor/lib/xhr.d.ts +1 -1
- package/dist/types/modules/monitor/utils/onload.d.ts +1 -1
- package/dist/types/modules/monitor/utils/tracker.d.ts +8 -7
- package/dist/types/modules/number/index.d.ts +39 -41
- package/dist/types/modules/sentry/index.d.ts +15 -15
- package/dist/types/modules/tools/index.d.ts +1 -166
- package/dist/types/types/index.d.ts +3 -3
- package/package.json +2 -2
|
@@ -1,63 +1,84 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var uuidv4 = require('uuid').v4;
|
|
15
|
-
// const Parser = require('ua-parser-js');
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
return;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var uuidv4 = require('uuid').v4;
|
|
15
|
+
// const Parser = require('ua-parser-js');
|
|
16
|
+
var reg = /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g;
|
|
17
|
+
var SendTracker = /** @class */ (function () {
|
|
18
|
+
function SendTracker() {
|
|
19
|
+
this.url = '';
|
|
20
|
+
}
|
|
21
|
+
SendTracker.prototype.verifyRequest = function (reason) {
|
|
22
|
+
if (!reason)
|
|
23
|
+
return false;
|
|
24
|
+
if (reg.test(reason))
|
|
25
|
+
return false;
|
|
26
|
+
if (reason.startsWith('halomoto'))
|
|
27
|
+
return false;
|
|
28
|
+
if (reason.startsWith('file:'))
|
|
29
|
+
return false;
|
|
30
|
+
if (reason.includes('log-center.58moto.com'))
|
|
31
|
+
return false;
|
|
32
|
+
if (reason.includes('s23.cnzz.com'))
|
|
33
|
+
return false;
|
|
34
|
+
if (reason.includes('g.alicdn.com'))
|
|
35
|
+
return false;
|
|
36
|
+
if (reason.includes('vendors'))
|
|
37
|
+
return false;
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
SendTracker.prototype.send = function (data) {
|
|
41
|
+
if (data === void 0) { data = {}; }
|
|
42
|
+
var host = window.location.host;
|
|
43
|
+
if (host.indexOf('localhost') > -1)
|
|
44
|
+
return;
|
|
45
|
+
if (reg.test(host))
|
|
46
|
+
return;
|
|
47
|
+
if (!this.verifyRequest(data.reason))
|
|
48
|
+
return;
|
|
49
|
+
data.reason = window.location.href + ' ' + data.reason;
|
|
50
|
+
var log = __assign(__assign({}, getExtraData()), data);
|
|
51
|
+
var formBody = [];
|
|
52
|
+
for (var property in log) {
|
|
53
|
+
var encodedKey = encodeURIComponent(property);
|
|
54
|
+
var encodedValue = encodeURIComponent(log[property]);
|
|
55
|
+
formBody.push(encodedKey + "=" + encodedValue);
|
|
56
|
+
}
|
|
57
|
+
formBody = formBody.join("&");
|
|
58
|
+
fetch('https://apm-collect.58moto.com/app/collect/original/info/report/v2', {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
62
|
+
},
|
|
63
|
+
body: formBody,
|
|
64
|
+
}).then(function (res) {
|
|
65
|
+
// console.log(res)
|
|
66
|
+
}).catch(function (e) {
|
|
67
|
+
console.log(e);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return SendTracker;
|
|
71
|
+
}());
|
|
72
|
+
function getExtraData() {
|
|
73
|
+
return {
|
|
74
|
+
deviceId: uuidv4(),
|
|
75
|
+
platform: 3,
|
|
76
|
+
errorType: 3,
|
|
77
|
+
channel: 'h5',
|
|
78
|
+
bundle: 'com.jdd.motorfans',
|
|
79
|
+
title: '',
|
|
80
|
+
frontStatus: 3,
|
|
81
|
+
occurTimeStamp: Date.now(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
exports.default = new SendTracker();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare class NumberClass {
|
|
2
|
+
/**
|
|
3
|
+
* 个位数前面补0
|
|
4
|
+
* @param {Number} num 需要格式化的数字
|
|
5
|
+
* @return {String} '01'
|
|
6
|
+
*/
|
|
7
|
+
formatNumber(num: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* 将手机号中间部分替换为星号
|
|
10
|
+
* @param {String} phone 手机号码
|
|
11
|
+
* @return {String} 131****1111
|
|
12
|
+
*/
|
|
13
|
+
formatPhone(phone: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 格式化数字 万
|
|
16
|
+
* @param {Number} num
|
|
17
|
+
* @return {String} 12.3万
|
|
18
|
+
*/
|
|
19
|
+
convertToWan(num: number): string | number;
|
|
20
|
+
/**
|
|
21
|
+
* 格式化数字 k
|
|
22
|
+
* @param {Number} num
|
|
23
|
+
* @return {String} 1.2k
|
|
24
|
+
*/
|
|
25
|
+
convertToThousand(num: number): string | number;
|
|
26
|
+
/**
|
|
27
|
+
* 随机数,指定范围
|
|
28
|
+
* @param {Number} min 开始
|
|
29
|
+
* @param {Number} max 结束
|
|
30
|
+
* @return {Number|Object}
|
|
31
|
+
*/
|
|
32
|
+
random(min: number, max: number): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* 格式化金额
|
|
35
|
+
* @param {Number} num
|
|
36
|
+
* @return {String} 123,456
|
|
37
|
+
*/
|
|
38
|
+
formatMoney(money: number | string, signal: string): string;
|
|
39
|
+
}
|
|
@@ -1,103 +1,102 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file number 格式化
|
|
3
|
-
* @Author: wanghui
|
|
4
|
-
* @createBy: @2020.05.26
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* @
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
* @param {Number}
|
|
61
|
-
* @
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
money =
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
exports.default = new NumberClass();
|
|
1
|
+
/**
|
|
2
|
+
* @file number 格式化
|
|
3
|
+
* @Author: wanghui
|
|
4
|
+
* @createBy: @2020.05.26
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
var NumberClass = /** @class */ (function () {
|
|
8
|
+
function NumberClass() {
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 个位数前面补0
|
|
12
|
+
* @param {Number} num 需要格式化的数字
|
|
13
|
+
* @return {String} '01'
|
|
14
|
+
*/
|
|
15
|
+
NumberClass.prototype.formatNumber = function (num) {
|
|
16
|
+
var res = num.toString();
|
|
17
|
+
return res[1] ? res : '0' + res;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 将手机号中间部分替换为星号
|
|
21
|
+
* @param {String} phone 手机号码
|
|
22
|
+
* @return {String} 131****1111
|
|
23
|
+
*/
|
|
24
|
+
NumberClass.prototype.formatPhone = function (phone) {
|
|
25
|
+
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 格式化数字 万
|
|
29
|
+
* @param {Number} num
|
|
30
|
+
* @return {String} 12.3万
|
|
31
|
+
*/
|
|
32
|
+
NumberClass.prototype.convertToWan = function (num) {
|
|
33
|
+
var result = '';
|
|
34
|
+
if (num < 10000) {
|
|
35
|
+
result = num;
|
|
36
|
+
}
|
|
37
|
+
if (num >= 10000) {
|
|
38
|
+
result = (num / 10000).toFixed(1) + '万';
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* 格式化数字 k
|
|
44
|
+
* @param {Number} num
|
|
45
|
+
* @return {String} 1.2k
|
|
46
|
+
*/
|
|
47
|
+
NumberClass.prototype.convertToThousand = function (num) {
|
|
48
|
+
var result = '';
|
|
49
|
+
if (num < 1000) {
|
|
50
|
+
result = num;
|
|
51
|
+
}
|
|
52
|
+
if (num >= 1000) {
|
|
53
|
+
result = (num / 1000).toFixed(1) + 'k';
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 随机数,指定范围
|
|
59
|
+
* @param {Number} min 开始
|
|
60
|
+
* @param {Number} max 结束
|
|
61
|
+
* @return {Number|Object}
|
|
62
|
+
*/
|
|
63
|
+
NumberClass.prototype.random = function (min, max) {
|
|
64
|
+
if (arguments.length === 2) {
|
|
65
|
+
return Math.floor(min + Math.random() * ((max + 1) - min));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* 格式化金额
|
|
73
|
+
* @param {Number} num
|
|
74
|
+
* @return {String} 123,456
|
|
75
|
+
*/
|
|
76
|
+
NumberClass.prototype.formatMoney = function (money, signal) {
|
|
77
|
+
var result = '';
|
|
78
|
+
if (money === '') {
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
money = String(money).replace('.00', '');
|
|
82
|
+
money = money.substring(money.length - 2) === '.0' ? money.replace('.0', '') : money;
|
|
83
|
+
// 小于3位数,直接返回
|
|
84
|
+
if (Number(money) < 1000) {
|
|
85
|
+
return result = money;
|
|
86
|
+
}
|
|
87
|
+
if (money.split('.')[0].length < 3) {
|
|
88
|
+
return result = money;
|
|
89
|
+
}
|
|
90
|
+
signal = signal === '' ? '' : ',';
|
|
91
|
+
var price = money.split('.')[0] + '';
|
|
92
|
+
var pricePoint = money.split('.')[1];
|
|
93
|
+
result = price.length > 6 ?
|
|
94
|
+
"" + price.substring(0, price.length - 6) + signal + price.substring(price.length - 6, price.length - 3) + "," + price.substring(price.length - 3, price.length)
|
|
95
|
+
:
|
|
96
|
+
"" + price.substring(0, price.length - 3) + signal + price.substring(price.length - 3, price.length);
|
|
97
|
+
result = pricePoint ? "" + result + signal + pricePoint : result;
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
return NumberClass;
|
|
101
|
+
}());
|
|
102
|
+
module.exports = new NumberClass();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class Report {
|
|
2
|
+
static instance: any;
|
|
3
|
+
constructor(Vue: Object, options?: {});
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
static getInstance(Vue: Object, Option: Object): any;
|
|
6
|
+
install(): void;
|
|
7
|
+
/**
|
|
8
|
+
* 主动上报
|
|
9
|
+
* @param {String} data
|
|
10
|
+
* @param {String} type 'info','warning','error'
|
|
11
|
+
* @param {Object} options
|
|
12
|
+
*/
|
|
13
|
+
log(data?: any, type?: any, options?: any): void;
|
|
14
|
+
}
|
|
15
|
+
export default Report;
|
|
@@ -1,81 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 异常上报日志监控类
|
|
3
|
-
* @Author: wanghui
|
|
4
|
-
* 常用配置 option:https://docs.sentry.io/clients/javascript/config/
|
|
5
|
-
* 1.自动捕获vue组件内异常
|
|
6
|
-
* 2.自动捕获promise内的异常
|
|
7
|
-
* 3.自动捕获没有被catch的运行异常
|
|
8
|
-
*/
|
|
9
|
-
'use strict';
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.instance
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
* @param {String}
|
|
47
|
-
* @param {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return Report;
|
|
80
|
-
}());
|
|
81
|
-
exports.default = Report;
|
|
1
|
+
/**
|
|
2
|
+
* 异常上报日志监控类
|
|
3
|
+
* @Author: wanghui
|
|
4
|
+
* 常用配置 option:https://docs.sentry.io/clients/javascript/config/
|
|
5
|
+
* 1.自动捕获vue组件内异常
|
|
6
|
+
* 2.自动捕获promise内的异常
|
|
7
|
+
* 3.自动捕获没有被catch的运行异常
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var browser_1 = __importDefault(require("@sentry/browser"));
|
|
15
|
+
var Report = /** @class */ (function () {
|
|
16
|
+
function Report(Vue, options) {
|
|
17
|
+
if (options === void 0) { options = {}; }
|
|
18
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
19
|
+
// todo
|
|
20
|
+
}
|
|
21
|
+
this.vue = Vue;
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
Report.getInstance = function (Vue, Option) {
|
|
25
|
+
if (!(this.instance instanceof this)) {
|
|
26
|
+
this.instance = new this(Vue, Option);
|
|
27
|
+
this.instance.install();
|
|
28
|
+
}
|
|
29
|
+
return this.instance;
|
|
30
|
+
};
|
|
31
|
+
Report.prototype.install = function () {
|
|
32
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
33
|
+
// Raven.config(this.options.dsn, {
|
|
34
|
+
// environment: process.env.NODE_ENV,
|
|
35
|
+
// }).addPlugin(RavenVue, this.Vue).install();
|
|
36
|
+
// raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
|
|
37
|
+
// 记录用户信息
|
|
38
|
+
browser_1.default.setUser({ user: this.options.user || '' });
|
|
39
|
+
// 设置全局tag标签
|
|
40
|
+
browser_1.default.setTag('environment', this.options.env || '');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 主动上报
|
|
45
|
+
* @param {String} data
|
|
46
|
+
* @param {String} type 'info','warning','error'
|
|
47
|
+
* @param {Object} options
|
|
48
|
+
*/
|
|
49
|
+
Report.prototype.log = function (data, type, options) {
|
|
50
|
+
if (data === void 0) { data = null; }
|
|
51
|
+
if (type === void 0) { type = 'error'; }
|
|
52
|
+
if (options === void 0) { options = {}; }
|
|
53
|
+
// 添加面包屑
|
|
54
|
+
browser_1.default.addBreadcrumb({
|
|
55
|
+
message: data,
|
|
56
|
+
category: 'manual message',
|
|
57
|
+
});
|
|
58
|
+
// 异常上报
|
|
59
|
+
if (data instanceof Error) {
|
|
60
|
+
browser_1.default.captureException(data, {
|
|
61
|
+
level: type,
|
|
62
|
+
tags: { options: options },
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
browser_1.default.captureException('error', {
|
|
67
|
+
level: type,
|
|
68
|
+
extra: {
|
|
69
|
+
data: data,
|
|
70
|
+
options: this.options,
|
|
71
|
+
date: new Date(),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return Report;
|
|
77
|
+
}());
|
|
78
|
+
exports.default = Report;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|