Skip to content

Apply stateTransformer to Attachments in createSentryPiniaPlugin #14441

Open

Description

Problem Statement

Feature Request: Apply stateTransformer to Attachments in createSentryPiniaPlugin

First, thank you for createSentryPiniaPlugin—it's been a lifesaver!

Would it be possible to apply the stateTransformer not just to the context but also to the attachments? This would greatly reduce the size of the attachments when they contain items that don’t need to be in Sentry. Currently, we're hitting our monthly attachment cap just a few days after starting to use createSentryPiniaPlugin.

Solution Brainstorm

Potential Implementation:

try {
+ const transformedState = options.stateTransformer 
+   ? options.stateTransformer(store.$state) 
+   : store.$state;
  // Get current timestamp in hh:mm:ss
  const timestamp = new Date().toTimeString().split(' ')[0];
  const filename = `pinia_state_${store.$id}_${timestamp}.json`;

  hint.attachments = [
    ...(hint.attachments || []),
    {
      filename,
-     data: JSON.stringify(store.$state),
+     data: JSON.stringify(transformedState),
    },
  ];
} catch (_) {
  // empty
}

This adjustment would make the plugin more efficient by ensuring attachment size is minimized by excluding unnecessary data from the state with stateTransformer.

Let me know if you’d like me to submit a PR for this change.

Thanks again!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Package: vueIssues related to the Sentry Vue SDK

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions