From b2d8bd410dfbdda66f1a3ac7de2de4305bf90e5c Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Sat, 23 Sep 2023 15:05:22 -0500 Subject: [PATCH] replay: onboarding specific per sdk (#7883) Co-authored-by: Shana Matthews --- .../install/javascript.angular.mdx | 24 ++++++++++ .../install/javascript.capacitor.mdx | 16 +++++-- .../install/javascript.electron.mdx | 8 ++++ .../install/javascript.ember.mdx | 3 ++ .../install/javascript.gatsby.mdx | 9 ++++ .../session-replay/install/javascript.mdx | 2 - .../install/javascript.nextjs.mdx | 5 ++ .../install/javascript.react.mdx | 9 ++++ .../install/javascript.remix.mdx | 23 +++++++++ .../install/javascript.svelte.mdx | 9 ++++ .../install/javascript.sveltekit.mdx | 22 +++++++++ .../session-replay/install/javascript.vue.mdx | 9 ++++ .../setup/javascript.angular.mdx | 45 ++++++++++++++++++ .../setup/javascript.electron.mdx | 8 ---- .../session-replay/setup/javascript.ember.mdx | 45 ++++++++++++++++++ .../setup/javascript.gatsby.mdx | 45 ++++++++++++++++++ .../session-replay/setup/javascript.mdx | 4 -- .../setup/javascript.nextjs.mdx | 47 +++++++++++++++++++ .../session-replay/setup/javascript.react.mdx | 45 ++++++++++++++++++ .../session-replay/setup/javascript.remix.mdx | 47 +++++++++++++++++++ .../setup/javascript.svelte.mdx | 45 ++++++++++++++++++ .../setup/javascript.sveltekit.mdx | 47 +++++++++++++++++++ .../session-replay/setup/javascript.vue.mdx | 45 ++++++++++++++++++ .../common/session-replay/index.mdx | 4 ++ 24 files changed, 549 insertions(+), 17 deletions(-) create mode 100644 src/platform-includes/session-replay/install/javascript.angular.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.ember.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.gatsby.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.nextjs.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.react.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.remix.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.svelte.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.sveltekit.mdx create mode 100644 src/platform-includes/session-replay/install/javascript.vue.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.angular.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.ember.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.gatsby.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.nextjs.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.react.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.remix.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.svelte.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.sveltekit.mdx create mode 100644 src/platform-includes/session-replay/setup/javascript.vue.mdx diff --git a/src/platform-includes/session-replay/install/javascript.angular.mdx b/src/platform-includes/session-replay/install/javascript.angular.mdx new file mode 100644 index 0000000000000..96105f56c2a66 --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.angular.mdx @@ -0,0 +1,24 @@ +```bash {tabTitle:npm} +# Angular 12 and newer: +npm install --save @sentry/angular-ivy + +# Angular 10 and 11: +npm install --save @sentry/angular +``` + +```bash {tabTitle:Yarn} +# Angular 12 and newer: +yarn add @sentry/angular-ivy + +# Angular 10 and 11: +yarn add @sentry/angular +``` + +### Angular Version Compatibility + +Because of the way Angular libraries are compiled, you need to use a specific version of the Sentry SDK for each corresponding version of Angular as shown below: + +| Angular version | Recommended Sentry SDK | +| --------------- | ---------------------- | +| 12 and newer | `@sentry/angular-ivy` | +| 10, 11 | `@sentry/angular` | diff --git a/src/platform-includes/session-replay/install/javascript.capacitor.mdx b/src/platform-includes/session-replay/install/javascript.capacitor.mdx index c60906f36a3b9..d26b4cbb83e8f 100644 --- a/src/platform-includes/session-replay/install/javascript.capacitor.mdx +++ b/src/platform-includes/session-replay/install/javascript.capacitor.mdx @@ -1,7 +1,17 @@ -```bash {tabTitle: Yarn} -yarn add @sentry/capacitor @sentry/replay +Install the Sentry Capacitor SDK alongside the corresponding Sentry SDK for the framework you're using, such as Angular in this example: + +```bash {tabTitle:Angular} +# npm +npm install --save @sentry/capacitor @sentry/angular-ivy @sentry/replay + +# yarn +yarn add @sentry/capacitor @sentry/angular-ivy @sentry/replay ``` -```html {tabTitle: npm} +```bash {tabTitle:Other Frameworks} +# npm npm install --save @sentry/capacitor @sentry/replay + +# yarn +yarn add @sentry/capacitor @sentry/replay ``` diff --git a/src/platform-includes/session-replay/install/javascript.electron.mdx b/src/platform-includes/session-replay/install/javascript.electron.mdx index fb25249be9002..8e5bc4d4f6976 100644 --- a/src/platform-includes/session-replay/install/javascript.electron.mdx +++ b/src/platform-includes/session-replay/install/javascript.electron.mdx @@ -1 +1,9 @@ The Replay integration is **already included** with the Electron SDK package. + +```bash {tabTitle: npm} +npm install --save @sentry/electron +``` + +```bash {tabTitle: Yarn} +yarn add @sentry/electron +``` diff --git a/src/platform-includes/session-replay/install/javascript.ember.mdx b/src/platform-includes/session-replay/install/javascript.ember.mdx new file mode 100644 index 0000000000000..89515011d2da4 --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.ember.mdx @@ -0,0 +1,3 @@ +```bash {tabTitle:ember-cli} +ember install @sentry/ember +``` diff --git a/src/platform-includes/session-replay/install/javascript.gatsby.mdx b/src/platform-includes/session-replay/install/javascript.gatsby.mdx new file mode 100644 index 0000000000000..9b3c83704316e --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.gatsby.mdx @@ -0,0 +1,9 @@ +The Replay integration is **already included** with the Gatsby SDK package. + +```bash {tabTitle: npm} +npm install --save @sentry/gatsby +``` + +```bash {tabTitle: Yarn} +yarn add @sentry/gatsby +``` diff --git a/src/platform-includes/session-replay/install/javascript.mdx b/src/platform-includes/session-replay/install/javascript.mdx index 6e34d33b4bedb..726dcaf99bcbb 100644 --- a/src/platform-includes/session-replay/install/javascript.mdx +++ b/src/platform-includes/session-replay/install/javascript.mdx @@ -1,12 +1,10 @@ The Replay integration is **already included** in your browser or framework SDK NPM packages. If you're using CDN bundles instead of NPM packages, you need to load the Replay integration CDN bundle in addition to your browser bundle: ```bash {tabTitle: npm} -# Make sure to have @sentry/browser or a Framework SDK (e.g. @sentry/react) installed npm install --save @sentry/browser ``` ```bash {tabTitle: Yarn} -# Make sure to have @sentry/browser or a Framework SDK (e.g. @sentry/react) installed yarn add @sentry/browser ``` diff --git a/src/platform-includes/session-replay/install/javascript.nextjs.mdx b/src/platform-includes/session-replay/install/javascript.nextjs.mdx new file mode 100644 index 0000000000000..3050f964b7f1a --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.nextjs.mdx @@ -0,0 +1,5 @@ +The Replay integration is already included with the Sentry SDK. We recommend installing the SDK through our installation wizard: + +```bash +npx @sentry/wizard@latest -i nextjs +``` diff --git a/src/platform-includes/session-replay/install/javascript.react.mdx b/src/platform-includes/session-replay/install/javascript.react.mdx new file mode 100644 index 0000000000000..2ef398672b48a --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.react.mdx @@ -0,0 +1,9 @@ +The Replay integration is **already included** with the React SDK package. + +```bash {tabTitle:npm} +npm install --save @sentry/react +``` + +```bash {tabTitle:Yarn} +yarn add @sentry/react +``` diff --git a/src/platform-includes/session-replay/install/javascript.remix.mdx b/src/platform-includes/session-replay/install/javascript.remix.mdx new file mode 100644 index 0000000000000..ef2d6bd611c79 --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.remix.mdx @@ -0,0 +1,23 @@ +The Replay integration is already included with the Sentry SDK. We recommend installing the SDK through our installation wizard: + +```bash +npx @sentry/wizard@latest -i remix +``` + +The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you: + +- create two files in the root directory of your project, `entry.client.tsx` and `entry.server.tsx` (if they don't already exist). +- add the default `Sentry.init()` for the client in `entry.client.tsx` and the server in `entry.server.tsx`. +- create `.sentryclirc` with an auth token to upload source maps (this file is automatically added to `.gitignore`). +- adjust your `build` script in `package.json` to automatically upload source maps to Sentry when you build your application. + +If you use [Remix future flags](https://remix.run/docs/en/main/pages/api-development-strategy#current-future-flags), the wizard will instrument your application accordingly to support Remix v2 features. + +After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance. +You can also manually capture errors. + + + +If the wizard setup isn't working for you, you can set up the SDK manually. + + diff --git a/src/platform-includes/session-replay/install/javascript.svelte.mdx b/src/platform-includes/session-replay/install/javascript.svelte.mdx new file mode 100644 index 0000000000000..4b0645dad7483 --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.svelte.mdx @@ -0,0 +1,9 @@ +The Replay integration is **already included** with the Svelte SDK package. + +```bash {tabTitle:npm} +npm install --save @sentry/svelte +``` + +```bash {tabTitle:Yarn} +yarn add @sentry/svelte +``` diff --git a/src/platform-includes/session-replay/install/javascript.sveltekit.mdx b/src/platform-includes/session-replay/install/javascript.sveltekit.mdx new file mode 100644 index 0000000000000..1c22fa4d2d73e --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.sveltekit.mdx @@ -0,0 +1,22 @@ +The Replay integration is already included with the Sentry SDK. We recommend installing the SDK by running our installation wizard in the root directory of your project: + +```bash +npx @sentry/wizard@latest -i sveltekit +``` + +The wizard will prompt you to log in to Sentry. It will then automatically do the following steps for you: + +- create or update SvelteKit files with the default Sentry configuration: + - `hooks.(client|server).js` to initialize the SDK and instrument [SvelteKit's hooks](https://kit.svelte.dev/docs/hooks) + - `vite.config.js` to add source maps upload and auto-instrumentation via Vite plugins. +- create a `.sentryclirc` file with an auth token to upload source maps (this file is automatically added to `.gitignore`) +- add an example page to your app to verify your Sentry setup + +After the wizard setup is completed, the SDK will automatically capture unhandled errors, and monitor performance. +You can also manually capture errors. + + + +If the setup through the wizard doesn't work for you, you can also set up the SDK manually. + + diff --git a/src/platform-includes/session-replay/install/javascript.vue.mdx b/src/platform-includes/session-replay/install/javascript.vue.mdx new file mode 100644 index 0000000000000..f5ddd3a0d8d18 --- /dev/null +++ b/src/platform-includes/session-replay/install/javascript.vue.mdx @@ -0,0 +1,9 @@ +The Replay integration is **already included** with the Vue SDK package. + +```bash {tabTitle:npm} +npm install --save @sentry/vue +``` + +```bash {tabTitle:Yarn} +yarn add @sentry/vue +``` diff --git a/src/platform-includes/session-replay/setup/javascript.angular.mdx b/src/platform-includes/session-replay/setup/javascript.angular.mdx new file mode 100644 index 0000000000000..6ce5e36e1a1da --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.angular.mdx @@ -0,0 +1,45 @@ +```javascript +import * as Sentry from "@sentry/angular-ivy"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/angular-ivy"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.electron.mdx b/src/platform-includes/session-replay/setup/javascript.electron.mdx index 0dd59719528d8..3263afa69fe5d 100644 --- a/src/platform-includes/session-replay/setup/javascript.electron.mdx +++ b/src/platform-includes/session-replay/setup/javascript.electron.mdx @@ -1,11 +1,3 @@ -To set up the integration, add the following to your Sentry initialization in -Electron renderers. Several options are supported and passable using the integration -constructor. See the [configuration -documentation](/platforms/javascript/session-replay/configuration/) for more -details. - - - ```javascript import * as Sentry from "@sentry/electron/renderer"; diff --git a/src/platform-includes/session-replay/setup/javascript.ember.mdx b/src/platform-includes/session-replay/setup/javascript.ember.mdx new file mode 100644 index 0000000000000..2b406944686dc --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.ember.mdx @@ -0,0 +1,45 @@ +```javascript +import * as Sentry from "@sentry/ember"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/ember"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.gatsby.mdx b/src/platform-includes/session-replay/setup/javascript.gatsby.mdx new file mode 100644 index 0000000000000..5af92f4e82c3a --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.gatsby.mdx @@ -0,0 +1,45 @@ +```javascript +import * as Sentry from "@sentry/gatsby"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/gatsby"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.mdx b/src/platform-includes/session-replay/setup/javascript.mdx index 9f86255eb7603..d789fe781c3a7 100644 --- a/src/platform-includes/session-replay/setup/javascript.mdx +++ b/src/platform-includes/session-replay/setup/javascript.mdx @@ -1,7 +1,3 @@ -To set up the integration, add the following to your Sentry initialization. Several options are supported and passable using the integration constructor. See the [configuration documentation](/platforms/javascript/session-replay/configuration/) for more details. - - - ```javascript // import Sentry from your framework SDK (e.g. @sentry/react) instead of @sentry/browser import * as Sentry from "@sentry/browser"; diff --git a/src/platform-includes/session-replay/setup/javascript.nextjs.mdx b/src/platform-includes/session-replay/setup/javascript.nextjs.mdx new file mode 100644 index 0000000000000..3d4d0464b72f3 --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.nextjs.mdx @@ -0,0 +1,47 @@ +On your client-side NextJS app, add: + +```javascript +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/nextjs"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.react.mdx b/src/platform-includes/session-replay/setup/javascript.react.mdx new file mode 100644 index 0000000000000..95b3698bf15f1 --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.react.mdx @@ -0,0 +1,45 @@ +```javascript +import * as Sentry from "@sentry/react"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/react"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.remix.mdx b/src/platform-includes/session-replay/setup/javascript.remix.mdx new file mode 100644 index 0000000000000..d9c7e30d55340 --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.remix.mdx @@ -0,0 +1,47 @@ +On your client-side Remix app, add: + +```javascript +import * as Sentry from "@sentry/remix"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/remix"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.svelte.mdx b/src/platform-includes/session-replay/setup/javascript.svelte.mdx new file mode 100644 index 0000000000000..d3b22f6b0f487 --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.svelte.mdx @@ -0,0 +1,45 @@ +```javascript +import * as Sentry from "@sentry/svelte"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/svelte"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.sveltekit.mdx b/src/platform-includes/session-replay/setup/javascript.sveltekit.mdx new file mode 100644 index 0000000000000..30abbccf7531f --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.sveltekit.mdx @@ -0,0 +1,47 @@ +On your client-side SvelteKit app, add: + +```javascript +import * as Sentry from "@sentry/sveltekit"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/sveltekit"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platform-includes/session-replay/setup/javascript.vue.mdx b/src/platform-includes/session-replay/setup/javascript.vue.mdx new file mode 100644 index 0000000000000..d5e067ed409ae --- /dev/null +++ b/src/platform-includes/session-replay/setup/javascript.vue.mdx @@ -0,0 +1,45 @@ +```javascript +import * as Sentry from "@sentry/vue"; + +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // If the entire session is not sampled, use the below sample rate to sample + // sessions when an error occurs. + replaysOnErrorSampleRate: 1.0, + + integrations: [ + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); +``` + +With the settings above, session replays with errors are always captured. +You can verify that with the following: + +```javascript +myUndefinedFunction(); +``` + +### Lazy-loading Replay + +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`: + +```js +Sentry.init({ + // Note, Replay is NOT instantiated below: + integrations: [], +}); + +// Sometime later +const { getCurrentHub, Replay } = await import("@sentry/vue"); +getCurrentHub().getClient().addIntegration(new Replay()); +``` diff --git a/src/platforms/javascript/common/session-replay/index.mdx b/src/platforms/javascript/common/session-replay/index.mdx index 889af1b826883..91f2b7777cc97 100644 --- a/src/platforms/javascript/common/session-replay/index.mdx +++ b/src/platforms/javascript/common/session-replay/index.mdx @@ -60,6 +60,10 @@ By default, our Session Replay SDK masks all DOM text content, images, and user ## Set Up +To set up the integration, add the following to your Sentry initialization. There are several options you can pass to the integration constructor. See the [configuration documentation](/platforms/javascript/session-replay/configuration/) for more details. + + + ### Content Security Policy (CSP)