Skip to content

Commit cd409dc

Browse files
committed
Don't nuke the entire context.state.
1 parent ea7ba22 commit cd409dc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/vue/src/pinia.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
7272
const client = getClient();
7373
const options = client && client.getOptions();
7474
const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3
75-
7675
const newStateContext = { state: { type: 'pinia', value: transformedState } };
7776

7877
addNonEnumerableProperty(
@@ -82,9 +81,15 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
8281
normalizationDepth, // rest for the actual state
8382
);
8483

85-
scope.setContext('state', newStateContext);
84+
scope.setContext('state', {
85+
...scope.getScopeData().contexts.state,
86+
newStateContext,
87+
});
8688
} else {
87-
scope.setContext('state', null);
89+
scope.setContext('state', {
90+
...scope.getScopeData().contexts.state,
91+
state: { type: 'pinia', value: 'undefined' },
92+
});
8893
}
8994
});
9095
});

0 commit comments

Comments
 (0)