Skip to content

Commit ea6b8ed

Browse files
onurtemizkancoolguyzones1gr1d
authored
feat(vue): Add Pinia Plugin Docs (#11516)
* feat(vue): Add Pinia Integration Docs * Update docs/platforms/javascript/guides/vue/features/pinia.mdx Co-authored-by: Alex Krawiec <alexanderkrawiec@gmail.com> * Update pinia.mdx Co-authored-by: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com> --------- Co-authored-by: Alex Krawiec <alexanderkrawiec@gmail.com> Co-authored-by: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com>
1 parent 500a1f3 commit ea6b8ed

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: Pinia
3+
description: "Learn about Sentry's Pinia plugin."
4+
---
5+
6+
To capture Pinia state data, use `Sentry.createSentryPiniaPlugin()` and add it to your Pinia store instance:
7+
8+
```javascript
9+
import { createPinia } from 'pinia';
10+
import { createSentryPiniaPlugin } from '@sentry/vue';
11+
12+
const pinia = createPinia();
13+
14+
pinia.use(createSentryPiniaPlugin());
15+
```
16+
17+
## Normalization Depth
18+
19+
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:
20+
21+
```javascript
22+
Sentry.init({
23+
dsn: "___PUBLIC_DSN___",
24+
normalizeDepth: 10, // Or however deep you want your state context to be.
25+
});
26+
```
27+
28+
## Options
29+
30+
To configure the Pinia plugin, pass an options object as the first parameter to `createSentryPiniaPlugin`.
31+
32+
<Alert level="warning" title="Note">
33+
34+
While we try our best to filter out Personally Identifiable Information (PII) such as user passwords, we advise against sending sensitive information to Sentry.
35+
36+
</Alert>
37+
38+
39+
### `attachPiniaState` (Boolean)
40+
41+
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`.
42+
43+
```javascript
44+
createSentryPiniaPlugin({
45+
attachPiniaState: false,
46+
});
47+
```
48+
49+
### `addBreadcrumbs` (Boolean)
50+
51+
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`.
52+
53+
```javascript
54+
createSentryPiniaPlugin({
55+
addBreadcrumbs: false,
56+
});
57+
```
58+
59+
### `actionTransformer` (Function)
60+
61+
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`.
62+
63+
```javascript
64+
createSentryPiniaPlugin({
65+
actionTransformer: (action) => {
66+
if (action === "GOVERNMENT_SECRETS") {
67+
// Return null to not log the action to Sentry
68+
return null;
69+
}
70+
71+
return action;
72+
},
73+
});
74+
```
75+
76+
### `stateTransformer` (Function)
77+
78+
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.
79+
80+
```javascript
81+
createSentryPiniaPlugin({
82+
stateTransformer: (state) => {
83+
if (state.topSecret.doNotSend) {
84+
// Return null to not send this version of the state.
85+
return null;
86+
}
87+
88+
// Transform the state to remove sensitive information
89+
const transformedState = {
90+
...state,
91+
topSecret: {
92+
...state.topSecret,
93+
// Replace sensitive information with something else
94+
nuclearLaunchCodes: "I love pizza",
95+
// or just remove it entirely
96+
hiddenTreasureLocation: null,
97+
},
98+
// You should also remove large data that is irrelevant to debugging to not clutter your Sentry issues
99+
giganticState: null,
100+
};
101+
102+
return transformedState;
103+
},
104+
});
105+
```

platform-includes/getting-started-config/javascript.vue.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,7 @@ The SDK accepts a few Vue-specific `Sentry.init` configuration options:
100100

101101
If the Vue application is not defined from the start, you can add error monitoring for Vue-specific errors later on.
102102
To manually add the integration for late-defined Vue applications check out the docs for the <PlatformLink to="/configuration/integrations/vue/">Vue Integration</PlatformLink>.
103+
104+
### Pinia Plugin
105+
106+
Sentry Vue SDK provides a Pinia plugin to capture Pinia action and state data. Learn more about the [Pinia Plugin](./features/pinia) and its options.

0 commit comments

Comments
 (0)