Skip to content

Commit

Permalink
Provide an option for adding breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Oct 4, 2024
1 parent c7cfa72 commit ea7ba22
Showing 1 changed file with 7 additions and 2 deletions.
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({
category: 'action',
message: transformedActionName,
Expand Down

0 comments on commit ea7ba22

Please sign in to comment.