@honeybadger-io/js 6.15.2 → 6.16.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.
@@ -19,6 +19,8 @@ export declare class AsyncStore implements Types.HoneybadgerStore {
19
19
  getContents(key?: keyof Types.StoreContents): any;
20
20
  available(): boolean;
21
21
  setContext(context: Record<string, unknown>): void;
22
+ setEventContext(eventContext: Record<string, unknown>): void;
23
+ clearEventContext(): void;
22
24
  addBreadcrumb(breadcrumb: any): void;
23
25
  clear(): void;
24
26
  run<R>(callback: () => R, request?: Record<symbol, unknown>): R;
@@ -0,0 +1,31 @@
1
+ import type { FastifyPluginCallback } from 'fastify';
2
+ import { Client } from '@honeybadger-io/core';
3
+ type ServerClient = Client & {
4
+ withRequest<R>(request: Record<symbol, unknown>, handler: (...args: never[]) => R, onError?: (...args: unknown[]) => unknown): R | void;
5
+ };
6
+ /**
7
+ * Returns a Fastify plugin bound to the given Honeybadger client.
8
+ *
9
+ * Exposed as a factory (rather than a method on the singleton) so the
10
+ * framework-specific code stays off the client API:
11
+ *
12
+ * const { fastifyPlugin } = require('@honeybadger-io/js/dist/server/fastify')
13
+ * fastify.register(fastifyPlugin(Honeybadger))
14
+ *
15
+ * Requires the `fastify-plugin` package (declared as an optional peer
16
+ * dependency of this package) — the factory throws with install instructions
17
+ * when it cannot be resolved. The returned plugin is wrapped with
18
+ * `fastify-plugin`, so its hooks apply to the calling context rather than
19
+ * being encapsulated.
20
+ *
21
+ * The plugin runs every request inside `client.withRequest(req, ...)`, seeding
22
+ * `request_id` / `correlation_id` on the event context. When
23
+ * `insights.enabled` and `insights.http` are both true it also emits a
24
+ * `request.handled` event per request with method, path, route, status and
25
+ * duration.
26
+ *
27
+ * Supports Fastify 4+.
28
+ */
29
+ export declare function fastifyPlugin(client: ServerClient): FastifyPluginCallback;
30
+ export {};
31
+ //# sourceMappingURL=fastify.d.ts.map