remix.tsx 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 {t, tct} from 'sentry/locale';
  28. type Params = DocsParams;
  29. const getConfigStep = ({isSelfHosted, organization, projectSlug}: Params) => {
  30. const urlParam = isSelfHosted ? '' : '--saas';
  31. return [
  32. {
  33. description: tct(
  34. 'Configure your app automatically by running the [wizardLink:Sentry wizard] in the root of your project.',
  35. {
  36. wizardLink: (
  37. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/remix/#install" />
  38. ),
  39. }
  40. ),
  41. language: 'bash',
  42. code: `npx @sentry/wizard@latest -i remix ${urlParam} --org ${organization.slug} --project ${projectSlug}`,
  43. },
  44. ];
  45. };
  46. const getInstallConfig = (params: Params) => [
  47. {
  48. type: StepType.INSTALL,
  49. configurations: getConfigStep(params),
  50. },
  51. ];
  52. const onboarding: OnboardingConfig = {
  53. introduction: () =>
  54. tct("Sentry's integration with [remixLink:Remix] supports Remix 1.0.0 and above.", {
  55. remixLink: <ExternalLink href="https://remix.run/" />,
  56. }),
  57. install: (params: Params) => [
  58. {
  59. title: t('Automatic Configuration (Recommended)'),
  60. configurations: getConfigStep(params),
  61. },
  62. ],
  63. configure: () => [
  64. {
  65. collapsible: true,
  66. title: t('Manual Configuration'),
  67. description: tct(
  68. 'Alternatively, you can also [manualSetupLink:set up the SDK manually], by following these steps:',
  69. {
  70. manualSetupLink: (
  71. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/" />
  72. ),
  73. }
  74. ),
  75. configurations: [
  76. {
  77. description: (
  78. <List symbol="bullet">
  79. <ListItem>
  80. {tct(
  81. "Create two files in the root directory of your project, [code:entry.client.tsx] and [code:entry.server.tsx] (if they don't already exist).",
  82. {
  83. code: <code />,
  84. }
  85. )}
  86. </ListItem>
  87. <ListItem>
  88. {tct(
  89. 'Add the default [sentryInitCode:Sentry.init] call to both, client and server entry files.',
  90. {
  91. sentryInitCode: <code />,
  92. }
  93. )}
  94. </ListItem>
  95. <ListItem>
  96. {tct(
  97. 'Create a [code:.sentryclirc] with an auth token to upload source maps (this file is automatically added to your [code:.gitignore]).',
  98. {
  99. code: <code />,
  100. }
  101. )}
  102. </ListItem>
  103. <ListItem>
  104. {tct(
  105. 'Adjust your [code:build] script in your [code:package.json] to automatically upload source maps to Sentry when you build your application.',
  106. {
  107. code: <code />,
  108. }
  109. )}
  110. </ListItem>
  111. </List>
  112. ),
  113. },
  114. ],
  115. },
  116. ],
  117. verify: () => [
  118. {
  119. type: StepType.VERIFY,
  120. description: (
  121. <Fragment>
  122. <p>
  123. {tct(
  124. 'Start your development server and visit [code:/sentry-example-page] if you have set it up. Click the button to trigger a test error.',
  125. {
  126. code: <code />,
  127. }
  128. )}
  129. </p>
  130. <p>
  131. {t(
  132. 'Or, trigger a sample error by calling a function that does not exist somewhere in your application.'
  133. )}
  134. </p>
  135. </Fragment>
  136. ),
  137. configurations: [
  138. {
  139. code: [
  140. {
  141. label: 'Javascript',
  142. value: 'javascript',
  143. language: 'javascript',
  144. code: `myUndefinedFunction();`,
  145. },
  146. ],
  147. },
  148. ],
  149. additionalInfo: t(
  150. 'If you see an issue in your Sentry dashboard, you have successfully set up Sentry.'
  151. ),
  152. },
  153. ],
  154. nextSteps: () => [],
  155. };
  156. const replayOnboarding: OnboardingConfig = {
  157. install: (params: Params) => getInstallConfig(params),
  158. configure: (params: Params) => [
  159. {
  160. type: StepType.CONFIGURE,
  161. description: getReplayConfigureDescription({
  162. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/session-replay/',
  163. }),
  164. configurations: [
  165. {
  166. code: [
  167. {
  168. label: 'entry.client.tsx',
  169. value: 'javascript',
  170. language: 'javascript',
  171. code: getReplaySDKSetupSnippet({
  172. importStatement: `import * as Sentry from "@sentry/remix";`,
  173. dsn: params.dsn.public,
  174. mask: params.replayOptions?.mask,
  175. block: params.replayOptions?.block,
  176. }),
  177. },
  178. ],
  179. },
  180. ],
  181. additionalInfo: (
  182. <Fragment>
  183. <TracePropagationMessage />
  184. {tct(
  185. 'Note: The Replay integration only needs to be added to your [code:entry.client.tsx] file. It will not run if it is added into [code:sentry.server.config.js].',
  186. {code: <code />}
  187. )}
  188. </Fragment>
  189. ),
  190. },
  191. ],
  192. verify: getReplayVerifyStep(),
  193. nextSteps: () => [],
  194. };
  195. const feedbackOnboarding: OnboardingConfig = {
  196. install: (params: Params) => [
  197. {
  198. type: StepType.INSTALL,
  199. description: tct(
  200. 'For the User Feedback integration to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/remix]) installed, minimum version 7.85.0.',
  201. {
  202. code: <code />,
  203. }
  204. ),
  205. configurations: getConfigStep(params),
  206. },
  207. ],
  208. configure: (params: Params) => [
  209. {
  210. type: StepType.CONFIGURE,
  211. description: getFeedbackConfigureDescription({
  212. linkConfig:
  213. 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/configuration/',
  214. linkButton:
  215. 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/configuration/#bring-your-own-button',
  216. }),
  217. configurations: [
  218. {
  219. code: [
  220. {
  221. label: 'entry.client.tsx',
  222. value: 'javascript',
  223. language: 'javascript',
  224. code: getFeedbackSDKSetupSnippet({
  225. importStatement: `import * as Sentry from "@sentry/remix";`,
  226. dsn: params.dsn.public,
  227. feedbackOptions: params.feedbackOptions,
  228. }),
  229. },
  230. ],
  231. },
  232. ],
  233. additionalInfo: (
  234. <Fragment>
  235. <p>
  236. {tct(
  237. 'Note: The Feedback integration only needs to be added to your [code:entry.client.tsx] file.',
  238. {code: <code />}
  239. )}
  240. </p>
  241. {crashReportCallout({
  242. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/#user-feedback-api',
  243. })}
  244. </Fragment>
  245. ),
  246. },
  247. ],
  248. verify: () => [],
  249. nextSteps: () => [],
  250. };
  251. const crashReportOnboarding: OnboardingConfig = {
  252. introduction: () => getCrashReportModalIntroduction(),
  253. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  254. configure: () => [
  255. {
  256. type: StepType.CONFIGURE,
  257. description: getCrashReportModalConfigDescription({
  258. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/configuration/#crash-report-modal',
  259. }),
  260. additionalInfo: widgetCallout({
  261. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/#user-feedback-widget',
  262. }),
  263. },
  264. ],
  265. verify: () => [],
  266. nextSteps: () => [],
  267. };
  268. const docs: Docs = {
  269. onboarding,
  270. feedbackOnboardingNpm: feedbackOnboarding,
  271. replayOnboarding,
  272. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  273. crashReportOnboarding,
  274. };
  275. export default docs;