usetraceforge 0.1.16 → 0.1.17

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/express.d.ts CHANGED
@@ -3,4 +3,4 @@ import { Request, Response, NextFunction } from "express";
3
3
  * Express middleware to catch unhandled errors and report them to TraceForge.
4
4
  * Ensure this is added AFTER all your routes and controllers, but BEFORE your custom error handler.
5
5
  */
6
- export declare const TraceForgeErrorHandler: (error: Error, req: Request, res: Response, next: NextFunction) => void;
6
+ export declare const expressErrorHandler: () => (error: Error, req: Request, res: Response, next: NextFunction) => void;
package/dist/express.js CHANGED
@@ -3,25 +3,27 @@ import TraceForge from "./index.js";
3
3
  * Express middleware to catch unhandled errors and report them to TraceForge.
4
4
  * Ensure this is added AFTER all your routes and controllers, but BEFORE your custom error handler.
5
5
  */
6
- export const TraceForgeErrorHandler = (error, req, res, next) => {
7
- TraceForge.captureException(error, {
8
- environment: "node",
9
- tags: {
10
- method: req.method,
11
- url: req.url,
12
- path: req.path,
13
- ip: req.ip || "Unknown"
14
- },
15
- payload: {
16
- query: req.query,
17
- body: req.body,
18
- headers: {
19
- ...req.headers,
20
- authorization: req.headers.authorization ? "[REDACTED]" : undefined,
21
- cookie: req.headers.cookie ? "[REDACTED]" : undefined
6
+ export const expressErrorHandler = () => {
7
+ return (error, req, res, next) => {
8
+ TraceForge.captureException(error, {
9
+ environment: "node",
10
+ tags: {
11
+ method: req.method,
12
+ url: req.url,
13
+ path: req.path,
14
+ ip: req.ip || "Unknown"
15
+ },
16
+ payload: {
17
+ query: req.query,
18
+ body: req.body,
19
+ headers: {
20
+ ...req.headers,
21
+ authorization: req.headers.authorization ? "[REDACTED]" : undefined,
22
+ cookie: req.headers.cookie ? "[REDACTED]" : undefined
23
+ }
22
24
  }
23
- }
24
- }).catch(() => undefined);
25
- // Pass the error to the next error handler
26
- next(error);
25
+ }).catch(() => undefined);
26
+ // Pass the error to the next error handler
27
+ next(error);
28
+ };
27
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usetraceforge",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "private": false,
5
5
  "description": "TraceForge JavaScript SDK for sending errors to a TraceForge ingest endpoint.",
6
6
  "type": "module",