sveltekit.tsx 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  26. import {t, tct} from 'sentry/locale';
  27. type Params = DocsParams;
  28. const getInstallConfig = () => [
  29. {
  30. type: StepType.INSTALL,
  31. description: tct(
  32. 'Configure your app automatically with the [wizardLink:Sentry wizard].',
  33. {
  34. wizardLink: (
  35. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/#install" />
  36. ),
  37. }
  38. ),
  39. configurations: [
  40. {
  41. language: 'bash',
  42. code: `npx @sentry/wizard@latest -i sveltekit`,
  43. },
  44. ],
  45. },
  46. ];
  47. const onboarding: OnboardingConfig = {
  48. install: () => getInstallConfig(),
  49. configure: () => [
  50. {
  51. type: StepType.CONFIGURE,
  52. configurations: [
  53. {
  54. description: (
  55. <Fragment>
  56. {t(
  57. 'The Sentry wizard will automatically patch your application to configure the Sentry SDK:'
  58. )}
  59. <List symbol="bullet">
  60. <ListItem>
  61. {tct(
  62. '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.',
  63. {
  64. hookClientCode: <code />,
  65. hookServerCode: <code />,
  66. sentryInitCode: <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 [sentryClircCode:.sentryclirc] and [sentryPropertiesCode:sentry.properties] files with configuration for sentry-cli (which is used when automatically uploading source maps).',
  81. {
  82. sentryClircCode: <code />,
  83. sentryPropertiesCode: <code />,
  84. }
  85. )}
  86. </ListItem>
  87. </List>
  88. <p>
  89. {tct(
  90. 'Alternatively, you can also [manualSetupLink:set up the SDK manually].',
  91. {
  92. manualSetupLink: (
  93. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/manual-setup/" />
  94. ),
  95. }
  96. )}
  97. </p>
  98. </Fragment>
  99. ),
  100. },
  101. ],
  102. },
  103. ],
  104. verify: () => [],
  105. };
  106. const replayOnboarding: OnboardingConfig = {
  107. install: () => getInstallConfig(),
  108. configure: (params: Params) => [
  109. {
  110. type: StepType.CONFIGURE,
  111. description: getReplayConfigureDescription({
  112. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/session-replay/',
  113. }),
  114. configurations: [
  115. {
  116. code: [
  117. {
  118. label: 'JavaScript',
  119. value: 'javascript',
  120. language: 'javascript',
  121. code: getReplaySDKSetupSnippet({
  122. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  123. dsn: params.dsn.public,
  124. mask: params.replayOptions?.mask,
  125. block: params.replayOptions?.block,
  126. }),
  127. },
  128. ],
  129. additionalInfo: <TracePropagationMessage />,
  130. },
  131. ],
  132. },
  133. ],
  134. verify: () => [],
  135. nextSteps: () => [],
  136. };
  137. const feedbackOnboarding: OnboardingConfig = {
  138. install: () => [
  139. {
  140. type: StepType.INSTALL,
  141. description: tct(
  142. '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.',
  143. {
  144. code: <code />,
  145. }
  146. ),
  147. configurations: getInstallConfig(),
  148. },
  149. ],
  150. configure: (params: Params) => [
  151. {
  152. type: StepType.CONFIGURE,
  153. description: getFeedbackConfigureDescription({
  154. linkConfig:
  155. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/',
  156. linkButton:
  157. 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#bring-your-own-button',
  158. }),
  159. configurations: [
  160. {
  161. code: [
  162. {
  163. label: 'JavaScript',
  164. value: 'javascript',
  165. language: 'javascript',
  166. code: getFeedbackSDKSetupSnippet({
  167. importStatement: `import * as Sentry from "@sentry/sveltekit";`,
  168. dsn: params.dsn.public,
  169. feedbackOptions: params.feedbackOptions,
  170. }),
  171. },
  172. ],
  173. },
  174. ],
  175. additionalInfo: crashReportCallout({
  176. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#crash-report-modal',
  177. }),
  178. },
  179. ],
  180. verify: () => [],
  181. nextSteps: () => [],
  182. };
  183. const crashReportOnboarding: OnboardingConfig = {
  184. introduction: () => getCrashReportModalIntroduction(),
  185. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  186. configure: () => [
  187. {
  188. type: StepType.CONFIGURE,
  189. description: getCrashReportModalConfigDescription({
  190. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/configuration/#crash-report-modal',
  191. }),
  192. additionalInfo: widgetCallout({
  193. link: 'https://docs.sentry.io/platforms/javascript/guides/sveltekit/user-feedback/#user-feedback-widget',
  194. }),
  195. },
  196. ],
  197. verify: () => [],
  198. nextSteps: () => [],
  199. };
  200. const docs: Docs = {
  201. onboarding,
  202. feedbackOnboardingNpm: feedbackOnboarding,
  203. replayOnboardingNpm: replayOnboarding,
  204. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  205. crashReportOnboarding,
  206. };
  207. export default docs;