kmind-apm-web-vue 0.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.
@@ -0,0 +1,14 @@
1
+ import { App } from 'vue';
2
+ import { KmindConfig } from 'kmind-apm-web';
3
+
4
+ type Router = {
5
+ afterEach: (callback: (to: {
6
+ fullPath: string;
7
+ }, from: {
8
+ fullPath: string;
9
+ }) => void) => void;
10
+ };
11
+ declare function initKmindVue(config?: Partial<KmindConfig>): void;
12
+ declare function installKmindVue(app: App, router?: Router): void;
13
+
14
+ export { initKmindVue, installKmindVue };
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ // src/index.ts
2
+ import { init, logger, recordMetric } from "kmind-apm-web";
3
+ function viteEnv() {
4
+ return import.meta.env ?? {};
5
+ }
6
+ function initKmindVue(config = {}) {
7
+ const env = viteEnv();
8
+ init({ serviceName: config.serviceName ?? env.VITE_KMIND_SERVICE_NAME ?? "vue-app", clientKey: config.clientKey ?? env.VITE_KMIND_CLIENT_KEY ?? "", endpoint: config.endpoint ?? env.VITE_KMIND_ENDPOINT, statusEndpoint: config.statusEndpoint ?? env.VITE_KMIND_STATUS_ENDPOINT, ...config });
9
+ }
10
+ function installKmindVue(app, router) {
11
+ app.config.errorHandler = (error, _instance, info) => logger.error(error instanceof Error ? error.message : String(error), { "vue.error_info": info, "exception.stacktrace": error instanceof Error ? error.stack ?? "" : "" });
12
+ router?.afterEach((to, from) => {
13
+ if (to.fullPath !== from.fullPath) recordMetric("navigation.route_change", 1, { route: to.fullPath });
14
+ });
15
+ }
16
+ export {
17
+ initKmindVue,
18
+ installKmindVue
19
+ };
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "kmind-apm-web-vue",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
8
+ "scripts": { "build": "tsup" },
9
+ "dependencies": { "kmind-apm-web": "*" },
10
+ "peerDependencies": { "vue": ">=3" },
11
+ "devDependencies": { "tsup": "^8.5.0", "typescript": "^5.8.3", "vue": "^3.5.13" }
12
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { App } from "vue";
2
+ import { init, logger, recordMetric, type KmindConfig } from "kmind-apm-web";
3
+ type PublicEnv = Record<string, string | undefined>;
4
+ type Router = { afterEach: (callback: (to: { fullPath: string }, from: { fullPath: string }) => void) => void };
5
+ function viteEnv(): PublicEnv { return (import.meta as ImportMeta & { env?: PublicEnv }).env ?? {}; }
6
+ export function initKmindVue(config: Partial<KmindConfig> = {}): void { const env = viteEnv(); init({ serviceName: config.serviceName ?? env.VITE_KMIND_SERVICE_NAME ?? "vue-app", clientKey: config.clientKey ?? env.VITE_KMIND_CLIENT_KEY ?? "", endpoint: config.endpoint ?? env.VITE_KMIND_ENDPOINT, statusEndpoint: config.statusEndpoint ?? env.VITE_KMIND_STATUS_ENDPOINT, ...config }); }
7
+ export function installKmindVue(app: App, router?: Router): void { app.config.errorHandler = (error, _instance, info) => logger.error(error instanceof Error ? error.message : String(error), { "vue.error_info": info, "exception.stacktrace": error instanceof Error ? error.stack ?? "" : "" }); router?.afterEach((to, from) => { if (to.fullPath !== from.fullPath) recordMetric("navigation.route_change", 1, { route: to.fullPath }); }); }
package/tsconfig.json ADDED
@@ -0,0 +1 @@
1
+ { "compilerOptions": { "target": "ES2020", "module": "ESNext", "moduleResolution": "Bundler", "strict": true, "declaration": true, "lib": ["DOM", "ES2020"], "skipLibCheck": true }, "include": ["src"] }
package/tsup.config.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { defineConfig } from "tsup";
2
+ export default defineConfig({ entry: ["src/index.ts"], format: ["esm"], dts: true, target: "es2020", clean: true, external: ["vue", "kmind-apm-web"] });