Skip to content

Commit 683ab67

Browse files
s1gr1dlizokmLms24
authored
docs(nuxt): Add missing code snippets (#11501)
* docs(nuxt): Add missing code snippets * Update platform-includes/user-feedback/example-widget/javascript.nuxt.mdx Co-authored-by: Liza Mock <[email protected]> * Apply suggestions from code review Co-authored-by: Lukas Stracke <[email protected]> --------- Co-authored-by: Liza Mock <[email protected]> Co-authored-by: Lukas Stracke <[email protected]>
1 parent 60950b4 commit 683ab67

File tree

12 files changed

+199
-2
lines changed

12 files changed

+199
-2
lines changed

docs/platforms/javascript/common/crons/index.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ supported:
1919
- javascript.hapi
2020
- javascript.koa
2121
- javascript.nestjs
22-
- javascript.nuxt
2322
- javascript.cloudflare
2423
---
2524

docs/platforms/javascript/common/crons/troubleshooting.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ supported:
1919
- javascript.hapi
2020
- javascript.koa
2121
- javascript.nestjs
22-
- javascript.nuxt
2322
- javascript.cloudflare
2423
---
2524

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
In Next.js you can configure document response headers via the `headers` option in `next.config.js`:
2+
3+
```javascript {tabTitle:ESM} {filename:nuxt.config.ts}
4+
export default defineNuxtConfig({
5+
routeRules: {
6+
'/**': {
7+
headers: { 'Document-Policy': 'js-profiling' }
8+
}
9+
}
10+
});
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```bash {tabTitle:npm}
2+
npm install @sentry/nuxt --save
3+
```
4+
5+
```bash {tabTitle:yarn}
6+
yarn add @sentry/nuxt
7+
```
8+
9+
```bash {tabTitle:pnpm}
10+
pnpm add @sentry/nuxt
11+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
```javascript {filename:sentry.client.config.js|ts}
2+
import * as Sentry from "@sentry/nuxt";
3+
4+
Sentry.init({
5+
dsn: "___PUBLIC_DSN___",
6+
integrations: [
7+
// Add browser profiling integration to the list of integrations
8+
Sentry.browserProfilingIntegration(),
9+
],
10+
11+
// Set tracesSampleRate to 1.0 to capture 100%
12+
// of transactions for tracing.
13+
// We recommend adjusting this value in production
14+
tracesSampleRate: 1.0,
15+
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
16+
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
17+
18+
// Set profilesSampleRate to 1.0 to profile every transaction.
19+
// Since profilesSampleRate is relative to tracesSampleRate,
20+
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
21+
// For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would
22+
// result in 25% of transactions being profiled (0.5*0.5=0.25)
23+
profilesSampleRate: 1.0,
24+
});
25+
```
26+
27+
Alternatively, instead of a `profilesSampleRate` your can also provide a `profilesSampler` function:
28+
29+
```javascript {filename:sentry.client.config.js|ts}
30+
const Sentry = require("@sentry/nuxt");
31+
32+
Sentry.init({
33+
dsn: "___PUBLIC_DSN___",
34+
integrations: [
35+
// Add browser profiling integration to the list of integrations
36+
Sentry.browserTracingIntegration(),
37+
Sentry.browserProfilingIntegration(),
38+
],
39+
tracesSampleRate: 1.0,
40+
41+
// This function will be called for every sampled span
42+
// to determine if it should be profiled
43+
profilesSampler: (samplingContext) => {
44+
return 1.0;
45+
},
46+
});
47+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The Replay integration is **already included** with the `@sentry/nuxt` SDK package.
2+
3+
Check the setup guide on how to <PlatformLink to="/">install and configure the Sentry Nuxt SDK</PlatformLink>.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```javascript {13} {filename:sentry.client.config.ts}
2+
import * as Sentry from "@sentry/nuxt";
3+
4+
Sentry.init({
5+
dsn: "___PUBLIC_DSN___",
6+
replaysSessionSampleRate: 0.1,
7+
replaysOnErrorSampleRate: 1.0,
8+
9+
integrations: [
10+
// Keep the Replay integration as before
11+
Sentry.replayIntegration(),
12+
13+
// The following is all you need to enable canvas recording with Replay
14+
Sentry.replayCanvasIntegration(),
15+
],
16+
});
17+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
On your client-side Nuxt app, add:
2+
3+
```javascript {tabTitle:TypeScript} {8,12,14-20} {filename:sentry.client.config.ts}
4+
import * as Sentry from "@sentry/nuxt";
5+
6+
Sentry.init({
7+
dsn: "___PUBLIC_DSN___",
8+
9+
// This sets the sample rate to be 10%. You may want this to be 100% while
10+
// in development and sample at a lower rate in production
11+
replaysSessionSampleRate: 0.1,
12+
13+
// If the entire session is not sampled, use the below sample rate to sample
14+
// sessions when an error occurs.
15+
replaysOnErrorSampleRate: 1.0,
16+
17+
integrations: [
18+
Sentry.replayIntegration({
19+
// Additional SDK configuration goes in here, for example:
20+
maskAllText: true,
21+
blockAllMedia: true,
22+
}),
23+
],
24+
});
25+
```
26+
27+
### Verify
28+
29+
While you're testing, we recommend that you set `replaysSessionSampleRate` to `1.0`. This ensures that every user session will be sent to Sentry.
30+
31+
Once testing is complete, **we recommend lowering this value in production**. We still recommend keeping `replaysOnErrorSampleRate` set to `1.0`, so that, whenever possible, every error has an associated replay with additional debugging context.
32+
33+
34+
### PII & Privacy Considerations
35+
36+
Personally identifiable information (PII) and privacy are important considerations when enabling Session Replay. There are multiple ways in which Sentry helps you avoid collecting PII, including:
37+
- [Masking](/platforms/javascript/session-replay/privacy/#masking), which replaces the text content with something else -- the default behavior being to replace each character with a *.
38+
- Making [network request, response bodies, and headers](/platforms/javascript/session-replay/privacy/#network-request-and-response-bodies-and-headers) an opt-in feature, because the best way to avoid getting PII into Sentry is by not adding URLs of endpoints that may contain PII.
39+
40+
While we have certain privacy considerations in place, Sentry's Session Replay allows you to set up the [privacy configurations](/platforms/javascript/session-replay/privacy/#privacy-configuration) that work best for your use case. For example, if you're working on a static website that's free of PII or other types of private data, you can opt out of the default text masking and image blocking settings.
41+
To learn more about Session Replay privacy, [read our docs.](/platforms/javascript/session-replay/privacy/)
42+
43+
### Lazy-loading Replay
44+
45+
Once you've added the integration, Replay will start automatically. If you don't want to start it immediately (lazy-load it), you can use `addIntegration`:
46+
47+
<PlatformContent includePath="configuration/integrations/lazy-loading-replay" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
In Nuxt, the best place to collect user feedback on the **client side** is inside a plugin:
2+
3+
```javascript {tabTitle:TypeScript} {filename:plugins/report-errors.ts}
4+
export default defineNuxtPlugin((nuxtApp) => {
5+
nuxtApp.hook('vue:error', (error, instance, info) => {
6+
Sentry.showReportDialog({ /* optional options */});
7+
})
8+
})
9+
```
10+
11+
To collect user feedback for errors on the **server side**, you can create an error page by following the [error handling](https://nuxt.com/docs/getting-started/error-handling#nitro-server-errors) instructions in the Nuxt docs.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The User Feedback integration is **already included** in the Nuxt SDK package.
2+
3+
Check the setup guide on how to <PlatformLink to="/">install and configure the Sentry Nuxt SDK</PlatformLink>.

0 commit comments

Comments
 (0)