-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathTestClient.ts
48 lines (42 loc) · 1.31 KB
/
TestClient.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
47
48
import { Client, createTransport, initAndBind } from '@sentry/core';
import { resolvedSyncPromise } from '@sentry/core';
import type {
BrowserClientReplayOptions,
ClientOptions,
Event,
ParameterizedString,
SeverityLevel,
} from '@sentry/core';
export interface TestClientOptions extends ClientOptions, BrowserClientReplayOptions {}
export class TestClient extends Client<TestClientOptions> {
public constructor(options: TestClientOptions) {
super(options);
}
public eventFromException(exception: any): PromiseLike<Event> {
return resolvedSyncPromise({
exception: {
values: [
{
type: exception.name,
value: exception.message,
},
],
},
});
}
public eventFromMessage(message: ParameterizedString, level: SeverityLevel = 'info'): PromiseLike<Event> {
return resolvedSyncPromise({ message, level });
}
}
export function init(options: TestClientOptions): void {
initAndBind(TestClient, options);
}
export function getDefaultClientOptions(options: Partial<ClientOptions> = {}): ClientOptions {
return {
integrations: [],
dsn: 'https://username@domain/123',
transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => resolvedSyncPromise({})),
stackParser: () => [],
...options,
};
}