@tourmind-frontend/monitor-plugin-nuxt 1.2.1 → 1.4.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.cjs +8 -5
- package/dist/index.d.ts +6 -3
- package/package.json +3 -3
- package/templates/plugin.client.js +2 -2
package/dist/index.cjs
CHANGED
|
@@ -82,7 +82,8 @@ function readSourceContext(rootDir, file, hintLine, hintCol, contextLines = 10)
|
|
|
82
82
|
}
|
|
83
83
|
function MonitorModule(options) {
|
|
84
84
|
if (!options.url) throw new Error(`${LOG_PREFIX} "url" is required`);
|
|
85
|
-
if (!options.
|
|
85
|
+
if (!options.clientKey) throw new Error(`${LOG_PREFIX} "clientKey" is required`);
|
|
86
|
+
if (!options.authToken) throw new Error(`${LOG_PREFIX} "authToken" is required`);
|
|
86
87
|
if (!options.commit) throw new Error(`${LOG_PREFIX} "commit" is required`);
|
|
87
88
|
this.extendBuild((config, { isClient, isDev }) => {
|
|
88
89
|
if (isDev || !isClient) return;
|
|
@@ -91,7 +92,7 @@ function MonitorModule(options) {
|
|
|
91
92
|
config.plugins.push(
|
|
92
93
|
new import_monitor_plugin_webpack.default({
|
|
93
94
|
url: options.url,
|
|
94
|
-
|
|
95
|
+
authToken: options.authToken,
|
|
95
96
|
commit: options.commit
|
|
96
97
|
})
|
|
97
98
|
);
|
|
@@ -102,11 +103,12 @@ function MonitorModule(options) {
|
|
|
102
103
|
mode: "client",
|
|
103
104
|
options: {
|
|
104
105
|
url: options.url,
|
|
105
|
-
|
|
106
|
+
clientKey: options.clientKey
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
const ssrReportUrl = `${options.url.replace(/\/+$/, "")}/api/ssr-report`;
|
|
109
|
-
const
|
|
110
|
+
const clientKey = options.clientKey;
|
|
111
|
+
const commit = options.commit;
|
|
110
112
|
const rootDir = this.options.rootDir || this.options.srcDir || process.cwd();
|
|
111
113
|
this.nuxt.hook("render:errorMiddleware", (app) => {
|
|
112
114
|
app.use((err, req, _res, next) => {
|
|
@@ -124,9 +126,10 @@ function MonitorModule(options) {
|
|
|
124
126
|
method: "POST",
|
|
125
127
|
headers: { "Content-Type": "application/json" },
|
|
126
128
|
body: JSON.stringify({
|
|
127
|
-
token,
|
|
129
|
+
token: clientKey,
|
|
128
130
|
stack: refinedStack,
|
|
129
131
|
url: req.url || "",
|
|
132
|
+
commit,
|
|
130
133
|
...sourceCtx || {}
|
|
131
134
|
})
|
|
132
135
|
}).catch(() => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface MonitorModuleOptions {
|
|
2
|
-
/** monitor 项目
|
|
3
|
-
|
|
2
|
+
/** monitor 项目 client key(前缀 `fm_ck_`),浏览器 / SSR 上报使用,会出现在客户端 bundle 中。 */
|
|
3
|
+
clientKey: string;
|
|
4
|
+
/** monitor 项目 auth token(前缀 `fm_at_`),仅供构建机上传 sourcemap 使用。 */
|
|
5
|
+
authToken: string;
|
|
4
6
|
/** monitor 服务的 base URL,例如 `https://monitor.example.com`。`/api/report`、`/api/upload` 由下游 tracking / plugin-webpack 内部拼接。 */
|
|
5
7
|
url: string;
|
|
6
8
|
/** Commit hash,由调用方自行解析(如 `git rev-parse HEAD`)。 */
|
|
@@ -53,7 +55,8 @@ interface NuxtModuleThis {
|
|
|
53
55
|
* modules: [
|
|
54
56
|
* ['@tourmind-frontend/monitor-plugin-nuxt', {
|
|
55
57
|
* url: 'https://monitor.example.com',
|
|
56
|
-
*
|
|
58
|
+
* clientKey: process.env.MONITOR_CLIENT_KEY,
|
|
59
|
+
* authToken: process.env.MONITOR_AUTH_TOKEN,
|
|
57
60
|
* commit: process.env.GIT_COMMIT,
|
|
58
61
|
* }],
|
|
59
62
|
* ],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tourmind-frontend/monitor-plugin-nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Nuxt 2 module that captures runtime errors and uploads sourcemaps to a frontend-monitor server.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"node": ">=13"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tourmind-frontend/monitor-plugin-webpack": "^1.
|
|
20
|
+
"@tourmind-frontend/monitor-plugin-webpack": "^1.4.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"nuxt": "^2.4.0",
|
|
24
24
|
"vue": "^2.5.0",
|
|
25
|
-
"@tourmind-frontend/monitor-tracking": "^1.
|
|
25
|
+
"@tourmind-frontend/monitor-tracking": "^1.4.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^20.0.0",
|
|
@@ -5,9 +5,9 @@ import { register } from "@tourmind-frontend/monitor-tracking";
|
|
|
5
5
|
export default function () {
|
|
6
6
|
register({
|
|
7
7
|
url: "<%= options.url %>",
|
|
8
|
-
|
|
8
|
+
clientKey: "<%= options.clientKey %>",
|
|
9
9
|
// 桥接 Vue 2 的 errorHandler,链式调用既有 handler,不覆盖。
|
|
10
|
-
|
|
10
|
+
listener: function (handler) {
|
|
11
11
|
var existing = Vue.config.errorHandler;
|
|
12
12
|
Vue.config.errorHandler = function (err, vm, info) {
|
|
13
13
|
try {
|