-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(vue): Add Pinia Plugin Docs #11516
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
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
docs/platforms/javascript/guides/vue/features/pinia.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
title: Pinia | ||
description: "Learn about Sentry's Pinia plugin." | ||
--- | ||
|
||
To capture Pinia state data, use `Sentry.createSentryPiniaPlugin` and add it to your Pinia store instance. | ||
|
||
```javascript | ||
import { createPinia } from 'pinia'; | ||
import { createSentryPiniaPlugin } from '@sentry/vue'; | ||
|
||
const pinia = createPinia(); | ||
|
||
pinia.use(createSentryPiniaPlugin()); | ||
``` | ||
|
||
## 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: | ||
|
||
```javascript | ||
Sentry.init({ | ||
dsn: "___PUBLIC_DSN___", | ||
normalizeDepth: 10, // Or however deep you want your state context to be. | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
To configure the Pinia plugin, pass an options object as the first parameter to `createSentryPiniaPlugin`. | ||
|
||
<Alert level="warning" title="Note"> | ||
|
||
While we try our best to filter out Personally Identifiable Information such as user passwords, we advise against sending sensitive information to Sentry. | ||
onurtemizkan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
</Alert> | ||
|
||
|
||
### `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`. | ||
|
||
```javascript | ||
createSentryPiniaPlugin({ | ||
attachPiniaState: false, | ||
}); | ||
``` | ||
|
||
### `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`. | ||
|
||
```javascript | ||
createSentryPiniaPlugin({ | ||
addBreadcrumbs: false, | ||
}); | ||
``` | ||
|
||
### `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`. | ||
|
||
```javascript | ||
createSentryPiniaPlugin({ | ||
actionTransformer: (action) => { | ||
if (action === "GOVERNMENT_SECRETS") { | ||
// Return null to not log the action to Sentry | ||
return null; | ||
} | ||
|
||
return action; | ||
}, | ||
}); | ||
``` | ||
|
||
### `stateTransformer` (Function) | ||
|
||
This is used to remove sensitive information from 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. | ||
|
||
```javascript | ||
createSentryPiniaPlugin({ | ||
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; | ||
}, | ||
}); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.