diff --git a/packages/react/src/redux.ts b/packages/react/src/redux.ts index eb67a0a05a7f..92684808f758 100644 --- a/packages/react/src/redux.ts +++ b/packages/react/src/redux.ts @@ -68,7 +68,6 @@ export interface SentryEnhancerOptions { const ACTION_BREADCRUMB_CATEGORY = 'redux.action'; const ACTION_BREADCRUMB_TYPE = 'info'; -const STATE_CONTEXT_KEY = 'redux.state'; const defaultOptions: SentryEnhancerOptions = { actionTransformer: action => action, @@ -106,9 +105,9 @@ function createReduxEnhancer(enhancerOptions?: Partial): /* Set latest state to scope */ const transformedState = options.stateTransformer(newState); if (typeof transformedState !== 'undefined' && transformedState !== null) { - scope.setContext(STATE_CONTEXT_KEY, transformedState); + scope.setContext('state', { type: 'redux', value: transformedState }); } else { - scope.setContext(STATE_CONTEXT_KEY, null); + scope.setContext('state', null); } /* Allow user to configure scope with latest state */ diff --git a/packages/react/test/redux.test.ts b/packages/react/test/redux.test.ts index 9c75bc944d91..958aff094ab1 100644 --- a/packages/react/test/redux.test.ts +++ b/packages/react/test/redux.test.ts @@ -63,8 +63,11 @@ describe('createReduxEnhancer', () => { const updateAction = { type: ACTION_TYPE, newValue: 'updated' }; store.dispatch(updateAction); - expect(mockSetContext).toBeCalledWith('redux.state', { - value: 'updated', + expect(mockSetContext).toBeCalledWith('state', { + type: 'redux', + value: { + value: 'updated', + }, }); }); @@ -84,9 +87,12 @@ describe('createReduxEnhancer', () => { Redux.createStore((state = initialState) => state, enhancer); - expect(mockSetContext).toBeCalledWith('redux.state', { - superSecret: 'REDACTED', - value: 123, + expect(mockSetContext).toBeCalledWith('state', { + type: 'redux', + value: { + superSecret: 'REDACTED', + value: 123, + }, }); }); @@ -103,7 +109,7 @@ describe('createReduxEnhancer', () => { Redux.createStore((state = initialState) => state, enhancer); // Check that state is cleared - expect(mockSetContext).toBeCalledWith('redux.state', null); + expect(mockSetContext).toBeCalledWith('state', null); }); it('transforms actions', () => {