remix.tsx 7.9 KB

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