sveltekit.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 {CopyDsnField} from 'sentry/components/onboarding/gettingStartedDoc/copyDsnField';
  6. import crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
  7. import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  8. import TracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
  9. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  10. import type {
  11. Docs,
  12. DocsParams,
  13. OnboardingConfig,
  14. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  15. import {
  16. getCrashReportJavaScriptInstallStep,
  17. getCrashReportModalConfigDescription,
  18. getCrashReportModalIntroduction,
  19. getFeedbackConfigureDescription,
  20. getFeedbackSDKSetupSnippet,
  21. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  22. import {
  23. getReplayConfigureDescription,
  24. getReplaySDKSetupSnippet,
  25. getReplayVerifyStep,
  26. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  27. import {featureFlagOnboarding} from 'sentry/gettingStartedDocs/javascript/javascript';
  28. import {t, tct} from 'sentry/locale';
  29. type Params = DocsParams;
  30. const getConfigStep = ({isSelfHosted, organization, projectSlug}: Params) => {
  31. const urlParam = isSelfHosted ? '' : '--saas';
  32. return [
  33. {
  34. type: StepType.INSTALL,
  35. description: tct(
  36. 'Configure your app automatically by running the [wizardLink:Sentry wizard] in the root of your project.',
  37. {
  38. wizardLink: (
  39. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/#install" />
  40. ),
  41. }
  42. ),
  43. configurations: [
  44. {
  45. language: 'bash',
  46. code: `npx @sentry/wizard@latest -i sveltekit ${urlParam} --org ${organization.slug} --project ${projectSlug}`,
  47. },
  48. ],
  49. },
  50. ];
  51. };
  52. const getInstallConfig = (params: Params) => [
  53. {
  54. type: StepType.INSTALL,
  55. configurations: getConfigStep(params),
  56. },
  57. ];
  58. const onboarding: OnboardingConfig = {
  59. install: (params: Params) => [
  60. {
  61. title: t('Automatic Configuration (Recommended)'),
  62. configurations: getConfigStep(params),
  63. },
  64. ],
  65. configure: params => [
  66. {
  67. title: t('Manual Configuration'),
  68. collapsible: true,
  69. description: tct(
  70. 'Alternatively, you can also [manualSetupLink:set up the SDK manually], by following these steps:',
  71. {
  72. manualSetupLink: (
  73. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/" />
  74. ),
  75. }
  76. ),
  77. configurations: [
  78. {
  79. description: (
  80. <List symbol="bullet">
  81. <ListItem>
  82. {tct(
  83. 'Create or update [code:src/hooks.client.js] and [code:src/hooks.server.js] with the default [code:Sentry.init] call and SvelteKit hooks handlers.',
  84. {
  85. code: <code />,
  86. }
  87. )}
  88. </ListItem>
  89. <ListItem>
  90. {tct(
  91. 'Update [code:vite.config.js] to add source maps upload and auto-instrumentation via Vite plugins.',
  92. {
  93. code: <code />,
  94. }
  95. )}
  96. </ListItem>
  97. <ListItem>
  98. {tct(
  99. 'Create [code:.sentryclirc] and [code:sentry.properties] files with configuration for sentry-cli (which is used when automatically uploading source maps).',
  100. {
  101. code: <code />,
  102. }
  103. )}
  104. </ListItem>
  105. </List>
  106. ),
  107. },
  108. {
  109. description: <CopyDsnField params={params} />,
  110. },
  111. ],
  112. },
  113. ],
  114. verify: () => [
  115. {
  116. type: StepType.VERIFY,
  117. description: (
  118. <Fragment>
  119. <p>
  120. {tct(
  121. 'Start your development server and visit [code:/sentry-example-page] if you have set it up. Click the button to trigger a test error.',
  122. {
  123. code: <code />,
  124. }
  125. )}
  126. </p>
  127. <p>
  128. {t(
  129. 'Or, trigger a sample error by calling a function that does not exist somewhere in your application.'
  130. )}
  131. </p>
  132. </Fragment>
  133. ),
  134. configurations: [
  135. {
  136. code: [
  137. {
  138. label: 'Javascript',
  139. value: 'javascript',
  140. language: 'javascript',
  141. code: `myUndefinedFunction();`,
  142. },
  143. ],
  144. },
  145. ],
  146. additionalInfo: t(
  147. 'If you see an issue in your Sentry dashboard, you have successfully set up Sentry.'
  148. ),
  149. },
  150. ],
  151. };
  152. const replayOnboarding: OnboardingConfig = {
  153. install: (params: Params) => getInstallConfig(params),
  154. configure: (params: Params) => [
  155. {
  156. type: StepType.CONFIGURE,
  157. description: getReplayConfigureDescription({
  158. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/session-replay/',
  159. }),
  160. configurations: [
  161. {
  162. code: [
  163. {
  164. label: 'JavaScript',
  165. value: 'javascript',
  166. language: 'javascript',
  167. code: getReplaySDKSetupSnippet({
  168. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  169. dsn: params.dsn.public,
  170. mask: params.replayOptions?.mask,
  171. block: params.replayOptions?.block,
  172. }),
  173. },
  174. ],
  175. additionalInfo: <TracePropagationMessage />,
  176. },
  177. ],
  178. },
  179. ],
  180. verify: getReplayVerifyStep(),
  181. nextSteps: () => [],
  182. };
  183. const feedbackOnboarding: OnboardingConfig = {
  184. install: (params: Params) => [
  185. {
  186. type: StepType.INSTALL,
  187. description: tct(
  188. '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.',
  189. {
  190. code: <code />,
  191. }
  192. ),
  193. configurations: getInstallConfig(params),
  194. },
  195. ],
  196. configure: (params: Params) => [
  197. {
  198. type: StepType.CONFIGURE,
  199. description: getFeedbackConfigureDescription({
  200. linkConfig:
  201. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/',
  202. linkButton:
  203. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#bring-your-own-button',
  204. }),
  205. configurations: [
  206. {
  207. code: [
  208. {
  209. label: 'JavaScript',
  210. value: 'javascript',
  211. language: 'javascript',
  212. code: getFeedbackSDKSetupSnippet({
  213. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  214. dsn: params.dsn.public,
  215. feedbackOptions: params.feedbackOptions,
  216. }),
  217. },
  218. ],
  219. },
  220. ],
  221. additionalInfo: crashReportCallout({
  222. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#crash-report-modal',
  223. }),
  224. },
  225. ],
  226. verify: () => [],
  227. nextSteps: () => [],
  228. };
  229. const crashReportOnboarding: OnboardingConfig = {
  230. introduction: () => getCrashReportModalIntroduction(),
  231. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  232. configure: () => [
  233. {
  234. type: StepType.CONFIGURE,
  235. description: getCrashReportModalConfigDescription({
  236. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#crash-report-modal',
  237. }),
  238. additionalInfo: widgetCallout({
  239. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#user-feedback-widget',
  240. }),
  241. },
  242. ],
  243. verify: () => [],
  244. nextSteps: () => [],
  245. };
  246. const docs: Docs = {
  247. onboarding,
  248. feedbackOnboardingNpm: feedbackOnboarding,
  249. replayOnboarding,
  250. crashReportOnboarding,
  251. featureFlagOnboarding,
  252. };
  253. export default docs;