@haluo/util 1.0.32 → 1.0.33
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/modules/cookie/index.js +2 -2
- package/dist/modules/date/index.js +11 -11
- package/dist/modules/dom/index.js +1 -1
- package/dist/modules/monitor/index.js +2 -2
- package/dist/modules/monitor/lib/jsError.js +5 -13
- package/dist/modules/monitor/lib/timing.js +1 -1
- package/dist/modules/monitor/lib/xhr.js +2 -4
- package/dist/modules/monitor/utils/tracker.js +2 -23
- package/dist/modules/number/index.js +3 -3
- package/dist/modules/sentry/index.js +9 -6
- package/dist/modules/tools/index.js +4 -4
- package/package.json +4 -4
- 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
package/README.md
CHANGED
|
@@ -32,8 +32,8 @@ var CookieClass = /** @class */ (function () {
|
|
|
32
32
|
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
33
33
|
var d = new Date();
|
|
34
34
|
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
35
|
-
var expires = "expires="
|
|
36
|
-
document.cookie = name
|
|
35
|
+
var expires = "expires=".concat(d.toUTCString());
|
|
36
|
+
document.cookie = "".concat(name, "=").concat(value, ";").concat(expires, ";path=").concat(path, ";domain=").concat(domain, ";");
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* 清除Cookie
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
function replacementDate(data, fmt) {
|
|
15
15
|
for (var k in data) {
|
|
16
16
|
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
17
|
-
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00"
|
|
17
|
+
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (data[k]) : (("00".concat(data[k])).substr(('' + data[k]).length)));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
return fmt;
|
|
@@ -70,7 +70,7 @@ var DateClass = /** @class */ (function () {
|
|
|
70
70
|
};
|
|
71
71
|
fmt = replacementYear(timeData, fmt);
|
|
72
72
|
if (/(E+)/.test(fmt)) {
|
|
73
|
-
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[timeData.getDay()
|
|
73
|
+
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week["".concat(timeData.getDay(), " ")]);
|
|
74
74
|
}
|
|
75
75
|
return replacementDate(o, fmt);
|
|
76
76
|
};
|
|
@@ -105,10 +105,10 @@ var DateClass = /** @class */ (function () {
|
|
|
105
105
|
if (ts <= 0)
|
|
106
106
|
return false;
|
|
107
107
|
return {
|
|
108
|
-
dd: (dd < 10 ? "0"
|
|
109
|
-
hh: (hh < 10 ? "0"
|
|
110
|
-
mm: (mm < 10 ? "0"
|
|
111
|
-
ss: (ss < 10 ? "0"
|
|
108
|
+
dd: (dd < 10 ? "0".concat(dd) : dd),
|
|
109
|
+
hh: (hh < 10 ? "0".concat(hh) : hh),
|
|
110
|
+
mm: (mm < 10 ? "0".concat(mm) : mm),
|
|
111
|
+
ss: (ss < 10 ? "0".concat(ss) : ss)
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
@@ -121,19 +121,19 @@ var DateClass = /** @class */ (function () {
|
|
|
121
121
|
var time = currentTime - startTime;
|
|
122
122
|
var year = Math.floor(time / (1000 * 60 * 60 * 24) / 30 / 12);
|
|
123
123
|
if (year)
|
|
124
|
-
return year
|
|
124
|
+
return "".concat(year, "\u5E74\u524D");
|
|
125
125
|
var month = Math.floor(time / (1000 * 60 * 60 * 24) / 30);
|
|
126
126
|
if (month)
|
|
127
|
-
return month
|
|
127
|
+
return "".concat(month, "\u4E2A\u6708\u524D");
|
|
128
128
|
var day = Math.floor(time / (1000 * 60 * 60 * 24));
|
|
129
129
|
if (day)
|
|
130
|
-
return day
|
|
130
|
+
return "".concat(day, "\u5929\u524D");
|
|
131
131
|
var hour = Math.floor(time / (1000 * 60 * 60));
|
|
132
132
|
if (hour)
|
|
133
|
-
return hour
|
|
133
|
+
return "".concat(hour, "\u5C0F\u65F6\u524D");
|
|
134
134
|
var min = Math.floor(time / (1000 * 60));
|
|
135
135
|
if (min)
|
|
136
|
-
return min
|
|
136
|
+
return "".concat(min, "\u5206\u949F\u524D");
|
|
137
137
|
else
|
|
138
138
|
return '刚刚';
|
|
139
139
|
};
|
|
@@ -48,7 +48,7 @@ var DomClass = /** @class */ (function () {
|
|
|
48
48
|
var value = object[key];
|
|
49
49
|
if (Array.isArray(value)) {
|
|
50
50
|
value.forEach(function (subValue, i) {
|
|
51
|
-
return formData.append(key +
|
|
51
|
+
return formData.append(key + "[".concat(i, "]"), subValue);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
@@ -10,8 +10,8 @@ var tracker_1 = __importDefault(require("./utils/tracker"));
|
|
|
10
10
|
exports.Tracker = tracker_1.default;
|
|
11
11
|
// import timing from './lib/timing'
|
|
12
12
|
function setup(data) {
|
|
13
|
-
jsError_1.injectJsError(data);
|
|
14
|
-
xhr_1.default(data);
|
|
13
|
+
(0, jsError_1.injectJsError)(data);
|
|
14
|
+
(0, xhr_1.default)(data);
|
|
15
15
|
}
|
|
16
16
|
exports.default = setup;
|
|
17
17
|
// timing()
|
|
@@ -20,19 +20,12 @@ function injectJsError(data) {
|
|
|
20
20
|
if (data === void 0) { data = {}; }
|
|
21
21
|
window.addEventListener('error', function (e) {
|
|
22
22
|
if (e.target && (e.target.src || e.target.href)) {
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
// title: 'resourceError',
|
|
27
|
-
// filename: e.target.src || e.target.href,
|
|
28
|
-
// tagName: e.target.tagName,
|
|
29
|
-
// reason: e.target.src || e.target.href,
|
|
30
|
-
// ...data
|
|
31
|
-
// // selector: lastEvent ? get
|
|
32
|
-
// })
|
|
23
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'resourceError', filename: e.target.src || e.target.href, tagName: e.target.tagName, reason: e.target.src || e.target.href }, data
|
|
24
|
+
// selector: lastEvent ? get
|
|
25
|
+
));
|
|
33
26
|
return;
|
|
34
27
|
}
|
|
35
|
-
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'jsError', message: e.message, filename: e.filename, position: e.lineno
|
|
28
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'jsError', message: e.message, filename: e.filename, position: "".concat(e.lineno, ":").concat(e.colno), reason: e.error.stack }, data
|
|
36
29
|
// selector: lastEvent ? get
|
|
37
30
|
));
|
|
38
31
|
}, true);
|
|
@@ -52,8 +45,7 @@ function injectJsError(data) {
|
|
|
52
45
|
message = reason.message;
|
|
53
46
|
stack = reason.stack;
|
|
54
47
|
}
|
|
55
|
-
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'promiseError', message: message,
|
|
56
|
-
filename: filename, position: line + ":" + column, reason: stack }, data
|
|
48
|
+
tracker_1.default.send(__assign({ kind: 'stability', type: 'error', title: 'promiseError', message: message, filename: filename, position: "".concat(line, ":").concat(column), reason: stack }, data
|
|
57
49
|
// selector: lastEvent ? get
|
|
58
50
|
));
|
|
59
51
|
});
|
|
@@ -35,7 +35,7 @@ function timing() {
|
|
|
35
35
|
}
|
|
36
36
|
observer.disconnect(); // 不再观察
|
|
37
37
|
}).observe({ type: 'first-input', buffered: true }); // 观察页面中最大的元素
|
|
38
|
-
onload_1.default(function () {
|
|
38
|
+
(0, onload_1.default)(function () {
|
|
39
39
|
setTimeout(function () {
|
|
40
40
|
console.dir(window.performance);
|
|
41
41
|
var _a = performance.getEntriesByType('navigation')[0], fetchStart = _a.fetchStart, connectStart = _a.connectStart, connectEnd = _a.connectEnd, requestStart = _a.requestStart, responseStart = _a.responseStart, responseEnd = _a.responseEnd, domInteractive = _a.domInteractive, domContentLoadedEventStart = _a.domContentLoadedEventStart, domContentLoadedEventEnd = _a.domContentLoadedEventEnd, loadEventStart = _a.loadEventStart;
|
|
@@ -31,14 +31,12 @@ 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
|
-
|
|
35
|
-
// 当前都是在readyState为4(请求已完成)的情况下,进行处理
|
|
36
|
-
if (type !== 'error' || _this.status === 0)
|
|
34
|
+
if (type !== 'error')
|
|
37
35
|
return;
|
|
38
36
|
var duration = Date.now() - startTime_1;
|
|
39
37
|
var status = _this.status;
|
|
40
38
|
var statusText = _this.statusText;
|
|
41
|
-
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 +
|
|
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));
|
|
42
40
|
}; };
|
|
43
41
|
this.addEventListener('load', handler('load'), false);
|
|
44
42
|
this.addEventListener('error', handler('error'), false);
|
|
@@ -13,40 +13,18 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
var uuidv4 = require('uuid').v4;
|
|
15
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
16
|
var SendTracker = /** @class */ (function () {
|
|
18
17
|
function SendTracker() {
|
|
19
18
|
this.url = '';
|
|
20
19
|
}
|
|
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
20
|
SendTracker.prototype.send = function (data) {
|
|
41
21
|
if (data === void 0) { data = {}; }
|
|
42
22
|
var host = window.location.host;
|
|
43
23
|
if (host.indexOf('localhost') > -1)
|
|
44
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;
|
|
45
26
|
if (reg.test(host))
|
|
46
27
|
return;
|
|
47
|
-
if (!this.verifyRequest(data.reason))
|
|
48
|
-
return;
|
|
49
|
-
data.reason = window.location.href + ' ' + data.reason;
|
|
50
28
|
var log = __assign(__assign({}, getExtraData()), data);
|
|
51
29
|
var formBody = [];
|
|
52
30
|
for (var property in log) {
|
|
@@ -79,6 +57,7 @@ function getExtraData() {
|
|
|
79
57
|
title: '',
|
|
80
58
|
frontStatus: 3,
|
|
81
59
|
occurTimeStamp: Date.now(),
|
|
60
|
+
// userAgent: new Parser().getResult()
|
|
82
61
|
};
|
|
83
62
|
}
|
|
84
63
|
exports.default = new SendTracker();
|
|
@@ -91,10 +91,10 @@ var NumberClass = /** @class */ (function () {
|
|
|
91
91
|
var price = money.split('.')[0] + '';
|
|
92
92
|
var pricePoint = money.split('.')[1];
|
|
93
93
|
result = price.length > 6 ?
|
|
94
|
-
""
|
|
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
95
|
:
|
|
96
|
-
""
|
|
97
|
-
result = pricePoint ? ""
|
|
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
98
|
return result;
|
|
99
99
|
};
|
|
100
100
|
return NumberClass;
|
|
@@ -11,7 +11,8 @@ 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
|
|
14
|
+
var raven_js_1 = __importDefault(require("raven-js"));
|
|
15
|
+
// import RavenVue from 'raven-js/plugins/vue';
|
|
15
16
|
var Report = /** @class */ (function () {
|
|
16
17
|
function Report(Vue, options) {
|
|
17
18
|
if (options === void 0) { options = {}; }
|
|
@@ -35,9 +36,9 @@ var Report = /** @class */ (function () {
|
|
|
35
36
|
// }).addPlugin(RavenVue, this.Vue).install();
|
|
36
37
|
// raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
|
|
37
38
|
// 记录用户信息
|
|
38
|
-
|
|
39
|
+
raven_js_1.default.setUserContext({ user: this.options.user || '' });
|
|
39
40
|
// 设置全局tag标签
|
|
40
|
-
|
|
41
|
+
raven_js_1.default.setTagsContext({ environment: this.options.env || '' });
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
/**
|
|
@@ -51,20 +52,22 @@ var Report = /** @class */ (function () {
|
|
|
51
52
|
if (type === void 0) { type = 'error'; }
|
|
52
53
|
if (options === void 0) { options = {}; }
|
|
53
54
|
// 添加面包屑
|
|
54
|
-
|
|
55
|
+
raven_js_1.default.captureBreadcrumb({
|
|
55
56
|
message: data,
|
|
56
57
|
category: 'manual message',
|
|
57
58
|
});
|
|
58
59
|
// 异常上报
|
|
59
60
|
if (data instanceof Error) {
|
|
60
|
-
|
|
61
|
+
raven_js_1.default.captureException(data, {
|
|
61
62
|
level: type,
|
|
63
|
+
logger: 'manual exception',
|
|
62
64
|
tags: { options: options },
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
else {
|
|
66
|
-
|
|
68
|
+
raven_js_1.default.captureException('error', {
|
|
67
69
|
level: type,
|
|
70
|
+
logger: 'manual data',
|
|
68
71
|
extra: {
|
|
69
72
|
data: data,
|
|
70
73
|
options: this.options,
|
|
@@ -25,7 +25,7 @@ var ToolsClass = /** @class */ (function () {
|
|
|
25
25
|
body.style.overflow = 'hidden';
|
|
26
26
|
body.style.height = '100%';
|
|
27
27
|
if (className) {
|
|
28
|
-
var dom = document.querySelector("."
|
|
28
|
+
var dom = document.querySelector(".".concat(className));
|
|
29
29
|
dom && dom.addEventListener('touchmove', _this.__setDefault__);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -45,7 +45,7 @@ var ToolsClass = /** @class */ (function () {
|
|
|
45
45
|
body.style.overflow = 'visible';
|
|
46
46
|
body.style.height = 'auto';
|
|
47
47
|
if (className) {
|
|
48
|
-
var dom = document.querySelector("."
|
|
48
|
+
var dom = document.querySelector(".".concat(className));
|
|
49
49
|
dom && dom.removeEventListener('touchmove', _this.__setDefault__);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
@@ -384,9 +384,9 @@ var ToolsClass = /** @class */ (function () {
|
|
|
384
384
|
}
|
|
385
385
|
// 匹配中文、英文、数字
|
|
386
386
|
var regItem = '[\u4e00-\u9fa5a-zA-Z0-9]';
|
|
387
|
-
var regExp = "("
|
|
387
|
+
var regExp = "(".concat(regItem, "{").concat(before, "})").concat(regItem, "*(").concat(regItem, "{").concat(after, "})");
|
|
388
388
|
var reg = new RegExp(regExp);
|
|
389
|
-
return field.replace(reg, "$1"
|
|
389
|
+
return field.replace(reg, "$1".concat("*".repeat(sensitiveLen), "$2"));
|
|
390
390
|
};
|
|
391
391
|
return ToolsClass;
|
|
392
392
|
}());
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haluo/util",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "<wanghui@jddmoto.com>",
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "摩托范工具库",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "webpack --config ./build/webpack.pro.config.js",
|
|
9
9
|
"tsc": "tsc",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"@haluo/util"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sentry/browser": "^7.31.1",
|
|
30
29
|
"@types/jest": "^26.0.24",
|
|
31
|
-
"axios": "^
|
|
30
|
+
"axios": "^0.19.2",
|
|
32
31
|
"clipboard-copy": "^4.0.1",
|
|
33
32
|
"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
|
},
|
|
@@ -2,16 +2,16 @@ import track from '../utils/tracker'
|
|
|
2
2
|
export function injectJsError (data:any={}) {
|
|
3
3
|
window.addEventListener('error', (e: any) => {
|
|
4
4
|
if (e.target && (e.target.src || e.target.href)) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
track.send({
|
|
6
|
+
kind: 'stability',
|
|
7
|
+
type: 'error',
|
|
8
|
+
title: 'resourceError',
|
|
9
|
+
filename: e.target.src || e.target.href,
|
|
10
|
+
tagName: e.target.tagName,
|
|
11
|
+
reason: e.target.src || e.target.href,
|
|
12
|
+
...data
|
|
13
|
+
// selector: lastEvent ? get
|
|
14
|
+
})
|
|
15
15
|
return
|
|
16
16
|
}
|
|
17
17
|
track.send({
|
|
@@ -13,9 +13,7 @@ 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
|
-
|
|
17
|
-
// 当前都是在readyState为4(请求已完成)的情况下,进行处理
|
|
18
|
-
if(type !== 'error' || this.status === 0) return
|
|
16
|
+
if(type !== 'error') return
|
|
19
17
|
let duration = Date.now() - startTime
|
|
20
18
|
let status = this.status
|
|
21
19
|
let statusText = this.statusText
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
const { v4: uuidv4 } = require('uuid')
|
|
2
2
|
// const Parser = require('ua-parser-js');
|
|
3
|
-
const 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
|
|
4
|
-
|
|
5
3
|
class SendTracker {
|
|
6
4
|
url: string
|
|
7
5
|
constructor() {
|
|
8
6
|
this.url = ''
|
|
9
7
|
}
|
|
10
|
-
verifyRequest(reason:string):boolean {
|
|
11
|
-
if(!reason) return false
|
|
12
|
-
if(reg.test(reason)) return false
|
|
13
|
-
if(reason.startsWith('halomoto')) return false
|
|
14
|
-
if(reason.startsWith('file:')) return false
|
|
15
|
-
if(reason.includes('log-center.58moto.com')) return false
|
|
16
|
-
if(reason.includes('s23.cnzz.com')) return false
|
|
17
|
-
if(reason.includes('g.alicdn.com')) return false
|
|
18
|
-
if(reason.includes('vendors')) return false
|
|
19
|
-
return true
|
|
20
|
-
}
|
|
21
8
|
send(data:any = {}) {
|
|
22
9
|
const host = window.location.host
|
|
23
10
|
if(host.indexOf('localhost') > -1) return
|
|
11
|
+
const 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
|
|
24
12
|
if(reg.test(host)) return
|
|
25
|
-
if(!this.verifyRequest(data.reason)) return
|
|
26
|
-
data.reason = window.location.href+' '+data.reason
|
|
27
13
|
const log = { ...getExtraData(), ...data}
|
|
28
14
|
let formBody: any = [];
|
|
29
15
|
for (var property in log) {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
'use strict'
|
|
10
10
|
|
|
11
|
-
import Raven from '
|
|
11
|
+
import Raven from 'raven-js';
|
|
12
|
+
// import RavenVue from 'raven-js/plugins/vue';
|
|
12
13
|
|
|
13
14
|
class Report {
|
|
14
15
|
static instance: any;
|
|
@@ -38,10 +39,10 @@ class Report {
|
|
|
38
39
|
// raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
|
|
39
40
|
|
|
40
41
|
// 记录用户信息
|
|
41
|
-
Raven.
|
|
42
|
+
Raven.setUserContext({ user: this.options.user || '' });
|
|
42
43
|
|
|
43
44
|
// 设置全局tag标签
|
|
44
|
-
Raven.
|
|
45
|
+
Raven.setTagsContext({ environment: this.options.env || '' });
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -53,7 +54,7 @@ class Report {
|
|
|
53
54
|
*/
|
|
54
55
|
log(data: any = null, type: any = 'error', options: any = {}) {
|
|
55
56
|
// 添加面包屑
|
|
56
|
-
Raven.
|
|
57
|
+
Raven.captureBreadcrumb({
|
|
57
58
|
message: data,
|
|
58
59
|
category: 'manual message',
|
|
59
60
|
});
|
|
@@ -61,11 +62,13 @@ class Report {
|
|
|
61
62
|
if (data instanceof Error) {
|
|
62
63
|
Raven.captureException(data, {
|
|
63
64
|
level: type,
|
|
65
|
+
logger: 'manual exception',
|
|
64
66
|
tags: { options },
|
|
65
67
|
});
|
|
66
68
|
} else {
|
|
67
69
|
Raven.captureException('error', {
|
|
68
70
|
level: type,
|
|
71
|
+
logger: 'manual data',
|
|
69
72
|
extra: {
|
|
70
73
|
data,
|
|
71
74
|
options: this.options,
|
package/dist/index.cjs.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Cookie
|
|
5
|
-
* @Author: wanghui
|
|
6
|
-
* @createBy: @2021.01.21
|
|
7
|
-
*/
|
|
8
|
-
var CookieClass = /** @class */ (function () {
|
|
9
|
-
function CookieClass() {
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 获取cookie
|
|
13
|
-
* @param {String} name
|
|
14
|
-
* @return {String}
|
|
15
|
-
*/
|
|
16
|
-
CookieClass.prototype.getCookie = function (name) {
|
|
17
|
-
var _name = name + '=';
|
|
18
|
-
var ca = document.cookie.split(';');
|
|
19
|
-
for (var i = 0; i < ca.length; i++) {
|
|
20
|
-
var c = ca[i];
|
|
21
|
-
while (c.charAt(0) === ' ')
|
|
22
|
-
c = c.substring(1);
|
|
23
|
-
if (c.includes(_name))
|
|
24
|
-
return c.substring(_name.length, c.length);
|
|
25
|
-
}
|
|
26
|
-
return '';
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* 设置cookie
|
|
30
|
-
* @param {Object} ICookie
|
|
31
|
-
*/
|
|
32
|
-
CookieClass.prototype.setCookie = function (_a) {
|
|
33
|
-
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
34
|
-
var d = new Date();
|
|
35
|
-
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
36
|
-
var expires = "expires=" + d.toUTCString();
|
|
37
|
-
document.cookie = name + "=" + value + ";" + expires + ";path=" + path + ";domain=" + domain + ";";
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* 清除Cookie
|
|
41
|
-
* @param {String} name
|
|
42
|
-
*/
|
|
43
|
-
CookieClass.prototype.clearCookie = function (name) {
|
|
44
|
-
this.setCookie({
|
|
45
|
-
name: name,
|
|
46
|
-
value: '',
|
|
47
|
-
exdays: -1,
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
return CookieClass;
|
|
51
|
-
}());
|
|
52
|
-
var cookie = new CookieClass();
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @Author: wanghui
|
|
56
|
-
* createBy: @2020.05.21
|
|
57
|
-
*/
|
|
58
|
-
// import date from './modules/date'
|
|
59
|
-
// import dom from './modules/dom'
|
|
60
|
-
// import filter from './modules/filter'
|
|
61
|
-
// import format from './modules/format'
|
|
62
|
-
// import match from './modules/match'
|
|
63
|
-
// import number from './modules/number'
|
|
64
|
-
// import tools from './modules/tools'
|
|
65
|
-
var modules = {
|
|
66
|
-
cookie: cookie,
|
|
67
|
-
};
|
|
68
|
-
var Utils = /** @class */ (function () {
|
|
69
|
-
function Utils() {
|
|
70
|
-
Object.assign(this, modules);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 挂载各组件
|
|
74
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
75
|
-
* @param {Object} app 需要挂载的目标对象
|
|
76
|
-
*/
|
|
77
|
-
Utils.prototype.install = function (app) {
|
|
78
|
-
Object.keys(modules).forEach(function (key) {
|
|
79
|
-
if (key === 'filter') {
|
|
80
|
-
return modules[key].install(app);
|
|
81
|
-
}
|
|
82
|
-
app.config.globalProperties['$' + key] = modules[key];
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
return Utils;
|
|
86
|
-
}());
|
|
87
|
-
var utils = new Utils();
|
|
88
|
-
|
|
89
|
-
module.exports = utils;
|
package/dist/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare class Utils {
|
|
2
|
-
[key: string]: Object;
|
|
3
|
-
constructor();
|
|
4
|
-
/**
|
|
5
|
-
* 挂载各组件
|
|
6
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
7
|
-
* @param {Object} app 需要挂载的目标对象
|
|
8
|
-
*/
|
|
9
|
-
install(app: any): void;
|
|
10
|
-
}
|
|
11
|
-
declare const utils: Utils;
|
|
12
|
-
export default utils;
|
package/dist/index.esm.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Cookie
|
|
3
|
-
* @Author: wanghui
|
|
4
|
-
* @createBy: @2021.01.21
|
|
5
|
-
*/
|
|
6
|
-
var CookieClass = /** @class */ (function () {
|
|
7
|
-
function CookieClass() {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* 获取cookie
|
|
11
|
-
* @param {String} name
|
|
12
|
-
* @return {String}
|
|
13
|
-
*/
|
|
14
|
-
CookieClass.prototype.getCookie = function (name) {
|
|
15
|
-
var _name = name + '=';
|
|
16
|
-
var ca = document.cookie.split(';');
|
|
17
|
-
for (var i = 0; i < ca.length; i++) {
|
|
18
|
-
var c = ca[i];
|
|
19
|
-
while (c.charAt(0) === ' ')
|
|
20
|
-
c = c.substring(1);
|
|
21
|
-
if (c.includes(_name))
|
|
22
|
-
return c.substring(_name.length, c.length);
|
|
23
|
-
}
|
|
24
|
-
return '';
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* 设置cookie
|
|
28
|
-
* @param {Object} ICookie
|
|
29
|
-
*/
|
|
30
|
-
CookieClass.prototype.setCookie = function (_a) {
|
|
31
|
-
var _b = _a.name, name = _b === void 0 ? '' : _b, _c = _a.value, value = _c === void 0 ? '' : _c, _d = _a.exdays, exdays = _d === void 0 ? -1 : _d, _e = _a.path, path = _e === void 0 ? '/' : _e, _f = _a.domain, domain = _f === void 0 ? '.jddmoto.com' : _f;
|
|
32
|
-
var d = new Date();
|
|
33
|
-
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
|
34
|
-
var expires = "expires=" + d.toUTCString();
|
|
35
|
-
document.cookie = name + "=" + value + ";" + expires + ";path=" + path + ";domain=" + domain + ";";
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* 清除Cookie
|
|
39
|
-
* @param {String} name
|
|
40
|
-
*/
|
|
41
|
-
CookieClass.prototype.clearCookie = function (name) {
|
|
42
|
-
this.setCookie({
|
|
43
|
-
name: name,
|
|
44
|
-
value: '',
|
|
45
|
-
exdays: -1,
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
return CookieClass;
|
|
49
|
-
}());
|
|
50
|
-
var cookie = new CookieClass();
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @Author: wanghui
|
|
54
|
-
* createBy: @2020.05.21
|
|
55
|
-
*/
|
|
56
|
-
// import date from './modules/date'
|
|
57
|
-
// import dom from './modules/dom'
|
|
58
|
-
// import filter from './modules/filter'
|
|
59
|
-
// import format from './modules/format'
|
|
60
|
-
// import match from './modules/match'
|
|
61
|
-
// import number from './modules/number'
|
|
62
|
-
// import tools from './modules/tools'
|
|
63
|
-
var modules = {
|
|
64
|
-
cookie: cookie,
|
|
65
|
-
};
|
|
66
|
-
var Utils = /** @class */ (function () {
|
|
67
|
-
function Utils() {
|
|
68
|
-
Object.assign(this, modules);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 挂载各组件
|
|
72
|
-
* 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
|
|
73
|
-
* @param {Object} app 需要挂载的目标对象
|
|
74
|
-
*/
|
|
75
|
-
Utils.prototype.install = function (app) {
|
|
76
|
-
Object.keys(modules).forEach(function (key) {
|
|
77
|
-
if (key === 'filter') {
|
|
78
|
-
return modules[key].install(app);
|
|
79
|
-
}
|
|
80
|
-
app.config.globalProperties['$' + key] = modules[key];
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
return Utils;
|
|
84
|
-
}());
|
|
85
|
-
var utils = new Utils();
|
|
86
|
-
|
|
87
|
-
export { utils as default };
|
package/dist/lib-list.d.ts
DELETED