Skip to content

feat(vue): Add Pinia plugin #13841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 15, 2024
Prev Previous commit
Next Next commit
Provide an option for adding breadcrumbs
  • Loading branch information
onurtemizkan committed Oct 4, 2024
commit ea7ba2254fe829d180a43b61be6329d54ad00aa1
9 changes: 7 additions & 2 deletions packages/vue/src/pinia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type PiniaPlugin = (context: {

type SentryPiniaPluginOptions = {
attachPiniaState?: boolean;
addBreadcrumbs?: boolean;
actionTransformer?: (action: any) => any;
stateTransformer?: (state: any) => any;
};
Expand Down Expand Up @@ -48,10 +49,14 @@ export const createSentryPiniaPlugin: (options?: SentryPiniaPluginOptions) => Pi
store.$onAction(context => {
context.after(() => {
const transformedActionName = options.actionTransformer
? options.actionTransformer(context.name) || ''
? options.actionTransformer(context.name)
: context.name;

if (typeof transformedActionName !== 'undefined' && transformedActionName !== null) {
if (
typeof transformedActionName !== 'undefined' &&
transformedActionName !== null &&
options.addBreadcrumbs !== false
) {
addBreadcrumb({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an option to turn off creating breadcrumbs. From experience, some apps have a lot of state updates and breadcrumbs might be very spammy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated: ea7ba22

category: 'action',
message: transformedActionName,
Expand Down
Loading