diff --git a/packages/vue-cli-plugin-uni/lib/error-reporting.js b/packages/vue-cli-plugin-uni/lib/error-reporting.js index 104058449910fb6d43d1e3323b0b1e0b99e8a7a8..e196abdac179f0d9ff0f0d076cad446b3266fbe5 100644 --- a/packages/vue-cli-plugin-uni/lib/error-reporting.js +++ b/packages/vue-cli-plugin-uni/lib/error-reporting.js @@ -11,8 +11,9 @@ class ErrorReport { this._instance = null; this._https = null; this._crypto = null; - this._cacheList = []; - this._isReporting = false; + this._cacheList = []; + this._UNI_INPUT_DIR_REG = new RegExp(process.env.UNI_INPUT_DIR.replace(/\\/g, '\/'), 'g'); + this._UNI_CLI_CONTEXT_REG = new RegExp(process.env.UNI_CLI_CONTEXT.replace(/\\/g, '\/'), 'g'); } get https() { @@ -32,7 +33,11 @@ class ErrorReport { report(type, err) { if (!this._shouldReport(err)) { return; - } + } + + err = err.replace(/\\/g, '\/') + err = err.replace(this._UNI_INPUT_DIR_REG, 'UNI_INPUT_DIR') + err = err.replace(this._UNI_CLI_CONTEXT_REG, 'UNI_CLI_CONTEXT') const data = JSON.stringify({ np: process.platform, @@ -40,7 +45,7 @@ class ErrorReport { cp: process.env.UNI_PLATFORM, hx: this.isInHBuilderX ? 1 : 0, et: type, - em: err.replace(/(\().+?(node_modules[\/\\]@dcloudio)/g, '$1$2') + em: err }); var hash = this._getMD5(data); @@ -109,7 +114,7 @@ Object.assign(ErrorReport.prototype, { }); function report(type, err) { - //ErrorReport.instance.report(type, err); + ErrorReport.instance.report(type, err); } global.__error_reporting__ = report