-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathintegration.ts
46 lines (34 loc) · 1.23 KB
/
integration.ts
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
import type { Client } from '../../src';
import { getClient, getCurrentScope } from '../../src';
import type { Event, EventProcessor, Integration } from '../../src/types-hoist';
export class TestIntegration implements Integration {
public static id: string = 'TestIntegration';
public name: string = 'TestIntegration';
public setupOnce(): void {
const eventProcessor: EventProcessor = (event: Event) => {
if (!getClient()?.getIntegrationByName('TestIntegration')) {
return event;
}
return null;
};
eventProcessor.id = this.name;
getCurrentScope().addEventProcessor(eventProcessor);
}
}
export class AddAttachmentTestIntegration implements Integration {
public static id: string = 'AddAttachmentTestIntegration';
public name: string = 'AddAttachmentTestIntegration';
public setup(client: Client): void {
client.addEventProcessor((event, hint) => {
hint.attachments = [...(hint.attachments || []), { filename: 'integration.file', data: 'great content!' }];
return event;
});
}
}
export class AdHocIntegration implements Integration {
public static id: string = 'AdHockIntegration';
public name: string = 'AdHockIntegration';
public setupOnce(): void {
// Noop
}
}