/
integration.ts
38 lines (28 loc) · 1.06 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
import { Event, EventProcessor, Integration } from '@sentry/types';
import { configureScope, getCurrentHub } from '../../src';
export class TestIntegration implements Integration {
public static id: string = 'TestIntegration';
public name: string = 'TestIntegration';
public setupOnce(): void {
const eventProcessor: EventProcessor = (event: Event) => {
if (!getCurrentHub().getIntegration(TestIntegration)) {
return event;
}
return null;
};
eventProcessor.id = this.name;
configureScope(scope => {
scope.addEventProcessor(eventProcessor);
});
}
}
export class AddAttachmentTestIntegration implements Integration {
public static id: string = 'AddAttachmentTestIntegration';
public name: string = 'AddAttachmentTestIntegration';
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void {
addGlobalEventProcessor((event, hint) => {
hint.attachments = [...(hint.attachments || []), { filename: 'integration.file', data: 'great content!' }];
return event;
});
}
}