Skip to content

Commit 35fa934

Browse files
committed
fix(redux): Improve Redux state attachment handling
Refactors the code responsible for attaching the Redux state to Sentry events. The change enhances efficiency by avoiding the addition of empty JSON attachments when there is no Redux state available.
1 parent 2b3735a commit 35fa934

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/react/src/redux.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>):
9898
<S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {
9999
options.attachReduxState &&
100100
addGlobalEventProcessor((event, hint) => {
101-
hint.attachments = [
102-
...(hint.attachments || []),
103-
{ filename: 'reduxState.json', data: JSON.stringify(event.contexts && event.contexts.state) || ' ' },
104-
];
101+
if (event.contexts && event.contexts.state && event.contexts.state.type === 'redux') {
102+
hint.attachments = [
103+
...(hint.attachments || []),
104+
{ filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.value) },
105+
];
106+
}
105107
return event;
106108
});
107109

0 commit comments

Comments
 (0)