@zharp/node 0.3.0 → 0.4.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/dist/index.d.mts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +714 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +677 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -119,6 +119,30 @@ interface NodeOptions {
|
|
|
119
119
|
* captureBodies: { mode: 'all', redactKeys: ['dateOfBirth'], urls: [/\/api\//] }
|
|
120
120
|
*/
|
|
121
121
|
captureBodies?: CaptureBodies;
|
|
122
|
+
/**
|
|
123
|
+
* Request and response headers on HTTP spans (`http.request.header.user-agent`, …), incoming
|
|
124
|
+
* and outgoing. Default **on**. Secret headers — `authorization`, `cookie`, `set-cookie`, API
|
|
125
|
+
* keys, tokens, and any name matching the body key rules — are recorded as `[Filtered]`: you
|
|
126
|
+
* see that one was sent, never its value. Add names to `redact` to filter more. `false` (or
|
|
127
|
+
* `ZHARP_CAPTURE_HEADERS=false`) turns it off.
|
|
128
|
+
*/
|
|
129
|
+
captureHeaders?: boolean | {
|
|
130
|
+
redact?: Array<string | RegExp>;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Failed database queries reported as errors, with the line of your code that ran the query
|
|
134
|
+
* as their stack, the statement, and the driver's code (Postgres 23505 → `UniqueViolation`).
|
|
135
|
+
* Default true.
|
|
136
|
+
*/
|
|
137
|
+
captureQueryErrors?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The code around each error's lines, read on this server from your own files (never
|
|
140
|
+
* node_modules) and sent with the error, so Zharp shows exactly the code that ran without a
|
|
141
|
+
* repository link. Built code (TypeScript, a NestJS dist/) is read through the .js.map files
|
|
142
|
+
* next to it: the stack and the code are your sources. The innermost five frames, five lines
|
|
143
|
+
* either side. Default true; ZHARP_CAPTURE_SOURCE_CONTEXT=false turns it off.
|
|
144
|
+
*/
|
|
145
|
+
captureSourceContext?: boolean;
|
|
122
146
|
/**
|
|
123
147
|
* Capture uncaught exceptions and unhandled rejections. Default true. The process still
|
|
124
148
|
* exits as Node would have, once they have been sent.
|
|
@@ -148,6 +172,8 @@ declare class ZharpNode {
|
|
|
148
172
|
private tracing;
|
|
149
173
|
/** Errors already sent, so one that is both rejected and then thrown is reported once. */
|
|
150
174
|
private readonly reported;
|
|
175
|
+
/** Failed queries waiting to be reported, once and with their call site. */
|
|
176
|
+
private dbErrors;
|
|
151
177
|
/** `Zharp.log.info("Order placed", { orderId })` — and debug, warn, error, fatal, trace. */
|
|
152
178
|
readonly log: Record<Level, LogFn>;
|
|
153
179
|
/** Whether `init()` started the SDK. */
|
|
@@ -178,6 +204,25 @@ declare class ZharpNode {
|
|
|
178
204
|
* in, and grouped into an issue with every other occurrence.
|
|
179
205
|
*/
|
|
180
206
|
captureError(error: unknown, attributes?: Attributes): void;
|
|
207
|
+
/**
|
|
208
|
+
* Next.js (15+): errors a route handler, server component, server action or middleware threw,
|
|
209
|
+
* which Next answers with an error page and only prints. Export it from instrumentation.ts:
|
|
210
|
+
*
|
|
211
|
+
* export const onRequestError = Zharp.onRequestError;
|
|
212
|
+
*
|
|
213
|
+
* Each is reported once as a crash, with the request's path, method and route. A bound function,
|
|
214
|
+
* so it can be exported as it is.
|
|
215
|
+
*/
|
|
216
|
+
readonly onRequestError: (error: unknown, request?: {
|
|
217
|
+
path?: string;
|
|
218
|
+
method?: string;
|
|
219
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
220
|
+
}, context?: {
|
|
221
|
+
routerKind?: string;
|
|
222
|
+
routePath?: string;
|
|
223
|
+
routeType?: string;
|
|
224
|
+
renderSource?: string;
|
|
225
|
+
}) => void;
|
|
181
226
|
/**
|
|
182
227
|
* Run `fn` inside a span named `name`, which ends when `fn` returns or its promise settles. A
|
|
183
228
|
* throw or rejection marks the span as failed and is passed on unchanged.
|
|
@@ -189,6 +234,8 @@ declare class ZharpNode {
|
|
|
189
234
|
shutdown(): Promise<void>;
|
|
190
235
|
private emit;
|
|
191
236
|
private report;
|
|
237
|
+
/** A failed query as an error, in the query's own span so the error shows the query. */
|
|
238
|
+
private sendQueryError;
|
|
192
239
|
/**
|
|
193
240
|
* Uncaught exceptions and unhandled rejections, reported as unhandled.
|
|
194
241
|
*
|
|
@@ -209,7 +256,7 @@ declare class ZharpNode {
|
|
|
209
256
|
}
|
|
210
257
|
|
|
211
258
|
/** Sent as `telemetry.sdk.version`. Bumped with package.json. */
|
|
212
|
-
declare const VERSION = "0.
|
|
259
|
+
declare const VERSION = "0.4.0";
|
|
213
260
|
|
|
214
261
|
declare const Zharp: ZharpNode;
|
|
215
262
|
|
package/dist/index.d.ts
CHANGED
|
@@ -119,6 +119,30 @@ interface NodeOptions {
|
|
|
119
119
|
* captureBodies: { mode: 'all', redactKeys: ['dateOfBirth'], urls: [/\/api\//] }
|
|
120
120
|
*/
|
|
121
121
|
captureBodies?: CaptureBodies;
|
|
122
|
+
/**
|
|
123
|
+
* Request and response headers on HTTP spans (`http.request.header.user-agent`, …), incoming
|
|
124
|
+
* and outgoing. Default **on**. Secret headers — `authorization`, `cookie`, `set-cookie`, API
|
|
125
|
+
* keys, tokens, and any name matching the body key rules — are recorded as `[Filtered]`: you
|
|
126
|
+
* see that one was sent, never its value. Add names to `redact` to filter more. `false` (or
|
|
127
|
+
* `ZHARP_CAPTURE_HEADERS=false`) turns it off.
|
|
128
|
+
*/
|
|
129
|
+
captureHeaders?: boolean | {
|
|
130
|
+
redact?: Array<string | RegExp>;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Failed database queries reported as errors, with the line of your code that ran the query
|
|
134
|
+
* as their stack, the statement, and the driver's code (Postgres 23505 → `UniqueViolation`).
|
|
135
|
+
* Default true.
|
|
136
|
+
*/
|
|
137
|
+
captureQueryErrors?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The code around each error's lines, read on this server from your own files (never
|
|
140
|
+
* node_modules) and sent with the error, so Zharp shows exactly the code that ran without a
|
|
141
|
+
* repository link. Built code (TypeScript, a NestJS dist/) is read through the .js.map files
|
|
142
|
+
* next to it: the stack and the code are your sources. The innermost five frames, five lines
|
|
143
|
+
* either side. Default true; ZHARP_CAPTURE_SOURCE_CONTEXT=false turns it off.
|
|
144
|
+
*/
|
|
145
|
+
captureSourceContext?: boolean;
|
|
122
146
|
/**
|
|
123
147
|
* Capture uncaught exceptions and unhandled rejections. Default true. The process still
|
|
124
148
|
* exits as Node would have, once they have been sent.
|
|
@@ -148,6 +172,8 @@ declare class ZharpNode {
|
|
|
148
172
|
private tracing;
|
|
149
173
|
/** Errors already sent, so one that is both rejected and then thrown is reported once. */
|
|
150
174
|
private readonly reported;
|
|
175
|
+
/** Failed queries waiting to be reported, once and with their call site. */
|
|
176
|
+
private dbErrors;
|
|
151
177
|
/** `Zharp.log.info("Order placed", { orderId })` — and debug, warn, error, fatal, trace. */
|
|
152
178
|
readonly log: Record<Level, LogFn>;
|
|
153
179
|
/** Whether `init()` started the SDK. */
|
|
@@ -178,6 +204,25 @@ declare class ZharpNode {
|
|
|
178
204
|
* in, and grouped into an issue with every other occurrence.
|
|
179
205
|
*/
|
|
180
206
|
captureError(error: unknown, attributes?: Attributes): void;
|
|
207
|
+
/**
|
|
208
|
+
* Next.js (15+): errors a route handler, server component, server action or middleware threw,
|
|
209
|
+
* which Next answers with an error page and only prints. Export it from instrumentation.ts:
|
|
210
|
+
*
|
|
211
|
+
* export const onRequestError = Zharp.onRequestError;
|
|
212
|
+
*
|
|
213
|
+
* Each is reported once as a crash, with the request's path, method and route. A bound function,
|
|
214
|
+
* so it can be exported as it is.
|
|
215
|
+
*/
|
|
216
|
+
readonly onRequestError: (error: unknown, request?: {
|
|
217
|
+
path?: string;
|
|
218
|
+
method?: string;
|
|
219
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
220
|
+
}, context?: {
|
|
221
|
+
routerKind?: string;
|
|
222
|
+
routePath?: string;
|
|
223
|
+
routeType?: string;
|
|
224
|
+
renderSource?: string;
|
|
225
|
+
}) => void;
|
|
181
226
|
/**
|
|
182
227
|
* Run `fn` inside a span named `name`, which ends when `fn` returns or its promise settles. A
|
|
183
228
|
* throw or rejection marks the span as failed and is passed on unchanged.
|
|
@@ -189,6 +234,8 @@ declare class ZharpNode {
|
|
|
189
234
|
shutdown(): Promise<void>;
|
|
190
235
|
private emit;
|
|
191
236
|
private report;
|
|
237
|
+
/** A failed query as an error, in the query's own span so the error shows the query. */
|
|
238
|
+
private sendQueryError;
|
|
192
239
|
/**
|
|
193
240
|
* Uncaught exceptions and unhandled rejections, reported as unhandled.
|
|
194
241
|
*
|
|
@@ -209,7 +256,7 @@ declare class ZharpNode {
|
|
|
209
256
|
}
|
|
210
257
|
|
|
211
258
|
/** Sent as `telemetry.sdk.version`. Bumped with package.json. */
|
|
212
|
-
declare const VERSION = "0.
|
|
259
|
+
declare const VERSION = "0.4.0";
|
|
213
260
|
|
|
214
261
|
declare const Zharp: ZharpNode;
|
|
215
262
|
|