Problem Statement
When using the current Redux middleware, the latest state is set in the scope's context:
|
/* Set latest state to scope */ |
|
const transformedState = options.stateTransformer(newState); |
|
if (typeof transformedState !== 'undefined' && transformedState !== null) { |
|
scope.setContext('state', { state: { type: 'redux', value: transformedState } }); |
|
} else { |
|
scope.setContext('state', null); |
|
} |
This is a problem for big Redux states as the size of attributes in context is limited. But attachments are now added to the JS SDK, and are the perfect solution to this!
Solution Brainstorm
Instead of storing the state in the context, it should be an attachment as those can be much bigger. I have been using this in my app for some time and it work great:
Sentry.addGlobalEventProcessor((event, hint) => {
hint.attachments = [
{
filename: "redux-state.json",
data: JSON.stringify(store.getState(), undefined, 2),
},
]
return event
})
If you think this is a good idea, I can submit a PR for this. This could also be a middleware setting if you prefer, as well as the attachment name.
Problem Statement
When using the current Redux middleware, the latest state is set in the scope's context:
sentry-javascript/packages/react/src/redux.ts
Lines 105 to 111 in 99864fa
This is a problem for big Redux states as the size of attributes in context is limited. But attachments are now added to the JS SDK, and are the perfect solution to this!
Solution Brainstorm
Instead of storing the state in the context, it should be an attachment as those can be much bigger. I have been using this in my app for some time and it work great:
If you think this is a good idea, I can submit a PR for this. This could also be a middleware setting if you prefer, as well as the attachment name.