# Pinia | Sentry for Nuxt

To capture [Pinia](https://pinia.vuejs.org/) state data, add the `piniaIntegration` with `usePinia()` to the integrations array of your client-side Sentry configuration:

`sentry.client.config.ts`

```javascript
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",

  integrations: [Sentry.piniaIntegration(usePinia())],

});
```

## [Normalization Depth](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia.md#normalization-depth)

By default, Sentry SDKs normalize any context to a depth of 3. You may want to increase this for sending Pinia states by passing `normalizeDepth` to the `Sentry.init` call:

`sentry.client.config.ts`

```javascript
Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  integrations: [Sentry.piniaIntegration(usePinia())],

  normalizeDepth: 10, // Or however deep you want your state context to be.

});
```

## [Options](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia.md#options)

When not providing a second argument to the `piniaIntegration`, all default options are automatically applied. To configure the Pinia plugin manually, pass an options object as a second argument to `piniaIntegration`.

##### Note

While we try our best to filter out Personally Identifiable Information (PII) such as user passwords, we advise against sending sensitive information to Sentry.

### [`attachPiniaState` (Boolean)](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia.md#attachpiniastate-boolean)

This is used to attach Pinia state to Sentry events. By default, this is set to `true`. If you don't want to attach Pinia state to events being sent to Sentry, set this to `false`:

`sentry.client.config.ts`

```javascript
Sentry.piniaIntegration(usePinia(), {

  attachPiniaState: false,

});
```

### [`addBreadcrumbs` (Boolean)](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia.md#addbreadcrumbs-boolean)

This is used to add breadcrumbs to Sentry events. By default, this is set to `true`. If you don't want to add breadcrumbs to events being sent to Sentry, set this to `false`:

`sentry.client.config.ts`

```javascript
Sentry.piniaIntegration(usePinia(), {

  addBreadcrumbs: false,

});
```

### [`actionTransformer` (Function)](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia.md#actiontransformer-function)

This can be used to remove sensitive information from Pinia actions. The first parameter passed to the function is the Pinia action name. We send all actions by default, if you don't want an action name sent to Sentry, use `return null`:

`sentry.client.config.ts`

```javascript
Sentry.piniaIntegration(usePinia(), {

  actionTransformer: (action) => {
    if (action === "GOVERNMENT_SECRETS") {
      // Return null to not log the action to Sentry
      return null;
    }

    return action;
  },

});
```

### [`stateTransformer` (Function)](https://docs.sentry.io/platforms/javascript/guides/nuxt/features/pinia.md#statetransformer-function)

This is used to remove sensitive information from a Pinia state. The first parameter passed to the function is the Pinia state. We attach all state changes by default. If you don't want to attach state changes to events being sent to Sentry, use `return null`. Note, that if you choose not to send state to Sentry, your errors might not have the latest version attached:

`sentry.client.config.ts`

```javascript
Sentry.piniaIntegration(usePinia(), {

  stateTransformer: (state) => {
    if (state.topSecret.doNotSend) {
      // Return null to not send this version of the state.
      return null;
    }

    // Transform the state to remove sensitive information
    const transformedState = {
      ...state,
      topSecret: {
        ...state.topSecret,
        // Replace sensitive information with something else
        nuclearLaunchCodes: "I love pizza",
        // or just remove it entirely
        hiddenTreasureLocation: null,
      },
      // You should also remove large data that is irrelevant to debugging to not clutter your Sentry issues
      giganticState: null,
    };

    return transformedState;
  },

});
```
