Skip to content

Commit c9de1b6

Browse files
committed
Attach store id and timestamp to attachment name.
1 parent 1fa274a commit c9de1b6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/vue/src/pinia.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { addNonEnumerableProperty } from '@sentry/utils';
44
// Inline PiniaPlugin type
55
type PiniaPlugin = (context: {
66
store: {
7+
$id: string;
78
$state: unknown;
89
$onAction: (callback: (context: { name: string; after: (callback: () => void) => void }) => void) => void;
910
};
@@ -26,10 +27,14 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
2627
options.attachPiniaState &&
2728
getGlobalScope().addEventProcessor((event, hint) => {
2829
try {
30+
// Get current timestamp in hh:mm:ss
31+
const timestamp = new Date().toTimeString().split(' ')[0];
32+
const filename = `pinia_state_${store.$id}_${timestamp}.json`;
33+
2934
hint.attachments = [
3035
...(hint.attachments || []),
3136
{
32-
filename: 'pinia_state.json',
37+
filename,
3338
data: JSON.stringify(store.$state),
3439
},
3540
];

0 commit comments

Comments
 (0)