-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathintegration.ts
More file actions
110 lines (95 loc) · 3.81 KB
/
Copy pathintegration.ts
File metadata and controls
110 lines (95 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import type { Client } from './client';
import type { Event, EventHint } from './event';
import type { EventProcessor } from './eventprocessor';
import type { Hub } from './hub';
/** Integration Class Interface */
export interface IntegrationClass<T> {
/**
* Property that holds the integration name
*/
id: string;
new (...args: any[]): T;
}
/** Integration interface.
* This is more or less the same as `Integration`, but with a slimmer `setupOnce` siganture. */
export interface IntegrationFnResult {
/**
* The name of the integration.
*/
name: string;
/**
* This hook is only called once, even if multiple clients are created.
* It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
*
* NOTE: In v8, this will become optional.
*/
setupOnce(): void;
/**
* Set up an integration for the given client.
* Receives the client as argument.
*
* Whenever possible, prefer this over `setupOnce`, as that is only run for the first client,
* whereas `setup` runs for each client. Only truly global things (e.g. registering global handlers)
* should be done in `setupOnce`.
*/
setup?(client: Client): void;
/**
* This hook is triggered after `setupOnce()` and `setup()` have been called for all integrations.
* You can use it if it is important that all other integrations have been run before.
*/
afterAllSetup?(client: Client): void;
/**
* An optional hook that allows to preprocess an event _before_ it is passed to all other event processors.
*/
preprocessEvent?(event: Event, hint: EventHint | undefined, client: Client): void;
/**
* An optional hook that allows to process an event.
* Return `null` to drop the event, or mutate the event & return it.
* This receives the client that the integration was installed for as third argument.
*/
processEvent?(event: Event, hint: EventHint, client: Client): Event | null | PromiseLike<Event | null>;
}
/**
* An integration in function form.
* This is expected to return an integration.
*/
export type IntegrationFn = (...rest: any[]) => IntegrationFnResult;
/** Integration interface */
export interface Integration {
/**
* The name of the integration.
*/
name: string;
/**
* This hook is only called once, even if multiple clients are created.
* It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
*
* NOTE: In v8, this will become optional, and not receive any arguments anymore.
*/
// eslint-disable-next-line deprecation/deprecation
setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
/**
* Set up an integration for the given client.
* Receives the client as argument.
*
* Whenever possible, prefer this over `setupOnce`, as that is only run for the first client,
* whereas `setup` runs for each client. Only truly global things (e.g. registering global handlers)
* should be done in `setupOnce`.
*/
setup?(client: Client): void;
/**
* This hook is triggered after `setupOnce()` and `setup()` have been called for all integrations.
* You can use it if it is important that all other integrations have been run before.
*/
afterAllSetup?(client: Client): void;
/**
* An optional hook that allows to preprocess an event _before_ it is passed to all other event processors.
*/
preprocessEvent?(event: Event, hint: EventHint | undefined, client: Client): void;
/**
* An optional hook that allows to process an event.
* Return `null` to drop the event, or mutate the event & return it.
* This receives the client that the integration was installed for as third argument.
*/
processEvent?(event: Event, hint: EventHint, client: Client): Event | null | PromiseLike<Event | null>;
}