sveltekit.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import List from 'sentry/components/list/';
  3. import ListItem from 'sentry/components/list/listItem';
  4. import crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
  5. import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  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. getCrashReportJavaScriptInstallStep,
  15. getCrashReportModalConfigDescription,
  16. getCrashReportModalIntroduction,
  17. getFeedbackConfigureDescription,
  18. getFeedbackSDKSetupSnippet,
  19. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  20. import {getJSMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  21. import {
  22. getReplayConfigureDescription,
  23. getReplaySDKSetupSnippet,
  24. getReplayVerifyStep,
  25. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  26. import {t, tct} from 'sentry/locale';
  27. type Params = DocsParams;
  28. const getInstallConfig = ({isSelfHosted, organization, projectSlug}: Params) => {
  29. const urlParam = isSelfHosted ? '' : '--saas';
  30. return [
  31. {
  32. type: StepType.INSTALL,
  33. description: tct(
  34. 'Configure your app automatically with the [wizardLink:Sentry wizard].',
  35. {
  36. wizardLink: (
  37. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/#install" />
  38. ),
  39. }
  40. ),
  41. configurations: [
  42. {
  43. language: 'bash',
  44. code: `npx @sentry/wizard@latest -i sveltekit ${urlParam} --org ${organization.slug} --project ${projectSlug}`,
  45. },
  46. ],
  47. },
  48. ];
  49. };
  50. const onboarding: OnboardingConfig = {
  51. install: (params: Params) => getInstallConfig(params),
  52. configure: () => [
  53. {
  54. type: StepType.CONFIGURE,
  55. description: t(
  56. 'The Sentry wizard will automatically patch your application to configure the Sentry SDK:'
  57. ),
  58. configurations: [
  59. {
  60. description: (
  61. <List symbol="bullet">
  62. <ListItem>
  63. {tct(
  64. '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.',
  65. {
  66. code: <code />,
  67. }
  68. )}
  69. </ListItem>
  70. <ListItem>
  71. {tct(
  72. 'Update [code:vite.config.js] to add source maps upload and auto-instrumentation via Vite plugins.',
  73. {
  74. code: <code />,
  75. }
  76. )}
  77. </ListItem>
  78. <ListItem>
  79. {tct(
  80. 'Create [code:.sentryclirc] and [code:sentry.properties] files with configuration for sentry-cli (which is used when automatically uploading source maps).',
  81. {
  82. code: <code />,
  83. }
  84. )}
  85. </ListItem>
  86. </List>
  87. ),
  88. additionalInfo: tct(
  89. 'Alternatively, you can also [manualSetupLink:set up the SDK manually].',
  90. {
  91. manualSetupLink: (
  92. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/" />
  93. ),
  94. }
  95. ),
  96. },
  97. ],
  98. },
  99. ],
  100. verify: () => [],
  101. };
  102. const replayOnboarding: OnboardingConfig = {
  103. install: (params: Params) => getInstallConfig(params),
  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.public,
  120. mask: params.replayOptions?.mask,
  121. block: params.replayOptions?.block,
  122. }),
  123. },
  124. ],
  125. additionalInfo: <TracePropagationMessage />,
  126. },
  127. ],
  128. },
  129. ],
  130. verify: getReplayVerifyStep(),
  131. nextSteps: () => [],
  132. };
  133. const feedbackOnboarding: OnboardingConfig = {
  134. install: (params: Params) => [
  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(params),
  144. },
  145. ],
  146. configure: (params: Params) => [
  147. {
  148. type: StepType.CONFIGURE,
  149. description: getFeedbackConfigureDescription({
  150. linkConfig:
  151. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/',
  152. linkButton:
  153. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#bring-your-own-button',
  154. }),
  155. configurations: [
  156. {
  157. code: [
  158. {
  159. label: 'JavaScript',
  160. value: 'javascript',
  161. language: 'javascript',
  162. code: getFeedbackSDKSetupSnippet({
  163. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  164. dsn: params.dsn.public,
  165. feedbackOptions: params.feedbackOptions,
  166. }),
  167. },
  168. ],
  169. },
  170. ],
  171. additionalInfo: crashReportCallout({
  172. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#crash-report-modal',
  173. }),
  174. },
  175. ],
  176. verify: () => [],
  177. nextSteps: () => [],
  178. };
  179. const crashReportOnboarding: OnboardingConfig = {
  180. introduction: () => getCrashReportModalIntroduction(),
  181. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  182. configure: () => [
  183. {
  184. type: StepType.CONFIGURE,
  185. description: getCrashReportModalConfigDescription({
  186. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#crash-report-modal',
  187. }),
  188. additionalInfo: widgetCallout({
  189. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#user-feedback-widget',
  190. }),
  191. },
  192. ],
  193. verify: () => [],
  194. nextSteps: () => [],
  195. };
  196. const docs: Docs = {
  197. onboarding,
  198. feedbackOnboardingNpm: feedbackOnboarding,
  199. replayOnboarding,
  200. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  201. crashReportOnboarding,
  202. };
  203. export default docs;