Skip to content

Commit 852bacb

Browse files
inventarSarahcoolguyzonechargome
authored
docs(js): Create Vue Quick Start guide (#14162)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR This PR contains the updated Vue Quick Start guide. I added code snippets for Pluvia and late-defined Vue apps. We could put them in Expandables if it makes sense to you, but I don't think this is necessary since these sections are relatively short anyway. Closes: #14160 ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) --------- Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> Co-authored-by: Charly Gomez <charly.gomez@sentry.io>
1 parent 7030caa commit 852bacb

File tree

2 files changed

+131
-30
lines changed
  • docs/platforms/javascript

2 files changed

+131
-30
lines changed

docs/platforms/javascript/common/configuration/integrations/vue.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ supported:
77

88
<Alert>
99

10-
This integration is enabled by default (recommended) but can also be added manually.
10+
This integration is enabled by default (recommended) but can also be added manually.
1111

1212
</Alert>
1313

@@ -23,18 +23,19 @@ If the Vue application is not defined from the start, you can add error monitori
2323
To manually add the integration for late-defined Vue applications:
2424

2525
```javascript {filename:main.js}
26-
import * as Sentry from '@sentry/vue';
26+
import * as Sentry from "@sentry/vue";
2727

2828
Sentry.init({
29-
dsn: '...',
29+
dsn: "___PUBLIC_DSN___",
3030
// Filter out default `Vue` integration
31-
integrations: integrations => integrations.filter(integration => integration.name !== 'Vue'),
31+
integrations: (integrations) =>
32+
integrations.filter((integration) => integration.name !== "Vue"),
3233
});
3334

3435
// Sometimes later
3536
const app = createApp({
36-
template: '<div>hello</div>',
37+
template: "<div>hello</div>",
3738
});
3839

3940
Sentry.addIntegration(Sentry.vueIntegration({ app }));
40-
`
41+
```

docs/platforms/javascript/guides/vue/index.mdx

Lines changed: 124 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Vue
3+
description: "Learn how to manually set up Sentry in your Vue app and capture your first errors."
34
sdk: sentry.javascript.vue
45
categories:
56
- javascript
@@ -8,17 +9,25 @@ categories:
89

910
<PlatformContent includePath="getting-started-prerequisites" />
1011

11-
## Features
12+
## Step 1: Install
1213

13-
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also get to the root of an error or performance issue faster, by watching a video-like reproduction of a user session with [session replay](/product/explore/session-replay/web/getting-started/).
14+
Choose the features you want to configure, and this guide will show you how:
1415

15-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
16+
<OnboardingOptionButtons
17+
options={[
18+
"error-monitoring",
19+
"performance",
20+
"session-replay",
21+
"user-feedback",
22+
"logs",
23+
]}
24+
/>
1625

17-
## Install
26+
<PlatformContent includePath="getting-started-features-expandable" />
1827

19-
<OnboardingOptionButtons options={["error-monitoring", "performance", "session-replay", "user-feedback", "logs"]} />
28+
### Install the Sentry SDK
2029

21-
Sentry captures data by using an SDK within your application's runtime.
30+
Run the command for your preferred package manager to add the Sentry SDK to your application:
2231

2332
```bash {tabTitle:npm}
2433
npm install @sentry/vue --save
@@ -32,9 +41,7 @@ yarn add @sentry/vue
3241
pnpm add @sentry/vue
3342
```
3443

35-
## Configure
36-
37-
Configuration should happen as early as possible in your application's lifecycle.
44+
## Step 2: Configure
3845

3946
To initialize Sentry in your Vue application, add the following code snippet to your `main.js`:
4047

@@ -53,11 +60,11 @@ const router = createRouter({
5360
Sentry.init({
5461
app,
5562
dsn: "___PUBLIC_DSN___",
56-
63+
5764
// Adds request headers and IP for users, for more info visit:
5865
// https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/#sendDefaultPii
5966
sendDefaultPii: true,
60-
67+
6168
integrations: [
6269
// ___PRODUCT_OPTION_START___ performance
6370
Sentry.browserTracingIntegration({ router }),
@@ -168,24 +175,65 @@ new Vue({
168175
}).$mount("#app");
169176
```
170177

178+
<Alert type="info">
179+
171180
If you're creating more than one Vue 3 app within your application, check out how to initialize the SDK for [multiple apps](./features/multiple-apps).
172181

173-
### Late-Defined Vue Apps
182+
</Alert>
183+
184+
### Configuration for Late-Defined Vue Apps
185+
186+
If your Vue application is not defined from the start, you can add error monitoring for Vue-specific errors later on.
187+
To manually add the integration for late-defined Vue applications, update your `main.js` file:
174188

175-
If the Vue application is not defined from the start, you can add error monitoring for Vue-specific errors later on.
176-
To manually add the integration for late-defined Vue applications check out the docs for the <PlatformLink to="/configuration/integrations/vue/">Vue Integration</PlatformLink>.
189+
```javascript {filename:main.js}
190+
import * as Sentry from "@sentry/vue";
177191

178-
### Pinia Plugin
192+
Sentry.init({
193+
dsn: "...",
194+
// Filter out default `Vue` integration
195+
integrations: (integrations) =>
196+
integrations.filter((integration) => integration.name !== "Vue"),
197+
});
179198

180-
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.
199+
// Sometimes later
200+
const app = createApp({
201+
template: "<div>hello</div>",
202+
});
203+
204+
Sentry.addIntegration(Sentry.vueIntegration({ app }));
205+
```
181206

182-
<PlatformContent includePath="getting-started-sourcemaps" />
207+
### Configuration for Pinia
183208

184-
## Verify
209+
To capture Pinia state data, use `Sentry.createSentryPiniaPlugin()` and add it to your Pinia store instance:
185210

186-
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
211+
```javascript
212+
import { createPinia } from "pinia";
213+
import { createSentryPiniaPlugin } from "@sentry/vue";
187214

188-
Add a button to your page that throws an error:
215+
const pinia = createPinia();
216+
217+
pinia.use(createSentryPiniaPlugin());
218+
```
219+
220+
Learn more about the [Pinia Plugin](./features/pinia) and its options.
221+
222+
## Step 3: Add Readable Stack Traces With Source Maps (Optional)
223+
224+
<PlatformContent includePath="getting-started-sourcemaps-short-version" />
225+
226+
## Step 4: Avoid Ad Blockers With Tunneling (Optional)
227+
228+
<PlatformContent includePath="getting-started-tunneling" />
229+
230+
## Step 5: Verify Your Setup
231+
232+
Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project.
233+
234+
### Issues
235+
236+
To verify that Sentry is capturing errors and creating issues in your Sentry project, add the following test button to one of your pages, which will trigger an error that Sentry will capture when you click it:
189237

190238
```javascript {filename:App.vue}
191239
// ...
@@ -202,10 +250,62 @@ export default {
202250
};
203251
```
204252

205-
<Alert>
253+
<OnboardingOption optionId="performance" hideForThisOption>
254+
Open the page in a browser and click the button to trigger a frontend error.
255+
</OnboardingOption>
206256

207-
Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
257+
<PlatformContent includePath="getting-started-browser-sandbox-warning" />
208258

209-
</Alert>
259+
<OnboardingOption optionId="performance">
260+
### Tracing
261+
262+
To test your tracing configuration, update the previous code snippet to start a performance trace to measure the time it takes for your code to execute:
263+
264+
```javascript {filename:App.vue}
265+
// ...
266+
<button @click="throwError">Throw error</button>
267+
// ...
268+
269+
export default {
270+
// ...
271+
methods: {
272+
throwError() {
273+
Sentry.startSpan({ op: "test", name: "Example Frontend Span" }, async () => {
274+
// Simulate an asynchronous operation
275+
await new Promise(resolve => setTimeout(resolve, 99));
276+
277+
throw new Error("Sentry Error");
278+
});
279+
}
280+
}
281+
};
282+
283+
```
284+
285+
Open the page in a browser and click the button to trigger a frontend error and performance trace.
286+
287+
</OnboardingOption>
288+
289+
### View Captured Data in Sentry
290+
291+
Now, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear).
292+
293+
<PlatformContent includePath="getting-started-verify-locate-data" />
294+
295+
## Next Steps
296+
297+
At this point, you should have integrated Sentry into your Vue application and should already be sending data to your Sentry project.
298+
299+
Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:
300+
301+
- Extend Sentry to your backend using one of our [SDKs](/)
302+
- Continue to <PlatformLink to="/configuration">customize your configuration</PlatformLink>
303+
- Make use of <PlatformLink to="/features">Vue-specific features</PlatformLink>
304+
- Learn how to <PlatformLink to="/usage">manually capture errors</PlatformLink>
305+
306+
<Expandable permalink={false} title="Are you having problems setting up the SDK?">
307+
308+
- Find various topics in <PlatformLink to="/troubleshooting">Troubleshooting</PlatformLink>
309+
- [Get support](https://sentry.zendesk.com/hc/en-us/)
210310

211-
To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
311+
</Expandable>

0 commit comments

Comments
 (0)