sveltekit.tsx 4.2 KB

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