-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
linkederrors.ts
48 lines (40 loc) · 1.55 KB
/
linkederrors.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 type { Client, Event, EventHint, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import { applyAggregateErrorsToEvent, exceptionFromError } from '@sentry/utils';
import { convertIntegrationFnToClass, defineIntegration } from '../integration';
interface LinkedErrorsOptions {
key?: string;
limit?: number;
}
const DEFAULT_KEY = 'cause';
const DEFAULT_LIMIT = 5;
const INTEGRATION_NAME = 'LinkedErrors';
const _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {
const limit = options.limit || DEFAULT_LIMIT;
const key = options.key || DEFAULT_KEY;
return {
name: INTEGRATION_NAME,
// TODO v8: Remove this
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
preprocessEvent(event, hint, client) {
const options = client.getOptions();
applyAggregateErrorsToEvent(
exceptionFromError,
options.stackParser,
options.maxValueLength,
key,
limit,
event,
hint,
);
},
};
}) satisfies IntegrationFn;
export const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);
/**
* Adds SDK info to an event.
* @deprecated Use `linkedErrorsIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const LinkedErrors = convertIntegrationFnToClass(INTEGRATION_NAME, linkedErrorsIntegration) as IntegrationClass<
Integration & { preprocessEvent: (event: Event, hint: EventHint, client: Client) => void }
> & { new (options?: { key?: string; limit?: number }): Integration };