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/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()); +```