@haluo/util 1.0.32 → 2.0.0
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/index.js +33 -36
- package/dist/modules/cookie/index.js +54 -54
- package/dist/modules/date/index.js +192 -192
- package/dist/modules/dom/index.js +62 -62
- package/dist/modules/filter/index.js +44 -57
- package/dist/modules/format/index.js +21 -21
- package/dist/modules/match/index.js +31 -31
- package/dist/modules/monitor/index.js +17 -17
- package/dist/modules/monitor/lib/jsError.js +53 -61
- package/dist/modules/monitor/lib/timing.js +69 -69
- package/dist/modules/monitor/lib/xhr.js +48 -50
- package/dist/modules/monitor/utils/onload.js +11 -11
- package/dist/modules/monitor/utils/tracker.js +63 -84
- package/dist/modules/number/index.js +102 -102
- package/dist/modules/sentry/index.js +81 -78
- package/dist/modules/tools/index.js +393 -393
- package/package.json +4 -4
- package/publish.sh +0 -0
- package/src/index.ts +3 -6
- package/src/modules/filter/index.ts +0 -14
- package/src/modules/monitor/lib/jsError.ts +10 -10
- package/src/modules/monitor/lib/xhr.ts +1 -3
- package/src/modules/monitor/utils/tracker.ts +1 -15
- package/src/modules/sentry/index.ts +7 -4
- package/dist/index.cjs.js +0 -89
- package/dist/index.d.ts +0 -12
- package/dist/index.esm.js +0 -87
- package/dist/lib-list.d.ts +0 -2
- package/dist/modules/cookie/index.d.ts +0 -27
- package/dist/modules/date/index.d.ts +0 -1
- package/dist/modules/dom/index.d.ts +0 -1
- package/dist/modules/filter/index.d.ts +0 -26
- package/dist/modules/format/index.d.ts +0 -13
- package/dist/modules/match/index.d.ts +0 -1
- package/dist/modules/number/index.d.ts +0 -39
- package/dist/modules/sentry/index.d.ts +0 -15
- package/dist/modules/tools/index.d.ts +0 -1
- package/yarn-error.log +0 -9316
|
@@ -1,50 +1,48 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var tracker_1 = __importDefault(require("../utils/tracker"));
|
|
18
|
-
function injectXHR(data) {
|
|
19
|
-
if (data === void 0) { data = {}; }
|
|
20
|
-
var XMLHttpRequest = window.XMLHttpRequest;
|
|
21
|
-
var oldOpen = XMLHttpRequest.prototype.open;
|
|
22
|
-
XMLHttpRequest.prototype.open = function (method, url, async) {
|
|
23
|
-
this.logData = { method: method, url: url, async: async };
|
|
24
|
-
return oldOpen.apply(this, arguments);
|
|
25
|
-
};
|
|
26
|
-
var oldSend = XMLHttpRequest.prototype.send;
|
|
27
|
-
XMLHttpRequest.prototype.send = function (body) {
|
|
28
|
-
var _this = this;
|
|
29
|
-
if (this.logData) {
|
|
30
|
-
var startTime_1 = Date.now();
|
|
31
|
-
var handler = function (type) { return function (event) {
|
|
32
|
-
if (_this.logData.url.indexOf('app/collect/original/info/report/v2') > -1)
|
|
33
|
-
return;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.addEventListener('
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
exports.default = injectXHR;
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var tracker_1 = __importDefault(require("../utils/tracker"));
|
|
18
|
+
function injectXHR(data) {
|
|
19
|
+
if (data === void 0) { data = {}; }
|
|
20
|
+
var XMLHttpRequest = window.XMLHttpRequest;
|
|
21
|
+
var oldOpen = XMLHttpRequest.prototype.open;
|
|
22
|
+
XMLHttpRequest.prototype.open = function (method, url, async) {
|
|
23
|
+
this.logData = { method: method, url: url, async: async };
|
|
24
|
+
return oldOpen.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var oldSend = XMLHttpRequest.prototype.send;
|
|
27
|
+
XMLHttpRequest.prototype.send = function (body) {
|
|
28
|
+
var _this = this;
|
|
29
|
+
if (this.logData) {
|
|
30
|
+
var startTime_1 = Date.now();
|
|
31
|
+
var handler = function (type) { return function (event) {
|
|
32
|
+
if (_this.logData.url.indexOf('app/collect/original/info/report/v2') > -1)
|
|
33
|
+
return;
|
|
34
|
+
if (type !== 'error')
|
|
35
|
+
return;
|
|
36
|
+
var duration = Date.now() - startTime_1;
|
|
37
|
+
var status = _this.status;
|
|
38
|
+
var statusText = _this.statusText;
|
|
39
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'xhr', eventType: event.type, pathname: _this.logData.url, status: status + '-' + statusText, duration: duration, response: _this.response ? JSON.stringify(_this.response) : '', params: body || '', title: 'xhr', reason: status + '-' + statusText + " ".concat(_this.logData.url, " ").concat(_this.response ? JSON.stringify(_this.response) : '') }, data));
|
|
40
|
+
}; };
|
|
41
|
+
this.addEventListener('load', handler('load'), false);
|
|
42
|
+
this.addEventListener('error', handler('error'), false);
|
|
43
|
+
this.addEventListener('abort', handler('abort'), false);
|
|
44
|
+
}
|
|
45
|
+
return oldSend.apply(this, arguments);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.default = injectXHR;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function onload(cb) {
|
|
4
|
-
if (document.readyState) {
|
|
5
|
-
cb();
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
window.addEventListener('load', cb);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = onload;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function onload(cb) {
|
|
4
|
+
if (document.readyState) {
|
|
5
|
+
cb();
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
window.addEventListener('load', cb);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.default = onload;
|
|
@@ -1,84 +1,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
|
|
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
|
-
|
|
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();
|
|
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 SendTracker = /** @class */ (function () {
|
|
17
|
+
function SendTracker() {
|
|
18
|
+
this.url = '';
|
|
19
|
+
}
|
|
20
|
+
SendTracker.prototype.send = function (data) {
|
|
21
|
+
if (data === void 0) { data = {}; }
|
|
22
|
+
var host = window.location.host;
|
|
23
|
+
if (host.indexOf('localhost') > -1)
|
|
24
|
+
return;
|
|
25
|
+
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;
|
|
26
|
+
if (reg.test(host))
|
|
27
|
+
return;
|
|
28
|
+
var log = __assign(__assign({}, getExtraData()), data);
|
|
29
|
+
var formBody = [];
|
|
30
|
+
for (var property in log) {
|
|
31
|
+
var encodedKey = encodeURIComponent(property);
|
|
32
|
+
var encodedValue = encodeURIComponent(log[property]);
|
|
33
|
+
formBody.push(encodedKey + "=" + encodedValue);
|
|
34
|
+
}
|
|
35
|
+
formBody = formBody.join("&");
|
|
36
|
+
fetch('https://apm-collect.58moto.com/app/collect/original/info/report/v2', {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
40
|
+
},
|
|
41
|
+
body: formBody,
|
|
42
|
+
}).then(function (res) {
|
|
43
|
+
// console.log(res)
|
|
44
|
+
}).catch(function (e) {
|
|
45
|
+
console.log(e);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return SendTracker;
|
|
49
|
+
}());
|
|
50
|
+
function getExtraData() {
|
|
51
|
+
return {
|
|
52
|
+
deviceId: uuidv4(),
|
|
53
|
+
platform: 3,
|
|
54
|
+
errorType: 3,
|
|
55
|
+
channel: 'h5',
|
|
56
|
+
bundle: 'com.jdd.motorfans',
|
|
57
|
+
title: '',
|
|
58
|
+
frontStatus: 3,
|
|
59
|
+
occurTimeStamp: Date.now(),
|
|
60
|
+
// userAgent: new Parser().getResult()
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.default = new SendTracker();
|
|
@@ -1,102 +1,102 @@
|
|
|
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
|
-
""
|
|
95
|
-
:
|
|
96
|
-
""
|
|
97
|
-
result = pricePoint ? ""
|
|
98
|
-
return result;
|
|
99
|
-
};
|
|
100
|
-
return NumberClass;
|
|
101
|
-
}());
|
|
102
|
-
module.exports = 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
|
+
"".concat(price.substring(0, price.length - 6)).concat(signal).concat(price.substring(price.length - 6, price.length - 3), ",").concat(price.substring(price.length - 3, price.length))
|
|
95
|
+
:
|
|
96
|
+
"".concat(price.substring(0, price.length - 3)).concat(signal).concat(price.substring(price.length - 3, price.length));
|
|
97
|
+
result = pricePoint ? "".concat(result).concat(signal).concat(pricePoint) : result;
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
return NumberClass;
|
|
101
|
+
}());
|
|
102
|
+
module.exports = new NumberClass();
|
|
@@ -1,78 +1,81 @@
|
|
|
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
|
-
|
|
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 raven_js_1 = __importDefault(require("raven-js"));
|
|
15
|
+
// import RavenVue from 'raven-js/plugins/vue';
|
|
16
|
+
var Report = /** @class */ (function () {
|
|
17
|
+
function Report(Vue, options) {
|
|
18
|
+
if (options === void 0) { options = {}; }
|
|
19
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
20
|
+
// todo
|
|
21
|
+
}
|
|
22
|
+
this.vue = Vue;
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
Report.getInstance = function (Vue, Option) {
|
|
26
|
+
if (!(this.instance instanceof this)) {
|
|
27
|
+
this.instance = new this(Vue, Option);
|
|
28
|
+
this.instance.install();
|
|
29
|
+
}
|
|
30
|
+
return this.instance;
|
|
31
|
+
};
|
|
32
|
+
Report.prototype.install = function () {
|
|
33
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
34
|
+
// Raven.config(this.options.dsn, {
|
|
35
|
+
// environment: process.env.NODE_ENV,
|
|
36
|
+
// }).addPlugin(RavenVue, this.Vue).install();
|
|
37
|
+
// raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
|
|
38
|
+
// 记录用户信息
|
|
39
|
+
raven_js_1.default.setUserContext({ user: this.options.user || '' });
|
|
40
|
+
// 设置全局tag标签
|
|
41
|
+
raven_js_1.default.setTagsContext({ environment: this.options.env || '' });
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* 主动上报
|
|
46
|
+
* @param {String} data
|
|
47
|
+
* @param {String} type 'info','warning','error'
|
|
48
|
+
* @param {Object} options
|
|
49
|
+
*/
|
|
50
|
+
Report.prototype.log = function (data, type, options) {
|
|
51
|
+
if (data === void 0) { data = null; }
|
|
52
|
+
if (type === void 0) { type = 'error'; }
|
|
53
|
+
if (options === void 0) { options = {}; }
|
|
54
|
+
// 添加面包屑
|
|
55
|
+
raven_js_1.default.captureBreadcrumb({
|
|
56
|
+
message: data,
|
|
57
|
+
category: 'manual message',
|
|
58
|
+
});
|
|
59
|
+
// 异常上报
|
|
60
|
+
if (data instanceof Error) {
|
|
61
|
+
raven_js_1.default.captureException(data, {
|
|
62
|
+
level: type,
|
|
63
|
+
logger: 'manual exception',
|
|
64
|
+
tags: { options: options },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
raven_js_1.default.captureException('error', {
|
|
69
|
+
level: type,
|
|
70
|
+
logger: 'manual data',
|
|
71
|
+
extra: {
|
|
72
|
+
data: data,
|
|
73
|
+
options: this.options,
|
|
74
|
+
date: new Date(),
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return Report;
|
|
80
|
+
}());
|
|
81
|
+
exports.default = Report;
|