@tracewayapp/vue 0.2.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/README.md +72 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +42 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @tracewayapp/vue
|
|
2
|
+
|
|
3
|
+
Vue.js integration for Traceway. Provides a plugin with automatic error handling and a composable hook.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createApp } from "vue";
|
|
9
|
+
import { createTracewayPlugin } from "@tracewayapp/vue";
|
|
10
|
+
import App from "./App.vue";
|
|
11
|
+
|
|
12
|
+
const app = createApp(App);
|
|
13
|
+
|
|
14
|
+
app.use(
|
|
15
|
+
createTracewayPlugin({
|
|
16
|
+
connectionString: "your-token@https://your-server.com/api/report",
|
|
17
|
+
options: { debug: true }, // optional
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
app.mount("#app");
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Automatic Error Handling
|
|
25
|
+
|
|
26
|
+
The plugin automatically installs a global error handler (`app.config.errorHandler`) that captures all Vue component errors and reports them to Traceway.
|
|
27
|
+
|
|
28
|
+
## useTraceway Composable
|
|
29
|
+
|
|
30
|
+
Access capture methods from any component.
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { useTraceway } from "@tracewayapp/vue";
|
|
35
|
+
|
|
36
|
+
const { captureException, captureMessage } = useTraceway();
|
|
37
|
+
|
|
38
|
+
function handleClick() {
|
|
39
|
+
try {
|
|
40
|
+
doSomething();
|
|
41
|
+
} catch (err) {
|
|
42
|
+
captureException(err as Error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<button @click="handleClick">Do Something</button>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
### createTracewayPlugin(options)
|
|
55
|
+
|
|
56
|
+
Creates a Vue plugin that initializes Traceway.
|
|
57
|
+
|
|
58
|
+
| Option | Type | Description |
|
|
59
|
+
|--------|------|-------------|
|
|
60
|
+
| `connectionString` | `string` | Traceway connection string (`token@url`) |
|
|
61
|
+
| `options` | `TracewayFrontendOptions` | Optional SDK configuration |
|
|
62
|
+
|
|
63
|
+
### useTraceway()
|
|
64
|
+
|
|
65
|
+
Returns `{ captureException, captureExceptionWithAttributes, captureMessage }`.
|
|
66
|
+
|
|
67
|
+
Throws if used outside a Vue app with the Traceway plugin installed.
|
|
68
|
+
|
|
69
|
+
## Requirements
|
|
70
|
+
|
|
71
|
+
- Vue >= 3.3
|
|
72
|
+
- `@tracewayapp/frontend` (installed automatically as dependency)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectionKey, App } from 'vue';
|
|
2
|
+
import * as traceway from '@tracewayapp/frontend';
|
|
3
|
+
import { TracewayFrontendOptions } from '@tracewayapp/frontend';
|
|
4
|
+
|
|
5
|
+
interface TracewayPluginOptions {
|
|
6
|
+
connectionString: string;
|
|
7
|
+
options?: TracewayFrontendOptions;
|
|
8
|
+
}
|
|
9
|
+
interface TracewayContextValue {
|
|
10
|
+
captureException: typeof traceway.captureException;
|
|
11
|
+
captureExceptionWithAttributes: typeof traceway.captureExceptionWithAttributes;
|
|
12
|
+
captureMessage: typeof traceway.captureMessage;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const TracewayKey: InjectionKey<TracewayContextValue>;
|
|
16
|
+
declare function createTracewayPlugin(pluginOptions: TracewayPluginOptions): {
|
|
17
|
+
install(app: App): void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare function useTraceway(): TracewayContextValue;
|
|
21
|
+
|
|
22
|
+
export { type TracewayContextValue, TracewayKey, type TracewayPluginOptions, createTracewayPlugin, useTraceway };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectionKey, App } from 'vue';
|
|
2
|
+
import * as traceway from '@tracewayapp/frontend';
|
|
3
|
+
import { TracewayFrontendOptions } from '@tracewayapp/frontend';
|
|
4
|
+
|
|
5
|
+
interface TracewayPluginOptions {
|
|
6
|
+
connectionString: string;
|
|
7
|
+
options?: TracewayFrontendOptions;
|
|
8
|
+
}
|
|
9
|
+
interface TracewayContextValue {
|
|
10
|
+
captureException: typeof traceway.captureException;
|
|
11
|
+
captureExceptionWithAttributes: typeof traceway.captureExceptionWithAttributes;
|
|
12
|
+
captureMessage: typeof traceway.captureMessage;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const TracewayKey: InjectionKey<TracewayContextValue>;
|
|
16
|
+
declare function createTracewayPlugin(pluginOptions: TracewayPluginOptions): {
|
|
17
|
+
install(app: App): void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
declare function useTraceway(): TracewayContextValue;
|
|
21
|
+
|
|
22
|
+
export { type TracewayContextValue, TracewayKey, type TracewayPluginOptions, createTracewayPlugin, useTraceway };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
TracewayKey: () => TracewayKey,
|
|
34
|
+
createTracewayPlugin: () => createTracewayPlugin,
|
|
35
|
+
useTraceway: () => useTraceway
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// src/plugin.ts
|
|
40
|
+
var traceway = __toESM(require("@tracewayapp/frontend"));
|
|
41
|
+
var TracewayKey = /* @__PURE__ */ Symbol("traceway");
|
|
42
|
+
function createTracewayPlugin(pluginOptions) {
|
|
43
|
+
return {
|
|
44
|
+
install(app) {
|
|
45
|
+
traceway.init(pluginOptions.connectionString, pluginOptions.options);
|
|
46
|
+
const context = {
|
|
47
|
+
captureException: traceway.captureException,
|
|
48
|
+
captureExceptionWithAttributes: traceway.captureExceptionWithAttributes,
|
|
49
|
+
captureMessage: traceway.captureMessage
|
|
50
|
+
};
|
|
51
|
+
app.provide(TracewayKey, context);
|
|
52
|
+
app.config.errorHandler = (err, instance, info) => {
|
|
53
|
+
if (err instanceof Error) {
|
|
54
|
+
traceway.captureException(err);
|
|
55
|
+
} else {
|
|
56
|
+
traceway.captureMessage(String(err));
|
|
57
|
+
}
|
|
58
|
+
console.error("[Traceway] Vue error:", err);
|
|
59
|
+
console.error("[Traceway] Component:", instance);
|
|
60
|
+
console.error("[Traceway] Info:", info);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/use-traceway.ts
|
|
67
|
+
var import_vue = require("vue");
|
|
68
|
+
function useTraceway() {
|
|
69
|
+
const context = (0, import_vue.inject)(TracewayKey);
|
|
70
|
+
if (!context) {
|
|
71
|
+
throw new Error("useTraceway must be used within a Vue app that has installed the Traceway plugin");
|
|
72
|
+
}
|
|
73
|
+
return context;
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
TracewayKey,
|
|
78
|
+
createTracewayPlugin,
|
|
79
|
+
useTraceway
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/plugin.ts","../src/use-traceway.ts"],"sourcesContent":["export { createTracewayPlugin, TracewayKey } from \"./plugin.js\";\nexport { useTraceway } from \"./use-traceway.js\";\nexport type { TracewayPluginOptions, TracewayContextValue } from \"./types.js\";\n","import type { App, InjectionKey } from \"vue\";\nimport * as traceway from \"@tracewayapp/frontend\";\nimport type { TracewayPluginOptions, TracewayContextValue } from \"./types.js\";\n\nexport const TracewayKey: InjectionKey<TracewayContextValue> = Symbol(\"traceway\");\n\nexport function createTracewayPlugin(pluginOptions: TracewayPluginOptions) {\n return {\n install(app: App) {\n traceway.init(pluginOptions.connectionString, pluginOptions.options);\n\n const context: TracewayContextValue = {\n captureException: traceway.captureException,\n captureExceptionWithAttributes: traceway.captureExceptionWithAttributes,\n captureMessage: traceway.captureMessage,\n };\n\n app.provide(TracewayKey, context);\n\n app.config.errorHandler = (err, instance, info) => {\n if (err instanceof Error) {\n traceway.captureException(err);\n } else {\n traceway.captureMessage(String(err));\n }\n console.error(\"[Traceway] Vue error:\", err);\n console.error(\"[Traceway] Component:\", instance);\n console.error(\"[Traceway] Info:\", info);\n };\n },\n };\n}\n","import { inject } from \"vue\";\nimport { TracewayKey } from \"./plugin.js\";\nimport type { TracewayContextValue } from \"./types.js\";\n\nexport function useTraceway(): TracewayContextValue {\n const context = inject(TracewayKey);\n if (!context) {\n throw new Error(\"useTraceway must be used within a Vue app that has installed the Traceway plugin\");\n }\n return context;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,eAA0B;AAGnB,IAAM,cAAkD,uBAAO,UAAU;AAEzE,SAAS,qBAAqB,eAAsC;AACzE,SAAO;AAAA,IACL,QAAQ,KAAU;AAChB,MAAS,cAAK,cAAc,kBAAkB,cAAc,OAAO;AAEnE,YAAM,UAAgC;AAAA,QACpC,kBAA2B;AAAA,QAC3B,gCAAyC;AAAA,QACzC,gBAAyB;AAAA,MAC3B;AAEA,UAAI,QAAQ,aAAa,OAAO;AAEhC,UAAI,OAAO,eAAe,CAAC,KAAK,UAAU,SAAS;AACjD,YAAI,eAAe,OAAO;AACxB,UAAS,0BAAiB,GAAG;AAAA,QAC/B,OAAO;AACL,UAAS,wBAAe,OAAO,GAAG,CAAC;AAAA,QACrC;AACA,gBAAQ,MAAM,yBAAyB,GAAG;AAC1C,gBAAQ,MAAM,yBAAyB,QAAQ;AAC/C,gBAAQ,MAAM,oBAAoB,IAAI;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;;;AC/BA,iBAAuB;AAIhB,SAAS,cAAoC;AAClD,QAAM,cAAU,mBAAO,WAAW;AAClC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kFAAkF;AAAA,EACpG;AACA,SAAO;AACT;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/plugin.ts
|
|
2
|
+
import * as traceway from "@tracewayapp/frontend";
|
|
3
|
+
var TracewayKey = /* @__PURE__ */ Symbol("traceway");
|
|
4
|
+
function createTracewayPlugin(pluginOptions) {
|
|
5
|
+
return {
|
|
6
|
+
install(app) {
|
|
7
|
+
traceway.init(pluginOptions.connectionString, pluginOptions.options);
|
|
8
|
+
const context = {
|
|
9
|
+
captureException: traceway.captureException,
|
|
10
|
+
captureExceptionWithAttributes: traceway.captureExceptionWithAttributes,
|
|
11
|
+
captureMessage: traceway.captureMessage
|
|
12
|
+
};
|
|
13
|
+
app.provide(TracewayKey, context);
|
|
14
|
+
app.config.errorHandler = (err, instance, info) => {
|
|
15
|
+
if (err instanceof Error) {
|
|
16
|
+
traceway.captureException(err);
|
|
17
|
+
} else {
|
|
18
|
+
traceway.captureMessage(String(err));
|
|
19
|
+
}
|
|
20
|
+
console.error("[Traceway] Vue error:", err);
|
|
21
|
+
console.error("[Traceway] Component:", instance);
|
|
22
|
+
console.error("[Traceway] Info:", info);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/use-traceway.ts
|
|
29
|
+
import { inject } from "vue";
|
|
30
|
+
function useTraceway() {
|
|
31
|
+
const context = inject(TracewayKey);
|
|
32
|
+
if (!context) {
|
|
33
|
+
throw new Error("useTraceway must be used within a Vue app that has installed the Traceway plugin");
|
|
34
|
+
}
|
|
35
|
+
return context;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
TracewayKey,
|
|
39
|
+
createTracewayPlugin,
|
|
40
|
+
useTraceway
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts","../src/use-traceway.ts"],"sourcesContent":["import type { App, InjectionKey } from \"vue\";\nimport * as traceway from \"@tracewayapp/frontend\";\nimport type { TracewayPluginOptions, TracewayContextValue } from \"./types.js\";\n\nexport const TracewayKey: InjectionKey<TracewayContextValue> = Symbol(\"traceway\");\n\nexport function createTracewayPlugin(pluginOptions: TracewayPluginOptions) {\n return {\n install(app: App) {\n traceway.init(pluginOptions.connectionString, pluginOptions.options);\n\n const context: TracewayContextValue = {\n captureException: traceway.captureException,\n captureExceptionWithAttributes: traceway.captureExceptionWithAttributes,\n captureMessage: traceway.captureMessage,\n };\n\n app.provide(TracewayKey, context);\n\n app.config.errorHandler = (err, instance, info) => {\n if (err instanceof Error) {\n traceway.captureException(err);\n } else {\n traceway.captureMessage(String(err));\n }\n console.error(\"[Traceway] Vue error:\", err);\n console.error(\"[Traceway] Component:\", instance);\n console.error(\"[Traceway] Info:\", info);\n };\n },\n };\n}\n","import { inject } from \"vue\";\nimport { TracewayKey } from \"./plugin.js\";\nimport type { TracewayContextValue } from \"./types.js\";\n\nexport function useTraceway(): TracewayContextValue {\n const context = inject(TracewayKey);\n if (!context) {\n throw new Error(\"useTraceway must be used within a Vue app that has installed the Traceway plugin\");\n }\n return context;\n}\n"],"mappings":";AACA,YAAY,cAAc;AAGnB,IAAM,cAAkD,uBAAO,UAAU;AAEzE,SAAS,qBAAqB,eAAsC;AACzE,SAAO;AAAA,IACL,QAAQ,KAAU;AAChB,MAAS,cAAK,cAAc,kBAAkB,cAAc,OAAO;AAEnE,YAAM,UAAgC;AAAA,QACpC,kBAA2B;AAAA,QAC3B,gCAAyC;AAAA,QACzC,gBAAyB;AAAA,MAC3B;AAEA,UAAI,QAAQ,aAAa,OAAO;AAEhC,UAAI,OAAO,eAAe,CAAC,KAAK,UAAU,SAAS;AACjD,YAAI,eAAe,OAAO;AACxB,UAAS,0BAAiB,GAAG;AAAA,QAC/B,OAAO;AACL,UAAS,wBAAe,OAAO,GAAG,CAAC;AAAA,QACrC;AACA,gBAAQ,MAAM,yBAAyB,GAAG;AAC1C,gBAAQ,MAAM,yBAAyB,QAAQ;AAC/C,gBAAQ,MAAM,oBAAoB,IAAI;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AACF;;;AC/BA,SAAS,cAAc;AAIhB,SAAS,cAAoC;AAClD,QAAM,UAAU,OAAO,WAAW;AAClC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kFAAkF;AAAA,EACpG;AACA,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tracewayapp/vue",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Traceway Vue.js integration with plugin and composable",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"dev": "tsup --watch"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@tracewayapp/frontend": "0.2.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"vue": ">=3.3.0"
|
|
30
|
+
}
|
|
31
|
+
}
|