remix.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {t, tct} from 'sentry/locale';
  6. import type {Organization, PlatformKey} from 'sentry/types';
  7. type StepProps = {
  8. newOrg: boolean;
  9. organization: Organization;
  10. platformKey: PlatformKey;
  11. projectId: string;
  12. sentryInitContent: string;
  13. };
  14. // Configuration Start
  15. const replayIntegration = `
  16. new Sentry.Replay(),
  17. `;
  18. const replayOtherConfig = `
  19. // This sets the sample rate to be 10%. You may want this to be 100% while
  20. // in development and sample at a lower rate in production.
  21. replaysSessionSampleRate: 0.1,
  22. // If the entire session is not sampled, use the below sample rate to sample
  23. // sessions when an error occurs.
  24. replaysOnErrorSampleRate: 1.0,
  25. `;
  26. export const steps = ({
  27. sentryInitContent,
  28. }: Partial<StepProps> = {}): LayoutProps['steps'] => [
  29. {
  30. type: StepType.INSTALL,
  31. description: t('Configure your app automatically with the Sentry wizard.'),
  32. configurations: [
  33. {
  34. language: 'bash',
  35. code: [
  36. {
  37. label: 'Bash',
  38. value: 'bash',
  39. language: 'bash',
  40. code: 'npx @sentry/wizard@latest -i remix',
  41. },
  42. ],
  43. },
  44. ],
  45. },
  46. {
  47. type: StepType.CONFIGURE,
  48. description: tct(
  49. '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].',
  50. {
  51. code: <code />,
  52. link: (
  53. <ExternalLink href="https://docs.sentry.io/platforms/javascript/session-replay/" />
  54. ),
  55. }
  56. ),
  57. configurations: [
  58. {
  59. language: 'javascript',
  60. code: `
  61. import * as Sentry from "@sentry/remix";
  62. Sentry.init({
  63. ${sentryInitContent}
  64. });
  65. `,
  66. },
  67. ],
  68. additionalInfo: tct(
  69. 'Note: The Replay integration only needs to be added to your [codeEntry:entry.client.tsx] file. It will not run if it is added into [codeSentry:sentry.server.config.js].',
  70. {codeEntry: <code />, codeSentry: <code />}
  71. ),
  72. },
  73. ];
  74. // Configuration End
  75. export function GettingStartedWithRemixReplay({
  76. dsn,
  77. organization,
  78. newOrg,
  79. platformKey,
  80. projectId,
  81. ...props
  82. }: ModuleProps) {
  83. const integrations = replayIntegration.trim();
  84. const otherConfigs = replayOtherConfig.trim();
  85. let sentryInitContent: string[] = [`dsn: "${dsn}",`];
  86. sentryInitContent = sentryInitContent.concat('integrations: [', integrations, '],');
  87. sentryInitContent = sentryInitContent.concat(otherConfigs);
  88. return (
  89. <Layout
  90. steps={steps({
  91. sentryInitContent: sentryInitContent.join('\n'),
  92. organization,
  93. newOrg,
  94. platformKey,
  95. projectId,
  96. })}
  97. platformKey={platformKey}
  98. newOrg={newOrg}
  99. hideHeader
  100. {...props}
  101. />
  102. );
  103. }
  104. export default GettingStartedWithRemixReplay;