usetraceforge 0.1.25 → 0.1.27

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,13 @@
1
+ /**
2
+ * Fastify Error Handler for TraceForge
3
+ *
4
+ * Usage:
5
+ * fastify.setErrorHandler(TraceForgeFastify.errorHandler);
6
+ */
7
+ export declare const errorHandler: (error: any, request: any, reply: any) => void;
8
+ export declare const TraceForgeFastify: {
9
+ errorHandler: (error: any, request: any, reply: any) => void;
10
+ init: (options: import("./index.js").TraceForgeConfig) => void;
11
+ captureException: (error: unknown, extras?: import("./index.js").CapturePayload) => Promise<void>;
12
+ };
13
+ export default TraceForgeFastify;
@@ -0,0 +1,27 @@
1
+ import TraceForge from "./index.js";
2
+ /**
3
+ * Fastify Error Handler for TraceForge
4
+ *
5
+ * Usage:
6
+ * fastify.setErrorHandler(TraceForgeFastify.errorHandler);
7
+ */
8
+ export const errorHandler = (error, request, reply) => {
9
+ let url = undefined;
10
+ if (request) {
11
+ url = `${request.protocol || 'http'}://${request.hostname}${request.url}`;
12
+ }
13
+ TraceForge.captureException(error, {
14
+ tags: {
15
+ framework: "fastify"
16
+ },
17
+ context: url ? { url, method: request.method } : undefined
18
+ });
19
+ // Fastify default behavior: send the error to the client
20
+ reply.status(error.statusCode || 500).send(error);
21
+ };
22
+ export const TraceForgeFastify = {
23
+ errorHandler,
24
+ init: TraceForge.init,
25
+ captureException: TraceForge.captureException
26
+ };
27
+ export default TraceForgeFastify;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usetraceforge",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "private": false,
5
5
  "description": "TraceForge JavaScript SDK for sending errors to a TraceForge ingest endpoint.",
6
6
  "type": "module",
@@ -37,6 +37,11 @@
37
37
  "require": "./dist/react.js",
38
38
  "default": "./dist/react.js"
39
39
  },
40
+ "./fastify": {
41
+ "import": "./dist/fastify.js",
42
+ "require": "./dist/fastify.js",
43
+ "types": "./dist/fastify.d.ts"
44
+ },
40
45
  "./express": {
41
46
  "types": "./dist/express.d.ts",
42
47
  "import": "./dist/express.js",