sveltekit.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
  6. import tracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
  7. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  8. import type {
  9. Docs,
  10. DocsParams,
  11. OnboardingConfig,
  12. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  13. import {
  14. getFeedbackConfigureDescription,
  15. getFeedbackSDKSetupSnippet,
  16. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  17. import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  18. import {
  19. getReplayConfigureDescription,
  20. getReplaySDKSetupSnippet,
  21. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  22. import {t, tct} from 'sentry/locale';
  23. type Params = DocsParams;
  24. const getInstallConfig = () => [
  25. {
  26. type: StepType.INSTALL,
  27. description: tct(
  28. 'Configure your app automatically with the [wizardLink:Sentry wizard].',
  29. {
  30. wizardLink: (
  31. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/#install" />
  32. ),
  33. }
  34. ),
  35. configurations: [
  36. {
  37. language: 'bash',
  38. code: `npx @sentry/wizard@latest -i sveltekit`,
  39. },
  40. ],
  41. },
  42. ];
  43. const onboarding: OnboardingConfig = {
  44. install: () => getInstallConfig(),
  45. configure: () => [
  46. {
  47. type: StepType.CONFIGURE,
  48. configurations: [
  49. {
  50. description: (
  51. <Fragment>
  52. {t(
  53. 'The Sentry wizard will automatically patch your application to configure the Sentry SDK:'
  54. )}
  55. <List symbol="bullet">
  56. <ListItem>
  57. {tct(
  58. '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.',
  59. {
  60. hookClientCode: <code />,
  61. hookServerCode: <code />,
  62. sentryInitCode: <code />,
  63. }
  64. )}
  65. </ListItem>
  66. <ListItem>
  67. {tct(
  68. 'Update [code:vite.config.js] to add source maps upload and auto-instrumentation via Vite plugins.',
  69. {
  70. code: <code />,
  71. }
  72. )}
  73. </ListItem>
  74. <ListItem>
  75. {tct(
  76. 'Create [sentryClircCode:.sentryclirc] and [sentryPropertiesCode:sentry.properties] files with configuration for sentry-cli (which is used when automatically uploading source maps).',
  77. {
  78. sentryClircCode: <code />,
  79. sentryPropertiesCode: <code />,
  80. }
  81. )}
  82. </ListItem>
  83. </List>
  84. <p>
  85. {tct(
  86. 'Alternatively, you can also [manualSetupLink:set up the SDK manually].',
  87. {
  88. manualSetupLink: (
  89. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/" />
  90. ),
  91. }
  92. )}
  93. </p>
  94. </Fragment>
  95. ),
  96. },
  97. ],
  98. },
  99. ],
  100. verify: () => [],
  101. };
  102. const replayOnboarding: OnboardingConfig = {
  103. install: () => getInstallConfig(),
  104. configure: (params: Params) => [
  105. {
  106. type: StepType.CONFIGURE,
  107. description: getReplayConfigureDescription({
  108. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/session-replay/',
  109. }),
  110. configurations: [
  111. {
  112. code: [
  113. {
  114. label: 'JavaScript',
  115. value: 'javascript',
  116. language: 'javascript',
  117. code: getReplaySDKSetupSnippet({
  118. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  119. dsn: params.dsn,
  120. mask: params.replayOptions?.mask,
  121. block: params.replayOptions?.block,
  122. }),
  123. },
  124. ],
  125. additionalInfo: tracePropagationMessage,
  126. },
  127. ],
  128. },
  129. ],
  130. verify: () => [],
  131. nextSteps: () => [],
  132. };
  133. const feedbackOnboarding: OnboardingConfig = {
  134. install: () => [
  135. {
  136. type: StepType.INSTALL,
  137. description: tct(
  138. 'For the User Feedback integration to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/sveltekit]) installed, minimum version 7.85.0.',
  139. {
  140. code: <code />,
  141. }
  142. ),
  143. configurations: getInstallConfig(),
  144. },
  145. ],
  146. configure: (params: Params) => [
  147. {
  148. type: StepType.CONFIGURE,
  149. description: getFeedbackConfigureDescription({
  150. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/',
  151. }),
  152. configurations: [
  153. {
  154. code: [
  155. {
  156. label: 'JavaScript',
  157. value: 'javascript',
  158. language: 'javascript',
  159. code: getFeedbackSDKSetupSnippet({
  160. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  161. dsn: params.dsn,
  162. }),
  163. },
  164. ],
  165. },
  166. ],
  167. additionalInfo: crashReportCallout({
  168. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#crash-report-modal',
  169. }),
  170. },
  171. ],
  172. verify: () => [],
  173. nextSteps: () => [],
  174. };
  175. const docs: Docs = {
  176. onboarding,
  177. feedbackOnboardingNpm: feedbackOnboarding,
  178. replayOnboardingNpm: replayOnboarding,
  179. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  180. };
  181. export default docs;