File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
2626 } ,
2727) => {
2828 const plugin : PiniaPlugin = ( { store } ) => {
29+ let transformedState = store . $state ;
30+ try {
31+ transformedState = options . stateTransformer ? options . stateTransformer ( store . $state ) : store . $state ;
32+ } catch ( _ ) {
33+ // If stateTransformer throws, let's just use the unmodified state
34+ }
2935 options . attachPiniaState !== false &&
3036 getGlobalScope ( ) . addEventProcessor ( ( event , hint ) => {
3137 try {
@@ -37,7 +43,7 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
3743 ...( hint . attachments || [ ] ) ,
3844 {
3945 filename,
40- data : JSON . stringify ( store . $state ) ,
46+ data : JSON . stringify ( transformedState ) ,
4147 } ,
4248 ] ;
4349 } catch ( _ ) {
@@ -66,7 +72,6 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
6672 }
6773
6874 /* Set latest state to scope */
69- const transformedState = options . stateTransformer ? options . stateTransformer ( store . $state ) : store . $state ;
7075 const scope = getCurrentScope ( ) ;
7176 const currentState = scope . getScopeData ( ) . contexts . state ;
7277
You can’t perform that action at this time.
0 commit comments