@tourmind-frontend/monitor-plugin-nuxt 1.4.2 → 1.6.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 +10 -9
- package/dist/index.d.ts +2 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -126,18 +126,19 @@ function MonitorModule(options) {
|
|
|
126
126
|
if (!options.clientKey) throw new Error(`${LOG_PREFIX} "clientKey" is required`);
|
|
127
127
|
if (!options.authToken) throw new Error(`${LOG_PREFIX} "authToken" is required`);
|
|
128
128
|
if (!options.commit) throw new Error(`${LOG_PREFIX} "commit" is required`);
|
|
129
|
+
const uploadPlugin = new import_monitor_plugin_webpack.default({
|
|
130
|
+
url: options.url,
|
|
131
|
+
authToken: options.authToken,
|
|
132
|
+
commit: options.commit,
|
|
133
|
+
deferWait: true
|
|
134
|
+
});
|
|
129
135
|
this.extendBuild((config, { isClient, isDev }) => {
|
|
130
136
|
if (isDev || !isClient) return;
|
|
131
137
|
config.devtool = "hidden-source-map";
|
|
132
138
|
config.plugins = config.plugins || [];
|
|
133
|
-
config.plugins.push(
|
|
134
|
-
new import_monitor_plugin_webpack.default({
|
|
135
|
-
url: options.url,
|
|
136
|
-
authToken: options.authToken,
|
|
137
|
-
commit: options.commit
|
|
138
|
-
})
|
|
139
|
-
);
|
|
139
|
+
config.plugins.push(uploadPlugin);
|
|
140
140
|
});
|
|
141
|
+
this.nuxt.hook("build:done", () => uploadPlugin.waitForUpload());
|
|
141
142
|
this.addPlugin({
|
|
142
143
|
src: (0, import_node_path.resolve)(__dirname, "../templates/plugin.client.js"),
|
|
143
144
|
fileName: "monitor-tracking.client.js",
|
|
@@ -147,7 +148,7 @@ function MonitorModule(options) {
|
|
|
147
148
|
clientKey: options.clientKey
|
|
148
149
|
}
|
|
149
150
|
});
|
|
150
|
-
const
|
|
151
|
+
const serverReportUrl = `${options.url.replace(/\/+$/, "")}/api/server-report`;
|
|
151
152
|
const clientKey = options.clientKey;
|
|
152
153
|
const commit = options.commit;
|
|
153
154
|
const publicUrlBase = (options.publicUrl || "").replace(/\/+$/, "") || null;
|
|
@@ -181,7 +182,7 @@ function MonitorModule(options) {
|
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
184
|
postJson(
|
|
184
|
-
|
|
185
|
+
serverReportUrl,
|
|
185
186
|
JSON.stringify({
|
|
186
187
|
token: clientKey,
|
|
187
188
|
stack: refinedStack,
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface MonitorModuleOptions {
|
|
|
3
3
|
clientKey: string;
|
|
4
4
|
/** monitor 项目 auth token(前缀 `fm_at_`),仅供构建机上传 sourcemap 使用。 */
|
|
5
5
|
authToken: string;
|
|
6
|
-
/** monitor 服务的 base URL,例如 `https://monitor.example.com`。`/api/report`、`/api/upload` 由下游 tracking / plugin-webpack
|
|
6
|
+
/** monitor 服务的 base URL,例如 `https://monitor.example.com`。`/api/report`、`/api/upload` 由下游 tracking / plugin-webpack 内部拼接,`/api/server-report` 由本模块拼接。 */
|
|
7
7
|
url: string;
|
|
8
8
|
/** Commit hash,由调用方自行解析(如 `git rev-parse HEAD`)。 */
|
|
9
9
|
commit: string;
|
|
@@ -30,6 +30,7 @@ interface ConnectApp {
|
|
|
30
30
|
}
|
|
31
31
|
interface NuxtInstance {
|
|
32
32
|
hook(name: "render:errorMiddleware", handler: (app: ConnectApp) => void): void;
|
|
33
|
+
hook(name: "build:done", handler: () => Promise<void> | void): void;
|
|
33
34
|
}
|
|
34
35
|
interface NuxtModuleThis {
|
|
35
36
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tourmind-frontend/monitor-plugin-nuxt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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,7 +17,7 @@
|
|
|
17
17
|
"node": ">=13"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tourmind-frontend/monitor-plugin-webpack": "^1.
|
|
20
|
+
"@tourmind-frontend/monitor-plugin-webpack": "^1.6.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"nuxt": "^2.4.0",
|