vue.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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(
  32. 'The Replay integration is already included with the Vue SDK package.'
  33. ),
  34. configurations: [
  35. {
  36. language: 'bash',
  37. code: [
  38. {
  39. label: 'npm',
  40. value: 'npm',
  41. language: 'bash',
  42. code: 'npm install --save @sentry/vue',
  43. },
  44. {
  45. label: 'yarn',
  46. value: 'yarn',
  47. language: 'bash',
  48. code: 'yarn add @sentry/vue',
  49. },
  50. ],
  51. },
  52. ],
  53. },
  54. {
  55. type: StepType.CONFIGURE,
  56. description: tct(
  57. '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].',
  58. {
  59. code: <code />,
  60. link: (
  61. <ExternalLink href="https://docs.sentry.io/platforms/javascript/session-replay/" />
  62. ),
  63. }
  64. ),
  65. configurations: [
  66. {
  67. language: 'javascript',
  68. code: `
  69. import * as Sentry from "@sentry/vue";
  70. Sentry.init({
  71. ${sentryInitContent}
  72. });
  73. `,
  74. },
  75. ],
  76. },
  77. ];
  78. // Configuration End
  79. export function GettingStartedWithVueReplay({
  80. dsn,
  81. organization,
  82. newOrg,
  83. platformKey,
  84. projectId,
  85. ...props
  86. }: ModuleProps) {
  87. const integrations = replayIntegration.trim();
  88. const otherConfigs = replayOtherConfig.trim();
  89. let sentryInitContent: string[] = [`dsn: "${dsn}",`];
  90. sentryInitContent = sentryInitContent.concat('integrations: [', integrations, '],');
  91. sentryInitContent = sentryInitContent.concat(otherConfigs);
  92. return (
  93. <Layout
  94. steps={steps({
  95. sentryInitContent: sentryInitContent.join('\n'),
  96. organization,
  97. newOrg,
  98. platformKey,
  99. projectId,
  100. })}
  101. platformKey={platformKey}
  102. newOrg={newOrg}
  103. hideHeader
  104. {...props}
  105. />
  106. );
  107. }
  108. export default GettingStartedWithVueReplay;