sveltekit.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import List from 'sentry/components/list/';
  4. import ListItem from 'sentry/components/list/listItem';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import {
  7. Docs,
  8. DocsParams,
  9. OnboardingConfig,
  10. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  11. import {
  12. getReplayConfigureDescription,
  13. getReplaySDKSetupSnippet,
  14. } from 'sentry/components/onboarding/gettingStartedDoc/utils';
  15. import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  16. import {tracePropagationMessage} from 'sentry/components/replaysOnboarding/utils';
  17. import {t, tct} from 'sentry/locale';
  18. type Params = DocsParams;
  19. const getInstallConfig = () => [
  20. {
  21. type: StepType.INSTALL,
  22. description: tct(
  23. 'Configure your app automatically with the [wizardLink:Sentry wizard].',
  24. {
  25. wizardLink: (
  26. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/#install" />
  27. ),
  28. }
  29. ),
  30. configurations: [
  31. {
  32. language: 'bash',
  33. code: `npx @sentry/wizard@latest -i sveltekit`,
  34. },
  35. ],
  36. },
  37. ];
  38. const onboarding: OnboardingConfig = {
  39. install: () => getInstallConfig(),
  40. configure: () => [
  41. {
  42. type: StepType.CONFIGURE,
  43. configurations: [
  44. {
  45. description: (
  46. <Fragment>
  47. {t(
  48. 'The Sentry wizard will automatically patch your application to configure the Sentry SDK:'
  49. )}
  50. <List symbol="bullet">
  51. <ListItem>
  52. {tct(
  53. 'Create or update [hookClientCode:src/hooks.client.js] and [hookServerCode:src/hooks.server.js] with the default [sentryInitCode:Sentry.init] call and SvelteKit hooks handlers.',
  54. {
  55. hookClientCode: <code />,
  56. hookServerCode: <code />,
  57. sentryInitCode: <code />,
  58. }
  59. )}
  60. </ListItem>
  61. <ListItem>
  62. {tct(
  63. 'Update [code:vite.config.js] to add source maps upload and auto-instrumentation via Vite plugins.',
  64. {
  65. code: <code />,
  66. }
  67. )}
  68. </ListItem>
  69. <ListItem>
  70. {tct(
  71. 'Create [sentryClircCode:.sentryclirc] and [sentryPropertiesCode:sentry.properties] files with configuration for sentry-cli (which is used when automatically uploading source maps).',
  72. {
  73. sentryClircCode: <code />,
  74. sentryPropertiesCode: <code />,
  75. }
  76. )}
  77. </ListItem>
  78. </List>
  79. <p>
  80. {tct(
  81. 'Alternatively, you can also [manualSetupLink:set up the SDK manually].',
  82. {
  83. manualSetupLink: (
  84. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/" />
  85. ),
  86. }
  87. )}
  88. </p>
  89. </Fragment>
  90. ),
  91. },
  92. ],
  93. },
  94. ],
  95. verify: () => [],
  96. };
  97. const replayOnboarding: OnboardingConfig = {
  98. install: () => getInstallConfig(),
  99. configure: (params: Params) => [
  100. {
  101. type: StepType.CONFIGURE,
  102. description: getReplayConfigureDescription({
  103. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/session-replay/',
  104. }),
  105. configurations: [
  106. {
  107. code: [
  108. {
  109. label: 'JavaScript',
  110. value: 'javascript',
  111. language: 'javascript',
  112. code: getReplaySDKSetupSnippet({
  113. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  114. dsn: params.dsn,
  115. mask: params.replayOptions?.mask,
  116. block: params.replayOptions?.block,
  117. }),
  118. },
  119. ],
  120. additionalInfo: tracePropagationMessage,
  121. },
  122. ],
  123. },
  124. ],
  125. verify: () => [],
  126. nextSteps: () => [],
  127. };
  128. const docs: Docs = {
  129. onboarding,
  130. replayOnboardingNpm: replayOnboarding,
  131. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  132. };
  133. export default docs;