Skip to content

Commit d413dad

Browse files
committed
feat(react): Add Event Processor for React
Use an event processor to correctly set SDK and package name
1 parent e13fc0c commit d413dad

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/react/src/index.ts

+23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1+
import { addGlobalEventProcessor, SDK_VERSION } from '@sentry/browser';
2+
3+
function createReactEventProcessor(): void {
4+
addGlobalEventProcessor(event => {
5+
event.sdk = {
6+
...event.sdk,
7+
name: 'sentry.javascript.react',
8+
packages: [
9+
...((event.sdk && event.sdk.packages) || []),
10+
{
11+
name: 'npm:@sentry/react',
12+
version: SDK_VERSION,
13+
},
14+
],
15+
version: SDK_VERSION,
16+
};
17+
18+
return event;
19+
});
20+
}
21+
122
export * from '@sentry/browser';
223

324
export { Profiler, withProfiler, useProfiler } from './profiler';
425
export { ErrorBoundary, withErrorBoundary } from './errorboundary';
26+
27+
createReactEventProcessor();

0 commit comments

Comments
 (0)