@tourmind-frontend/monitor-plugin-nuxt 1.0.4 → 1.1.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 +5 -11
- package/dist/index.d.ts +5 -10
- package/package.json +5 -5
- package/templates/plugin.client.js +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,24 +37,18 @@ var import_node_path = require("path");
|
|
|
37
37
|
var import_monitor_plugin_webpack = __toESM(require("@tourmind-frontend/monitor-plugin-webpack"));
|
|
38
38
|
var LOG_PREFIX = "[frontend-monitor]";
|
|
39
39
|
function MonitorModule(options) {
|
|
40
|
-
if (!(options == null ? void 0 : options.
|
|
40
|
+
if (!(options == null ? void 0 : options.token)) throw new Error(`${LOG_PREFIX} "token" is required`);
|
|
41
41
|
if (!options.reportUrl) throw new Error(`${LOG_PREFIX} "reportUrl" is required`);
|
|
42
42
|
if (!options.uploadUrl) throw new Error(`${LOG_PREFIX} "uploadUrl" is required`);
|
|
43
|
-
if (!options.branch) throw new Error(`${LOG_PREFIX} "branch" is required`);
|
|
44
43
|
this.extendBuild((config, { isClient, isDev }) => {
|
|
45
|
-
|
|
46
|
-
const enabled = (_a = options.uploadEnabled) != null ? _a : !isDev;
|
|
47
|
-
if (!enabled || !isClient) return;
|
|
44
|
+
if (isDev || !isClient) return;
|
|
48
45
|
config.devtool = "hidden-source-map";
|
|
49
46
|
config.plugins = config.plugins || [];
|
|
50
47
|
config.plugins.push(
|
|
51
48
|
new import_monitor_plugin_webpack.default({
|
|
52
49
|
url: options.uploadUrl,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
commit: options.commit,
|
|
56
|
-
// 已经在 extendBuild 层 gate 过,跳过 plugin 内部的 mode 判断。
|
|
57
|
-
enabled: true
|
|
50
|
+
token: options.token,
|
|
51
|
+
commit: options.commit
|
|
58
52
|
})
|
|
59
53
|
);
|
|
60
54
|
});
|
|
@@ -64,7 +58,7 @@ function MonitorModule(options) {
|
|
|
64
58
|
mode: "client",
|
|
65
59
|
options: {
|
|
66
60
|
url: options.reportUrl,
|
|
67
|
-
|
|
61
|
+
token: options.token
|
|
68
62
|
}
|
|
69
63
|
});
|
|
70
64
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
export interface MonitorModuleOptions {
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/** monitor 项目 token,从 web 控制台创建项目后获取,内部已绑定仓库 + 分支。 */
|
|
3
|
+
token: string;
|
|
4
4
|
/** 上报接口地址,例如 `https://monitor.example.com/api/report`。 */
|
|
5
5
|
reportUrl: string;
|
|
6
6
|
/** sourcemap 上传接口地址,例如 `https://monitor.example.com/api/upload`。 */
|
|
7
7
|
uploadUrl: string;
|
|
8
|
-
/** 分支名,由调用方自行解析(如 `git rev-parse --abbrev-ref HEAD`)。 */
|
|
9
|
-
branch: string;
|
|
10
8
|
/** Commit hash,由调用方自行解析(如 `git rev-parse HEAD`)。 */
|
|
11
9
|
commit?: string;
|
|
12
|
-
/** 强制启用 / 禁用 sourcemap 上传。默认仅在生产构建(`!isDev`)时为 `true`。 */
|
|
13
|
-
uploadEnabled?: boolean;
|
|
14
10
|
}
|
|
15
11
|
interface NuxtBuildContext {
|
|
16
12
|
isClient: boolean;
|
|
@@ -33,7 +29,7 @@ interface NuxtModuleThis {
|
|
|
33
29
|
}): void;
|
|
34
30
|
}
|
|
35
31
|
/**
|
|
36
|
-
* Nuxt 2 模块入口(兼容 `nuxt
|
|
32
|
+
* Nuxt 2 模块入口(兼容 `nuxt@^2.4.0` + `nuxt-property-decorator@^2.3.0`)。
|
|
37
33
|
*
|
|
38
34
|
* - 客户端生产构建时:通过 `@tourmind-frontend/monitor-plugin-webpack` 把 sourcemap
|
|
39
35
|
* 上传到 `uploadUrl`,避免逻辑重复
|
|
@@ -43,13 +39,12 @@ interface NuxtModuleThis {
|
|
|
43
39
|
* 在 `nuxt.config.js` 中使用:
|
|
44
40
|
*
|
|
45
41
|
* ```js
|
|
46
|
-
*
|
|
42
|
+
* module.exports = {
|
|
47
43
|
* modules: [
|
|
48
44
|
* ['@tourmind-frontend/monitor-plugin-nuxt', {
|
|
49
|
-
* project: 'your-org/your-repo',
|
|
50
45
|
* reportUrl: 'https://monitor.example.com/api/report',
|
|
51
46
|
* uploadUrl: 'https://monitor.example.com/api/upload',
|
|
52
|
-
*
|
|
47
|
+
* token: process.env.MONITOR_TOKEN,
|
|
53
48
|
* commit: process.env.GIT_COMMIT,
|
|
54
49
|
* }],
|
|
55
50
|
* ],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tourmind-frontend/monitor-plugin-nuxt",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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.0
|
|
20
|
+
"@tourmind-frontend/monitor-plugin-webpack": "^1.1.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"nuxt": "
|
|
24
|
-
"vue": "
|
|
25
|
-
"@tourmind-frontend/monitor-tracking": "^1.0
|
|
23
|
+
"nuxt": "^2.4.0",
|
|
24
|
+
"vue": "^2.5.0",
|
|
25
|
+
"@tourmind-frontend/monitor-tracking": "^1.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^20.0.0",
|
|
@@ -5,7 +5,7 @@ import { register } from "@tourmind-frontend/monitor-tracking";
|
|
|
5
5
|
export default function () {
|
|
6
6
|
register({
|
|
7
7
|
url: "<%= options.url %>",
|
|
8
|
-
|
|
8
|
+
token: "<%= options.token %>",
|
|
9
9
|
// 桥接 Vue 2 的 errorHandler,链式调用既有 handler,不覆盖。
|
|
10
10
|
callback: function (handler) {
|
|
11
11
|
var existing = Vue.config.errorHandler;
|