UNPKG

2.06 kBTypeScriptView Raw
1import type { Client } from './client';
2import type { Event, EventHint } from './event';
3/** Integration Class Interface */
4export interface IntegrationClass<T> {
5 /**
6 * Property that holds the integration name
7 */
8 id: string;
9 new (...args: any[]): T;
10}
11/** Integration interface */
12export interface Integration {
13 /**
14 * The name of the integration.
15 */
16 name: string;
17 /**
18 * This hook is only called once, even if multiple clients are created.
19 * It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
20 */
21 setupOnce?(): void;
22 /**
23 * Set up an integration for the given client.
24 * Receives the client as argument.
25 *
26 * Whenever possible, prefer this over `setupOnce`, as that is only run for the first client,
27 * whereas `setup` runs for each client. Only truly global things (e.g. registering global handlers)
28 * should be done in `setupOnce`.
29 */
30 setup?(client: Client): void;
31 /**
32 * This hook is triggered after `setupOnce()` and `setup()` have been called for all integrations.
33 * You can use it if it is important that all other integrations have been run before.
34 */
35 afterAllSetup?(client: Client): void;
36 /**
37 * An optional hook that allows to preprocess an event _before_ it is passed to all other event processors.
38 */
39 preprocessEvent?(event: Event, hint: EventHint | undefined, client: Client): void;
40 /**
41 * An optional hook that allows to process an event.
42 * Return `null` to drop the event, or mutate the event & return it.
43 * This receives the client that the integration was installed for as third argument.
44 */
45 processEvent?(event: Event, hint: EventHint, client: Client): Event | null | PromiseLike<Event | null>;
46}
47/**
48 * An integration in function form.
49 * This is expected to return an integration.
50 */
51export type IntegrationFn<IntegrationType = Integration> = (...rest: any[]) => IntegrationType;
52//# sourceMappingURL=integration.d.ts.map
\No newline at end of file