@guidelytech/node 0.16.0 → 0.17.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 +149 -5
- package/dist/index.cjs +1417 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +368 -7
- package/dist/index.d.ts +368 -7
- package/dist/index.js +1404 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ interface TrackMessage {
|
|
|
27
27
|
/** Links the user to this account. */
|
|
28
28
|
accountId?: string | number | null;
|
|
29
29
|
timestamp?: Timestamp;
|
|
30
|
+
/** Version of your app this event came from (default: the client's `appVersion` option). */
|
|
31
|
+
appVersion?: string | number | null;
|
|
30
32
|
}
|
|
31
33
|
interface GroupMessage {
|
|
32
34
|
/** The account id (1–256 characters). */
|
|
@@ -38,10 +40,289 @@ interface GroupMessage {
|
|
|
38
40
|
timestamp?: Timestamp;
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
/** The parts of `process` the handlers use (tests pass a fake). */
|
|
44
|
+
interface ProcessLike {
|
|
45
|
+
on(event: string, listener: (...args: any[]) => void): unknown;
|
|
46
|
+
removeListener(event: string, listener: (...args: any[]) => void): unknown;
|
|
47
|
+
listeners(event: string): Array<(...args: any[]) => void>;
|
|
48
|
+
exit(code?: number): void;
|
|
49
|
+
exitCode?: number | string | null;
|
|
50
|
+
execArgv?: string[];
|
|
51
|
+
env?: Record<string, string | undefined>;
|
|
52
|
+
}
|
|
53
|
+
/** Node's `--unhandled-rejections` modes (`warn-with-error-code` warns and sets the exit code). */
|
|
54
|
+
type UnhandledRejectionMode = "throw" | "strict" | "warn" | "warn-with-error-code" | "none";
|
|
55
|
+
interface ProcessHandlerOptions {
|
|
56
|
+
/**
|
|
57
|
+
* After an uncaught exception (or a rejection Node would have crashed on): print it, flush, then
|
|
58
|
+
* `exit(1)`, as Node does (default true). It never exits while the app has its own
|
|
59
|
+
* `uncaughtException` listeners, since Node would not either. `false` keeps the process running,
|
|
60
|
+
* like any `uncaughtException` listener does, in whatever state the error left it.
|
|
61
|
+
*/
|
|
62
|
+
exitOnUncaught?: boolean;
|
|
63
|
+
/** How unhandled rejections behave (default: Node's `--unhandled-rejections` flag, else `throw`). */
|
|
64
|
+
unhandledRejection?: UnhandledRejectionMode;
|
|
65
|
+
/** Most time spent sending before exiting (default 2000 ms). */
|
|
66
|
+
flushTimeoutMs?: number;
|
|
67
|
+
/** The process to listen on (default: `process`). */
|
|
68
|
+
process?: ProcessLike;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Error monitoring types. Event shapes use Sentry's names (https://develop.sentry.dev/sdk/data-model/),
|
|
73
|
+
* so code written for Sentry's `beforeSend` keeps working; see docs/error-monitoring/sdks.md.
|
|
74
|
+
*/
|
|
75
|
+
type SeverityLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
|
|
76
|
+
interface Breadcrumb {
|
|
77
|
+
/** `default`, `http`, `navigation`, `query`… */
|
|
78
|
+
type?: string;
|
|
79
|
+
/** `console`, `http`, `auth`, your own… */
|
|
80
|
+
category?: string;
|
|
81
|
+
message?: string;
|
|
82
|
+
level?: SeverityLevel;
|
|
83
|
+
data?: Record<string, unknown>;
|
|
84
|
+
/** Unix seconds (default: now). */
|
|
85
|
+
timestamp?: number;
|
|
86
|
+
}
|
|
87
|
+
/** What produced a breadcrumb, passed to `beforeBreadcrumb`. */
|
|
88
|
+
interface BreadcrumbHint {
|
|
89
|
+
/** Console breadcrumbs: the arguments of the call. */
|
|
90
|
+
input?: unknown[];
|
|
91
|
+
level?: string;
|
|
92
|
+
/** HTTP breadcrumbs: the `ClientRequest` / undici request and its response. */
|
|
93
|
+
request?: unknown;
|
|
94
|
+
response?: unknown;
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
}
|
|
97
|
+
interface User {
|
|
98
|
+
/** Becomes the event's `userId` (the id your frontend passes to `identify()`). */
|
|
99
|
+
id?: string | number;
|
|
100
|
+
email?: string;
|
|
101
|
+
username?: string;
|
|
102
|
+
ip_address?: string;
|
|
103
|
+
[key: string]: unknown;
|
|
104
|
+
}
|
|
105
|
+
/** One stack frame in Sentry's shape (frames are listed oldest call first). */
|
|
106
|
+
interface StackFrame {
|
|
107
|
+
function?: string;
|
|
108
|
+
filename?: string;
|
|
109
|
+
abs_path?: string;
|
|
110
|
+
module?: string;
|
|
111
|
+
lineno?: number;
|
|
112
|
+
colno?: number;
|
|
113
|
+
in_app?: boolean;
|
|
114
|
+
pre_context?: string[];
|
|
115
|
+
context_line?: string;
|
|
116
|
+
post_context?: string[];
|
|
117
|
+
vars?: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
interface Mechanism {
|
|
120
|
+
type: string;
|
|
121
|
+
handled: boolean;
|
|
122
|
+
exception_id?: number;
|
|
123
|
+
parent_id?: number;
|
|
124
|
+
/** `cause`, or `errors[i]` for an AggregateError's members. */
|
|
125
|
+
source?: string;
|
|
126
|
+
is_exception_group?: boolean;
|
|
127
|
+
synthetic?: boolean;
|
|
128
|
+
data?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
interface ExceptionValue {
|
|
131
|
+
type: string;
|
|
132
|
+
value: string;
|
|
133
|
+
module?: string;
|
|
134
|
+
mechanism: Mechanism;
|
|
135
|
+
stacktrace?: {
|
|
136
|
+
frames: StackFrame[];
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
interface RequestData {
|
|
140
|
+
method?: string;
|
|
141
|
+
/** Origin and path; the query string is in `query_string`. */
|
|
142
|
+
url?: string;
|
|
143
|
+
query_string?: string;
|
|
144
|
+
headers?: Record<string, string>;
|
|
145
|
+
env?: Record<string, string>;
|
|
146
|
+
}
|
|
147
|
+
/** The Sentry-shaped event `beforeSend` receives and the `detail` part of an `exception` message. */
|
|
148
|
+
interface ErrorEvent {
|
|
149
|
+
event_id: string;
|
|
150
|
+
/** Unix seconds. */
|
|
151
|
+
timestamp: number;
|
|
152
|
+
platform: "node";
|
|
153
|
+
level: SeverityLevel;
|
|
154
|
+
logger?: string;
|
|
155
|
+
release?: string;
|
|
156
|
+
environment?: string;
|
|
157
|
+
server_name?: string;
|
|
158
|
+
transaction?: string;
|
|
159
|
+
/** Set by `captureMessage`. */
|
|
160
|
+
logentry?: {
|
|
161
|
+
formatted: string;
|
|
162
|
+
};
|
|
163
|
+
/** Causes first, the thrown exception last. */
|
|
164
|
+
exception?: {
|
|
165
|
+
values: ExceptionValue[];
|
|
166
|
+
};
|
|
167
|
+
breadcrumbs?: {
|
|
168
|
+
values: Breadcrumb[];
|
|
169
|
+
};
|
|
170
|
+
contexts?: Record<string, Record<string, unknown>>;
|
|
171
|
+
tags?: Record<string, string>;
|
|
172
|
+
extra?: Record<string, unknown>;
|
|
173
|
+
user?: User;
|
|
174
|
+
fingerprint?: string[];
|
|
175
|
+
request?: RequestData;
|
|
176
|
+
sdk?: {
|
|
177
|
+
name: string;
|
|
178
|
+
version: string;
|
|
179
|
+
};
|
|
180
|
+
[key: string]: unknown;
|
|
181
|
+
}
|
|
182
|
+
interface EventHint {
|
|
183
|
+
/** What was passed to `captureException` (or the message of `captureMessage`). */
|
|
184
|
+
originalException: unknown;
|
|
185
|
+
event_id: string;
|
|
186
|
+
}
|
|
187
|
+
/** The second argument of `captureException` / third of `captureMessage`. */
|
|
188
|
+
interface CaptureContext {
|
|
189
|
+
/** Your user id (default: the scope user's `id`). */
|
|
190
|
+
userId?: string | number;
|
|
191
|
+
/** The browser SDK's anonymous id, for visitors who have not signed in. */
|
|
192
|
+
anonymousId?: string | number;
|
|
193
|
+
accountId?: string | number;
|
|
194
|
+
tags?: Record<string, string | number | boolean | null | undefined>;
|
|
195
|
+
extra?: Record<string, unknown>;
|
|
196
|
+
level?: SeverityLevel;
|
|
197
|
+
/** Sentry fingerprint: `["{{ default }}", "checkout"]` extends the default grouping, other values replace it. */
|
|
198
|
+
fingerprint?: string[];
|
|
199
|
+
contexts?: Record<string, Record<string, unknown> | null>;
|
|
200
|
+
/** An incoming request (Express/Fastify/Koa/`http.IncomingMessage`) or Sentry-shaped request data. */
|
|
201
|
+
request?: unknown;
|
|
202
|
+
/** How an integration caught the error (default `{ type: "generic", handled: true }`). */
|
|
203
|
+
mechanism?: {
|
|
204
|
+
type: string;
|
|
205
|
+
handled?: boolean;
|
|
206
|
+
};
|
|
207
|
+
/** Transaction name (`POST /pay`), else the scope's or the request's. */
|
|
208
|
+
transaction?: string;
|
|
209
|
+
/** Merged into the scope's user. */
|
|
210
|
+
user?: User;
|
|
211
|
+
/** Any other key is kept as an event property. */
|
|
212
|
+
[property: string]: unknown;
|
|
213
|
+
}
|
|
214
|
+
type ConsoleLevel = "debug" | "info" | "log" | "warn" | "error";
|
|
215
|
+
interface ErrorOptions {
|
|
216
|
+
/** Share of errors sent, 0–1 (default 1). */
|
|
217
|
+
sampleRate?: number;
|
|
218
|
+
/** Errors to drop: strings match `"<type>: <message>"` or the message as substrings, RegExps as patterns. */
|
|
219
|
+
ignoreErrors?: Array<string | RegExp>;
|
|
220
|
+
/** Edit or drop (`null`) an event before it is queued. A hook that throws leaves the event unchanged. */
|
|
221
|
+
beforeSend?: (event: ErrorEvent, hint: EventHint) => ErrorEvent | null | undefined | Promise<ErrorEvent | null | undefined>;
|
|
222
|
+
/** Edit or drop (`null`) a breadcrumb before it is recorded. */
|
|
223
|
+
beforeBreadcrumb?: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null | undefined;
|
|
224
|
+
/** The release errors belong to (default: the client's `appVersion`). */
|
|
225
|
+
release?: string;
|
|
226
|
+
/** `server_name` (default: `os.hostname()`). */
|
|
227
|
+
serverName?: string;
|
|
228
|
+
/** Paths (substrings or RegExps) whose frames are not your code, besides `node_modules` and Node internals. */
|
|
229
|
+
inAppExclude?: Array<string | RegExp>;
|
|
230
|
+
/** Console breadcrumbs: `true` (default) records `warn` and `error`; a list picks the levels; `false` turns them off. */
|
|
231
|
+
captureConsole?: boolean | ConsoleLevel[];
|
|
232
|
+
/** Breadcrumbs for outgoing `http`/`https` requests and `fetch` (default true). */
|
|
233
|
+
captureHttp?: boolean;
|
|
234
|
+
/** Source lines read around each in-app frame (default 5 before and after; 0 turns it off). */
|
|
235
|
+
contextLines?: number;
|
|
236
|
+
/** Send the client IP of requests (`user.ip_address`, forwarding headers). Default false. */
|
|
237
|
+
sendDefaultPii?: boolean;
|
|
238
|
+
/** Breadcrumbs kept per scope, at most 100 (default 100). */
|
|
239
|
+
maxBreadcrumbs?: number;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Data applied to every error captured while the scope is current: tags, extras, contexts, the user
|
|
244
|
+
* and the last breadcrumbs. The client has one process-wide scope; `withScope()` (and the framework
|
|
245
|
+
* middlewares, once per request) run code with a copy of it, so concurrent requests never mix.
|
|
246
|
+
*/
|
|
247
|
+
declare class Scope {
|
|
248
|
+
private readonly max;
|
|
249
|
+
private readonly hook?;
|
|
250
|
+
private tags;
|
|
251
|
+
private extra;
|
|
252
|
+
private contexts;
|
|
253
|
+
private user;
|
|
254
|
+
private level;
|
|
255
|
+
private fingerprint;
|
|
256
|
+
private transaction;
|
|
257
|
+
private crumbs;
|
|
258
|
+
/** @internal The framework request this scope was opened for (read when an error is captured). */
|
|
259
|
+
request: unknown;
|
|
260
|
+
/** @internal `max`: breadcrumbs kept; `hook`: the client's breadcrumb pipeline (`beforeBreadcrumb`). */
|
|
261
|
+
constructor(max?: number, hook?: ((crumb: Breadcrumb, scope: Scope) => void) | undefined);
|
|
262
|
+
/** A tag (searchable, ≤ 50 per event; keys ≤ 32 and values ≤ 200 characters). `null` removes it. */
|
|
263
|
+
setTag(key: string, value: string | number | boolean | null | undefined): this;
|
|
264
|
+
setTags(tags: Record<string, string | number | boolean | null | undefined>): this;
|
|
265
|
+
/** Arbitrary data shown with the event. `undefined` removes it. */
|
|
266
|
+
setExtra(key: string, value: unknown): this;
|
|
267
|
+
setExtras(extras: Record<string, unknown>): this;
|
|
268
|
+
/** A named context (`{ name: "checkout", cartSize: 3 }`); `null` removes it. */
|
|
269
|
+
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
270
|
+
/** The user errors are attributed to; `user.id` becomes the event's `userId`. `null` clears it. */
|
|
271
|
+
setUser(user: User | null): this;
|
|
272
|
+
/** Overrides the level of events captured in this scope. */
|
|
273
|
+
setLevel(level: SeverityLevel | undefined): this;
|
|
274
|
+
setFingerprint(fingerprint: string[] | undefined): this;
|
|
275
|
+
/** The transaction name (`GET /users/:id`); the request middlewares set it from the matched route. */
|
|
276
|
+
setTransactionName(name: string | undefined): this;
|
|
277
|
+
/** Records a breadcrumb through the client's `beforeBreadcrumb`. */
|
|
278
|
+
addBreadcrumb(crumb: Breadcrumb): this;
|
|
279
|
+
/** @internal Adds an already-filtered breadcrumb, dropping the oldest beyond the limit. */
|
|
280
|
+
pushBreadcrumb(crumb: Breadcrumb): void;
|
|
281
|
+
clearBreadcrumbs(): this;
|
|
282
|
+
/** Removes everything (tags, extras, contexts, user, breadcrumbs…). */
|
|
283
|
+
clear(): this;
|
|
284
|
+
/** A copy whose changes do not affect this scope. */
|
|
285
|
+
clone(): Scope;
|
|
286
|
+
/** @internal The scope's data at capture time. */
|
|
287
|
+
data(): {
|
|
288
|
+
tags: {
|
|
289
|
+
[x: string]: string;
|
|
290
|
+
};
|
|
291
|
+
extra: {
|
|
292
|
+
[x: string]: unknown;
|
|
293
|
+
};
|
|
294
|
+
contexts: {
|
|
295
|
+
[x: string]: Record<string, unknown>;
|
|
296
|
+
};
|
|
297
|
+
user: {
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
id?: string | number;
|
|
300
|
+
email?: string;
|
|
301
|
+
username?: string;
|
|
302
|
+
ip_address?: string;
|
|
303
|
+
} | null;
|
|
304
|
+
level: SeverityLevel | undefined;
|
|
305
|
+
fingerprint: string[] | undefined;
|
|
306
|
+
transaction: string | undefined;
|
|
307
|
+
breadcrumbs: Breadcrumb[];
|
|
308
|
+
request: unknown;
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Decides which errors a framework middleware reports (default: 5xx and errors without a status). */
|
|
313
|
+
interface MiddlewareOptions {
|
|
314
|
+
shouldHandleError?: (error: unknown) => boolean;
|
|
315
|
+
}
|
|
316
|
+
/** The parts of a Fastify instance the plugin uses. */
|
|
317
|
+
interface FastifyLike {
|
|
318
|
+
addHook(name: string, hook: (...args: any[]) => unknown): unknown;
|
|
319
|
+
}
|
|
320
|
+
|
|
41
321
|
declare const SDK_NAME = "guidely-node";
|
|
42
|
-
declare const SDK_VERSION = "0.
|
|
322
|
+
declare const SDK_VERSION = "0.17.0";
|
|
43
323
|
declare const DEFAULT_API_URL = "https://guidelytech.com";
|
|
44
|
-
|
|
324
|
+
/** `development`, `staging`, `production` or the key of an environment you added in Settings → Environments (`qa`, `uat`…). */
|
|
325
|
+
type Environment = "development" | "staging" | "production" | (string & {});
|
|
45
326
|
/** The subset of `fetch` the SDK uses, so any implementation (undici, node-fetch, a test fake) fits. */
|
|
46
327
|
type FetchLike = (url: string, init: {
|
|
47
328
|
method: "POST";
|
|
@@ -58,7 +339,7 @@ type FetchLike = (url: string, init: {
|
|
|
58
339
|
type GuidelyErrorCode =
|
|
59
340
|
/** A call was invalid (missing userId, empty event…) and dropped. */
|
|
60
341
|
"invalid_message"
|
|
61
|
-
/** A message serialized to more than 32 KB and was dropped. */
|
|
342
|
+
/** A message serialized to more than 32 KB (80 KB for an exception) and was dropped. */
|
|
62
343
|
| "message_too_large"
|
|
63
344
|
/** The queue was full (`maxQueueSize`); the oldest messages were dropped. */
|
|
64
345
|
| "queue_full"
|
|
@@ -85,7 +366,7 @@ declare class GuidelyError extends Error {
|
|
|
85
366
|
interface GuidelyOptions {
|
|
86
367
|
/** A secret API key (`gly_sk_…`) with the `events:write` scope. Never ship it to a browser. */
|
|
87
368
|
secretKey: string;
|
|
88
|
-
/**
|
|
369
|
+
/** Key of the environment events are written to (`production`, or e.g. `qa` for one you added). */
|
|
89
370
|
environment: Environment;
|
|
90
371
|
/** API origin (default `https://guidelytech.com`). */
|
|
91
372
|
apiUrl?: string;
|
|
@@ -107,6 +388,13 @@ interface GuidelyOptions {
|
|
|
107
388
|
fetch?: FetchLike;
|
|
108
389
|
/** Flush on the process's `beforeExit` event (default true). Signals and `process.exit()` skip it: call `shutdown()`. */
|
|
109
390
|
handleExit?: boolean;
|
|
391
|
+
/** Your app's version, sent with every `track` (a message's own `appVersion` wins) and as the release of errors. */
|
|
392
|
+
appVersion?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Error monitoring (`captureException`, breadcrumbs, process and framework hooks). `false` turns
|
|
395
|
+
* off the automatic console / HTTP breadcrumbs; manual captures still work.
|
|
396
|
+
*/
|
|
397
|
+
errors?: ErrorOptions | false;
|
|
110
398
|
}
|
|
111
399
|
/**
|
|
112
400
|
* Server-side Guidely client: `identify`, `track` and `group` from your backend.
|
|
@@ -132,6 +420,7 @@ declare class Guidely {
|
|
|
132
420
|
private readonly timeoutMs;
|
|
133
421
|
private readonly onError;
|
|
134
422
|
private readonly fetch;
|
|
423
|
+
private readonly appVersion;
|
|
135
424
|
private readonly sdkJson;
|
|
136
425
|
private queue;
|
|
137
426
|
private droppedSinceReport;
|
|
@@ -146,6 +435,9 @@ declare class Guidely {
|
|
|
146
435
|
private shutdownPromise;
|
|
147
436
|
private exitDrain;
|
|
148
437
|
private readonly exitListener;
|
|
438
|
+
/** Set once `shutdown()` has finished: events still being prepared then are dropped, not sent. */
|
|
439
|
+
private finished;
|
|
440
|
+
private readonly monitor;
|
|
149
441
|
constructor(options: GuidelyOptions);
|
|
150
442
|
/** Who a user is: merges `traits` into the user (creating it if needed), optionally linking an account. */
|
|
151
443
|
identify(message: IdentifyMessage): void;
|
|
@@ -153,14 +445,67 @@ declare class Guidely {
|
|
|
153
445
|
track(message: TrackMessage): void;
|
|
154
446
|
/** Account traits, and optionally adds `userId` to the account. */
|
|
155
447
|
group(message: GroupMessage): void;
|
|
448
|
+
/**
|
|
449
|
+
* Reports an error as an `exception` event (grouped into an issue), with the current scope's tags,
|
|
450
|
+
* extras, contexts, user and breadcrumbs. Returns the event id. Never throws.
|
|
451
|
+
*
|
|
452
|
+
* ```ts
|
|
453
|
+
* guidely.captureException(err, { userId: "u_42", tags: { area: "billing" }, extra: { invoiceId } });
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
captureException(error: unknown, context?: CaptureContext): string;
|
|
457
|
+
/** Reports a message (level `info` unless given), grouped by its text. Returns the event id. */
|
|
458
|
+
captureMessage(message: string, level?: SeverityLevel | CaptureContext, context?: CaptureContext): string;
|
|
459
|
+
/** A tag on every later error of the current scope (`null` removes it). */
|
|
460
|
+
setTag(key: string, value: string | number | boolean | null | undefined): void;
|
|
461
|
+
setTags(tags: Record<string, string | number | boolean | null | undefined>): void;
|
|
462
|
+
setExtra(key: string, value: unknown): void;
|
|
463
|
+
setExtras(extras: Record<string, unknown>): void;
|
|
464
|
+
/** A named context on every later error of the current scope (`null` removes it). */
|
|
465
|
+
setContext(name: string, context: Record<string, unknown> | null): void;
|
|
466
|
+
/** The user later errors of the current scope belong to (`user.id` becomes `userId`); `null` clears it. */
|
|
467
|
+
setUser(user: User | null): void;
|
|
468
|
+
/** Adds a breadcrumb to the current scope (the last 100 ride along with each error). */
|
|
469
|
+
addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void;
|
|
470
|
+
/**
|
|
471
|
+
* Runs `fn` with a copy of the current scope: tags, user and breadcrumbs set inside (and in
|
|
472
|
+
* everything it starts, through AsyncLocalStorage) stay there. Returns what `fn` returns.
|
|
473
|
+
*/
|
|
474
|
+
withScope<T>(fn: (scope: Scope) => T): T;
|
|
475
|
+
/**
|
|
476
|
+
* Reports `uncaughtException` (fatal) and `unhandledRejection`, keeping Node's behaviour: the error
|
|
477
|
+
* is printed, queued events are sent (at most `flushTimeoutMs`) and the process exits with code 1.
|
|
478
|
+
* Returns a function that removes the handlers (`shutdown()` removes them too).
|
|
479
|
+
*/
|
|
480
|
+
installProcessHandlers(options?: ProcessHandlerOptions): () => void;
|
|
481
|
+
/** Express: `app.use(guidely.expressRequestHandler())` first, so each request gets its own scope. */
|
|
482
|
+
expressRequestHandler(): (req: unknown, res: unknown, next: (error?: unknown) => void) => void;
|
|
483
|
+
/** Express: `app.use(guidely.expressErrorHandler())` after your routes, before other error handlers. */
|
|
484
|
+
expressErrorHandler(options?: MiddlewareOptions): (error: unknown, req: unknown, res: unknown, next: (error?: unknown) => void) => void;
|
|
485
|
+
/** Fastify: `await app.register(guidely.fastifyPlugin())` (request scopes + the `onError` hook). */
|
|
486
|
+
fastifyPlugin(options?: MiddlewareOptions): (fastify: FastifyLike, opts: unknown, done?: (error?: Error) => void) => void;
|
|
487
|
+
/** Fastify: `app.addHook("onError", guidely.fastifyErrorHook())`, when you do not use the plugin. */
|
|
488
|
+
fastifyErrorHook(options?: MiddlewareOptions): (request: unknown, reply: unknown, error: unknown, done?: () => void) => void;
|
|
489
|
+
/** Koa: `app.use(guidely.koaMiddleware())` first: a scope per request; errors are reported and rethrown. */
|
|
490
|
+
koaMiddleware(options?: MiddlewareOptions): (ctx: {
|
|
491
|
+
req?: unknown;
|
|
492
|
+
res?: unknown;
|
|
493
|
+
}, next: () => Promise<unknown>) => Promise<unknown>;
|
|
156
494
|
/** Sends everything queued; resolves once it has been delivered or dropped. Never rejects. */
|
|
157
495
|
flush(): Promise<void>;
|
|
158
496
|
/**
|
|
159
|
-
* Stops the timer and the
|
|
160
|
-
* are dropped (and reported). Call it before your process exits.
|
|
497
|
+
* Stops the timer, the exit hook and the error hooks, then flushes, waiting at most
|
|
498
|
+
* `shutdownTimeoutMs`. Later calls are dropped (and reported). Call it before your process exits.
|
|
499
|
+
* Never rejects.
|
|
161
500
|
*/
|
|
162
501
|
shutdown(): Promise<void>;
|
|
163
502
|
private enqueue;
|
|
503
|
+
/**
|
|
504
|
+
* Queues a built `exception` message (it may finish preparing after `shutdown()` began, which
|
|
505
|
+
* still sends it) and starts sending right away: errors should not wait for the flush interval.
|
|
506
|
+
*/
|
|
507
|
+
private enqueueException;
|
|
508
|
+
private push;
|
|
164
509
|
private scheduleTimer;
|
|
165
510
|
private clearTimer;
|
|
166
511
|
/** Starts (or joins) the single sender. `all`: send everything, not only full batches. */
|
|
@@ -178,4 +523,20 @@ declare class Guidely {
|
|
|
178
523
|
private report;
|
|
179
524
|
}
|
|
180
525
|
|
|
181
|
-
|
|
526
|
+
/** A frame as Guidely indexes it (`properties.frames`, innermost first). */
|
|
527
|
+
interface GuidelyFrame {
|
|
528
|
+
fn?: string;
|
|
529
|
+
file?: string;
|
|
530
|
+
line?: number;
|
|
531
|
+
col?: number;
|
|
532
|
+
inApp?: boolean;
|
|
533
|
+
}
|
|
534
|
+
interface FrameOptions {
|
|
535
|
+
/** Directory module names are relative to (Sentry's `getModuleFromFilename` base). */
|
|
536
|
+
root?: string;
|
|
537
|
+
inAppExclude?: Array<string | RegExp>;
|
|
538
|
+
}
|
|
539
|
+
/** Parses a V8 `Error.stack` into Sentry frames, **oldest call first** (the throwing frame last). */
|
|
540
|
+
declare function parseStack(stack: unknown, o?: FrameOptions): StackFrame[];
|
|
541
|
+
|
|
542
|
+
export { type Breadcrumb, type BreadcrumbHint, type CaptureContext, type ConsoleLevel, DEFAULT_API_URL, type Environment, type ErrorEvent, type ErrorOptions, type EventHint, type ExceptionValue, type FastifyLike, type FetchLike, type GroupMessage, Guidely, GuidelyError, type GuidelyErrorCode, type GuidelyFrame, type GuidelyOptions, type IdentifyMessage, type JsonValue, type Mechanism, type MessageType, type MiddlewareOptions, type ProcessHandlerOptions, type ProcessLike, type Properties, type RequestData, SDK_NAME, SDK_VERSION, Scope, type SeverityLevel, type StackFrame, type Timestamp, type TrackMessage, type UnhandledRejectionMode, type User, parseStack };
|