diff --git a/packages/vue/src/pinia.ts b/packages/vue/src/pinia.ts index d9106b3463d0..5dc34972e537 100644 --- a/packages/vue/src/pinia.ts +++ b/packages/vue/src/pinia.ts @@ -72,7 +72,6 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi const client = getClient(); const options = client && client.getOptions(); const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3 - const newStateContext = { state: { type: 'pinia', value: transformedState } }; addNonEnumerableProperty( @@ -82,9 +81,15 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi normalizationDepth, // rest for the actual state ); - scope.setContext('state', newStateContext); + scope.setContext('state', { + ...scope.getScopeData().contexts.state, + newStateContext, + }); } else { - scope.setContext('state', null); + scope.setContext('state', { + ...scope.getScopeData().contexts.state, + state: { type: 'pinia', value: 'undefined' }, + }); } }); });