remix.tsx 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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, urlPrefix}: Params) => {
  30. const urlParam = !isSelfHosted && urlPrefix ? `--url ${urlPrefix}` : '';
  31. return [
  32. {
  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/remix/#install" />
  38. ),
  39. }
  40. ),
  41. language: 'bash',
  42. code: `npx @sentry/wizard@latest -i remix ${urlParam}`,
  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) => getInstallConfig(params),
  58. configure: () => [
  59. {
  60. type: StepType.CONFIGURE,
  61. description: t(
  62. 'The Sentry wizard will automatically add code to your project to inialize and configure the Sentry SDK:'
  63. ),
  64. configurations: [
  65. {
  66. description: (
  67. <List symbol="bullet">
  68. <ListItem>
  69. {tct(
  70. "Create two files in the root directory of your project, [clientEntry:entry.client.tsx] and [serverEntry:entry.server.tsx] (if they don't already exist).",
  71. {
  72. clientEntry: <code />,
  73. serverEntry: <code />,
  74. }
  75. )}
  76. </ListItem>
  77. <ListItem>
  78. {tct(
  79. 'Add the default [sentryInitCode:Sentry.init] call to both, client and server entry files.',
  80. {
  81. sentryInitCode: <code />,
  82. }
  83. )}
  84. </ListItem>
  85. <ListItem>
  86. {tct(
  87. 'Create a [cliRc:.sentryclirc] with an auth token to upload source maps (this file is automatically added to your [gitignore:.gitignore]).',
  88. {
  89. cliRc: <code />,
  90. gitignore: <code />,
  91. }
  92. )}
  93. </ListItem>
  94. <ListItem>
  95. {tct(
  96. 'Adjust your [buildscript:build] script in your [pkgJson:package.json] to automatically upload source maps to Sentry when you build your application.',
  97. {
  98. buildscript: <code />,
  99. pkgJson: <code />,
  100. }
  101. )}
  102. </ListItem>
  103. </List>
  104. ),
  105. },
  106. {
  107. description: tct(
  108. 'You can also further [manualConfigure:configure your SDK] or [manualSetupLink:set it up manually], without the wizard.',
  109. {
  110. manualConfigure: (
  111. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/#configuration" />
  112. ),
  113. manualSetupLink: (
  114. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/" />
  115. ),
  116. }
  117. ),
  118. },
  119. ],
  120. },
  121. ],
  122. verify: () => [],
  123. nextSteps: () => [],
  124. };
  125. const replayOnboarding: OnboardingConfig = {
  126. install: (params: Params) => getInstallConfig(params),
  127. configure: (params: Params) => [
  128. {
  129. type: StepType.CONFIGURE,
  130. description: getReplayConfigureDescription({
  131. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/session-replay/',
  132. }),
  133. configurations: [
  134. {
  135. code: [
  136. {
  137. label: 'entry.client.tsx',
  138. value: 'javascript',
  139. language: 'javascript',
  140. code: getReplaySDKSetupSnippet({
  141. importStatement: `import * as Sentry from "@sentry/remix";`,
  142. dsn: params.dsn.public,
  143. mask: params.replayOptions?.mask,
  144. block: params.replayOptions?.block,
  145. }),
  146. },
  147. ],
  148. },
  149. ],
  150. additionalInfo: (
  151. <Fragment>
  152. <TracePropagationMessage />
  153. {tct(
  154. 'Note: The Replay integration only needs to be added to your [entryClient:entry.client.tsx] file. It will not run if it is added into [sentryServer:sentry.server.config.js].',
  155. {entryClient: <code />, sentryServer: <code />}
  156. )}
  157. </Fragment>
  158. ),
  159. },
  160. ],
  161. verify: getReplayVerifyStep(),
  162. nextSteps: () => [],
  163. };
  164. const feedbackOnboarding: OnboardingConfig = {
  165. install: (params: Params) => [
  166. {
  167. type: StepType.INSTALL,
  168. description: tct(
  169. '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.',
  170. {
  171. code: <code />,
  172. }
  173. ),
  174. configurations: getConfigStep(params),
  175. },
  176. ],
  177. configure: (params: Params) => [
  178. {
  179. type: StepType.CONFIGURE,
  180. description: getFeedbackConfigureDescription({
  181. linkConfig:
  182. 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/configuration/',
  183. linkButton:
  184. 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/configuration/#bring-your-own-button',
  185. }),
  186. configurations: [
  187. {
  188. code: [
  189. {
  190. label: 'entry.client.tsx',
  191. value: 'javascript',
  192. language: 'javascript',
  193. code: getFeedbackSDKSetupSnippet({
  194. importStatement: `import * as Sentry from "@sentry/remix";`,
  195. dsn: params.dsn.public,
  196. feedbackOptions: params.feedbackOptions,
  197. }),
  198. },
  199. ],
  200. },
  201. ],
  202. additionalInfo: (
  203. <Fragment>
  204. <p>
  205. {tct(
  206. 'Note: The Feedback integration only needs to be added to your [code:entry.client.tsx] file.',
  207. {code: <code />}
  208. )}
  209. </p>
  210. {crashReportCallout({
  211. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/#user-feedback-api',
  212. })}
  213. </Fragment>
  214. ),
  215. },
  216. ],
  217. verify: () => [],
  218. nextSteps: () => [],
  219. };
  220. const crashReportOnboarding: OnboardingConfig = {
  221. introduction: () => getCrashReportModalIntroduction(),
  222. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  223. configure: () => [
  224. {
  225. type: StepType.CONFIGURE,
  226. description: getCrashReportModalConfigDescription({
  227. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/configuration/#crash-report-modal',
  228. }),
  229. additionalInfo: widgetCallout({
  230. link: 'https://docs.sentry.io/platforms/javascript/guides/remix/user-feedback/#user-feedback-widget',
  231. }),
  232. },
  233. ],
  234. verify: () => [],
  235. nextSteps: () => [],
  236. };
  237. const docs: Docs = {
  238. onboarding,
  239. feedbackOnboardingNpm: feedbackOnboarding,
  240. replayOnboarding,
  241. customMetricsOnboarding: getJSMetricsOnboarding({getInstallConfig}),
  242. crashReportOnboarding,
  243. };
  244. export default docs;