Repository navigation
Expand file tree
/
Copy pathconsole.ts
More file actions
45 lines (39 loc) · 1.35 KB
/
Copy pathconsole.ts
File metadata and controls
45 lines (39 loc) · 1.35 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
import * as util from 'util';
import { addBreadcrumb, convertIntegrationFnToClass, defineIntegration, getClient } from '@sentry/core';
import type { Client, Integration, IntegrationClass, IntegrationFn } from '@sentry/types';
import { addConsoleInstrumentationHandler, severityLevelFromString } from '@sentry/utils';
const INTEGRATION_NAME = 'Console';
const _consoleIntegration = (() => {
return {
name: INTEGRATION_NAME,
setup(client) {
addConsoleInstrumentationHandler(({ args, level }) => {
if (getClient() !== client) {
return;
}
addBreadcrumb(
{
category: 'console',
level: severityLevelFromString(level),
message: util.format.apply(undefined, args),
},
{
input: [...args],
level,
},
);
});
},
};
}) satisfies IntegrationFn;
export const consoleIntegration = defineIntegration(_consoleIntegration);
/**
* Console module integration.
* @deprecated Use `consoleIntegration()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const Console = convertIntegrationFnToClass(INTEGRATION_NAME, consoleIntegration) as IntegrationClass<
Integration & { setup: (client: Client) => void }
>;
// eslint-disable-next-line deprecation/deprecation
export type Console = typeof Console;