sveltekit.tsx 4.0 KB

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