|
@@ -0,0 +1,140 @@
|
|
|
+import ExternalLink from 'sentry/components/links/externalLink';
|
|
|
+import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
|
|
|
+import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
|
|
|
+import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
|
|
|
+import {tct} from 'sentry/locale';
|
|
|
+import type {Organization, PlatformKey} from 'sentry/types';
|
|
|
+
|
|
|
+type StepProps = {
|
|
|
+ newOrg: boolean;
|
|
|
+ organization: Organization;
|
|
|
+ platformKey: PlatformKey;
|
|
|
+ projectId: string;
|
|
|
+ sentryInitContent: string;
|
|
|
+};
|
|
|
+
|
|
|
+// Configuration Start
|
|
|
+const replayIntegration = `
|
|
|
+new Sentry.Replay(),
|
|
|
+`;
|
|
|
+
|
|
|
+const replayOtherConfig = `
|
|
|
+// 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,
|
|
|
+`;
|
|
|
+
|
|
|
+export const steps = ({
|
|
|
+ sentryInitContent,
|
|
|
+}: Partial<StepProps> = {}): LayoutProps['steps'] => [
|
|
|
+ {
|
|
|
+ type: StepType.INSTALL,
|
|
|
+ description: (
|
|
|
+ <p>
|
|
|
+ {tct(
|
|
|
+ 'Add the Sentry SDK as a dependency using [codeNpm:npm] or [codeYarn:yarn]. You need a minimum version 7.27.0 of [code:@sentry/react] in order to use Session Replay. You do not need to install any additional packages.',
|
|
|
+ {
|
|
|
+ code: <code />,
|
|
|
+ codeYarn: <code />,
|
|
|
+ codeNpm: <code />,
|
|
|
+ }
|
|
|
+ )}
|
|
|
+ </p>
|
|
|
+ ),
|
|
|
+ configurations: [
|
|
|
+ {
|
|
|
+ language: 'bash',
|
|
|
+ code: [
|
|
|
+ {
|
|
|
+ label: 'npm',
|
|
|
+ value: 'npm',
|
|
|
+ language: 'bash',
|
|
|
+ code: 'npm install --save @sentry/react',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'yarn',
|
|
|
+ value: 'yarn',
|
|
|
+ language: 'bash',
|
|
|
+ code: 'yarn add @sentry/react',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: StepType.CONFIGURE,
|
|
|
+ description: tct(
|
|
|
+ 'Add the following to your SDK config. There are several privacy and sampling options available, all of which can be set using the [code:integrations] constructor. Learn more about configuring Session Replay by reading the [link:configuration docs].',
|
|
|
+ {
|
|
|
+ code: <code />,
|
|
|
+ link: (
|
|
|
+ <ExternalLink href="https://docs.sentry.io/platforms/javascript/session-replay/" />
|
|
|
+ ),
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ configurations: [
|
|
|
+ {
|
|
|
+ language: 'javascript',
|
|
|
+ code: `
|
|
|
+import * as Sentry from "@sentry/react";
|
|
|
+
|
|
|
+Sentry.init({
|
|
|
+ ${sentryInitContent}
|
|
|
+});
|
|
|
+
|
|
|
+const container = document.getElementById(“app”);
|
|
|
+const root = createRoot(container);
|
|
|
+root.render(<App />);
|
|
|
+ `,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+// Configuration End
|
|
|
+
|
|
|
+export function GettingStartedWithReactReplay({
|
|
|
+ dsn,
|
|
|
+ organization,
|
|
|
+ newOrg,
|
|
|
+ platformKey,
|
|
|
+ projectId,
|
|
|
+ ...props
|
|
|
+}: ModuleProps) {
|
|
|
+ const integrations: string[] = [];
|
|
|
+ const otherConfigs: string[] = [];
|
|
|
+
|
|
|
+ integrations.push(replayIntegration.trim());
|
|
|
+ otherConfigs.push(replayOtherConfig.trim());
|
|
|
+
|
|
|
+ let sentryInitContent: string[] = [`dsn: "${dsn}",`];
|
|
|
+
|
|
|
+ if (integrations.length > 0) {
|
|
|
+ sentryInitContent = sentryInitContent.concat('integrations: [', integrations, '],');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (otherConfigs.length > 0) {
|
|
|
+ sentryInitContent = sentryInitContent.concat(otherConfigs);
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Layout
|
|
|
+ steps={steps({
|
|
|
+ sentryInitContent: sentryInitContent.join('\n'),
|
|
|
+ organization,
|
|
|
+ newOrg,
|
|
|
+ platformKey,
|
|
|
+ projectId,
|
|
|
+ })}
|
|
|
+ newOrg={newOrg}
|
|
|
+ platformKey={platformKey}
|
|
|
+ hideHeader
|
|
|
+ {...props}
|
|
|
+ />
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+export default GettingStartedWithReactReplay;
|