Skip to content

Redux state doesn't update with createReduxEnhancer #22778

Closed
@Eugene-Musika

Description

@Eugene-Musika

Important Details

How are you running Sentry?
On-Premise
"@sentry/react": "5.29.0",
"@sentry/tracing": "5.29.0",
"@sentry/webpack-plugin": "1.14.0",
"@reduxjs/toolkit": "^1.4.0",

Description

Sentry writes only initial redux state and does not updates on state change.
As result I have only initial redux state in bug report and not latest
image

My Sentry config:

sentry.ts

export function createSentryEnhancer (): StoreEnhancer<Record<string, unknown>, RootState> {
	return Sentry.createReduxEnhancer({
		configureScopeWithState (scope, state: RootState) {
			const { app: { user } } = state;

			if (user) {
				const debugUserData = omit(user, [
					'bigPhoto',
					'userID',
				]);

				scope.setUser({
					id: user.userID.toString(),
					username: user.name,
					...debugUserData,
				});
			}
		},
	});
}

configureStore.ts with redux-toolkit for store configuring

import { configureStore, getDefaultMiddleware, isPlain } from '@reduxjs/toolkit';

const enhancers = [
	createInjectorsEnhancer({
		createReducer,
		runSaga,
	}),
	createSentryEnhancer(),
];

const store = configureStore({
	reducer: createReducer(),
	middleware: [...getDefaultMiddleware({
		serializableCheck:  {
			isSerializable: value => isPlain(value) || value instanceof Map,
		},
	}), ...middlewares],
	devTools: process.env.REACT_APP_DEV_TOOLS && {
		shouldHotReload: false,
		trace: true,
		latency: 0,
		maxAge: 200,
	},
	preloadedState,
	enhancers,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions