sveltekit.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  7. import TracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
  8. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  9. import type {
  10. Docs,
  11. DocsParams,
  12. OnboardingConfig,
  13. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  14. import {
  15. getCrashReportJavaScriptInstallStep,
  16. getCrashReportModalConfigDescription,
  17. getCrashReportModalIntroduction,
  18. getFeedbackConfigureDescription,
  19. getFeedbackSDKSetupSnippet,
  20. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  21. import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  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: () => [
  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. },
  110. ],
  111. verify: () => [
  112. {
  113. type: StepType.VERIFY,
  114. description: (
  115. <Fragment>
  116. <p>
  117. {tct(
  118. 'Start your development server and visit [code:/sentry-example-page] if you have set it up. Click the button to trigger a test error.',
  119. {
  120. code: <code />,
  121. }
  122. )}
  123. </p>
  124. <p>
  125. {t(
  126. 'Or, trigger a sample error by calling a function that does not exist somewhere in your application.'
  127. )}
  128. </p>
  129. </Fragment>
  130. ),
  131. configurations: [
  132. {
  133. code: [
  134. {
  135. label: 'Javascript',
  136. value: 'javascript',
  137. language: 'javascript',
  138. code: `myUndefinedFunction();`,
  139. },
  140. ],
  141. },
  142. ],
  143. additionalInfo: t(
  144. 'If you see an issue in your Sentry dashboard, you have successfully set up Sentry.'
  145. ),
  146. },
  147. ],
  148. };
  149. const replayOnboarding: OnboardingConfig = {
  150. install: (params: Params) => getInstallConfig(params),
  151. configure: (params: Params) => [
  152. {
  153. type: StepType.CONFIGURE,
  154. description: getReplayConfigureDescription({
  155. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/session-replay/',
  156. }),
  157. configurations: [
  158. {
  159. code: [
  160. {
  161. label: 'JavaScript',
  162. value: 'javascript',
  163. language: 'javascript',
  164. code: getReplaySDKSetupSnippet({
  165. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  166. dsn: params.dsn.public,
  167. mask: params.replayOptions?.mask,
  168. block: params.replayOptions?.block,
  169. }),
  170. },
  171. ],
  172. additionalInfo: <TracePropagationMessage />,
  173. },
  174. ],
  175. },
  176. ],
  177. verify: getReplayVerifyStep(),
  178. nextSteps: () => [],
  179. };
  180. const feedbackOnboarding: OnboardingConfig = {
  181. install: (params: Params) => [
  182. {
  183. type: StepType.INSTALL,
  184. description: tct(
  185. '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.',
  186. {
  187. code: <code />,
  188. }
  189. ),
  190. configurations: getInstallConfig(params),
  191. },
  192. ],
  193. configure: (params: Params) => [
  194. {
  195. type: StepType.CONFIGURE,
  196. description: getFeedbackConfigureDescription({
  197. linkConfig:
  198. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/',
  199. linkButton:
  200. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#bring-your-own-button',
  201. }),
  202. configurations: [
  203. {
  204. code: [
  205. {
  206. label: 'JavaScript',
  207. value: 'javascript',
  208. language: 'javascript',
  209. code: getFeedbackSDKSetupSnippet({
  210. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  211. dsn: params.dsn.public,
  212. feedbackOptions: params.feedbackOptions,
  213. }),
  214. },
  215. ],
  216. },
  217. ],
  218. additionalInfo: crashReportCallout({
  219. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#crash-report-modal',
  220. }),
  221. },
  222. ],
  223. verify: () => [],
  224. nextSteps: () => [],
  225. };
  226. const crashReportOnboarding: OnboardingConfig = {
  227. introduction: () => getCrashReportModalIntroduction(),
  228. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  229. configure: () => [
  230. {
  231. type: StepType.CONFIGURE,
  232. description: getCrashReportModalConfigDescription({
  233. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#crash-report-modal',
  234. }),
  235. additionalInfo: widgetCallout({
  236. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#user-feedback-widget',
  237. }),
  238. },
  239. ],
  240. verify: () => [],
  241. nextSteps: () => [],
  242. };
  243. const docs: Docs = {
  244. onboarding,
  245. feedbackOnboardingNpm: feedbackOnboarding,
  246. replayOnboarding,
  247. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  248. crashReportOnboarding,
  249. featureFlagOnboarding: featureFlagOnboarding,
  250. };
  251. export default docs;