Skip to content

Commit

Permalink
Don't nuke the entire context.state.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Oct 4, 2024
1 parent ea7ba22 commit cd409dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/vue/src/pinia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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' },
});
}
});
});
Expand Down

0 comments on commit cd409dc

Please sign in to comment.