usetraceforge 0.1.20 → 0.1.22

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,5 @@
1
+ import { TraceForgeConfig } from "./index.js";
2
+ export declare class TraceForgeErrorHandler {
3
+ handleError(error: any): void;
4
+ }
5
+ export declare function initTraceForgeAngular(options: TraceForgeConfig): void;
@@ -0,0 +1,20 @@
1
+ import TraceForge from "./index.js";
2
+ // We do NOT import @angular/core to avoid a hard dependency in the SDK package.
3
+ // Angular developers will provide this class as their ErrorHandler.
4
+ export class TraceForgeErrorHandler {
5
+ handleError(error) {
6
+ // Capture the error and tag it as coming from Angular
7
+ TraceForge.captureException(error, {
8
+ environment: "browser",
9
+ tags: { framework: "angular" }
10
+ });
11
+ // Mirror Angular's default behavior of logging to console
12
+ console.error("ERROR", error);
13
+ }
14
+ }
15
+ export function initTraceForgeAngular(options) {
16
+ TraceForge.init({
17
+ ...options,
18
+ autoCapture: options.autoCapture ?? true
19
+ });
20
+ }
package/dist/vue.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { TraceForgeConfig } from "./index.js";
2
+ export declare const TraceForgeVue: {
3
+ install(app: any, options: TraceForgeConfig): void;
4
+ };
package/dist/vue.js ADDED
@@ -0,0 +1,25 @@
1
+ import TraceForge from "./index.js";
2
+ export const TraceForgeVue = {
3
+ install(app, options) {
4
+ // Initialize TraceForge with autoCapture true by default for Vue apps
5
+ TraceForge.init({
6
+ ...options,
7
+ autoCapture: options.autoCapture ?? true,
8
+ });
9
+ const originalErrorHandler = app.config.errorHandler;
10
+ // Hook into Vue's global error handler to capture rendering/lifecycle errors
11
+ app.config.errorHandler = (err, instance, info) => {
12
+ TraceForge.captureException(err, {
13
+ environment: "browser",
14
+ tags: { framework: "vue", vueInfo: info }
15
+ });
16
+ // Call the original error handler if it exists, otherwise log to console
17
+ if (originalErrorHandler) {
18
+ originalErrorHandler(err, instance, info);
19
+ }
20
+ else {
21
+ console.error(err);
22
+ }
23
+ };
24
+ }
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usetraceforge",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "private": false,
5
5
  "description": "TraceForge JavaScript SDK for sending errors to a TraceForge ingest endpoint.",
6
6
  "type": "module",
@@ -48,6 +48,18 @@
48
48
  "import": "./dist/next.js",
49
49
  "require": "./dist/next.js",
50
50
  "default": "./dist/next.js"
51
+ },
52
+ "./vue": {
53
+ "types": "./dist/vue.d.ts",
54
+ "import": "./dist/vue.js",
55
+ "require": "./dist/vue.js",
56
+ "default": "./dist/vue.js"
57
+ },
58
+ "./angular": {
59
+ "types": "./dist/angular.d.ts",
60
+ "import": "./dist/angular.js",
61
+ "require": "./dist/angular.js",
62
+ "default": "./dist/angular.js"
51
63
  }
52
64
  },
53
65
  "files": [