nuxt.tsx 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 {CopyDsnField} from 'sentry/components/onboarding/gettingStartedDoc/copyDsnField';
  6. import crashReportCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/crashReportCallout';
  7. import widgetCallout from 'sentry/components/onboarding/gettingStartedDoc/feedback/widgetCallout';
  8. import TracePropagationMessage from 'sentry/components/onboarding/gettingStartedDoc/replay/tracePropagationMessage';
  9. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  10. import type {
  11. Docs,
  12. DocsParams,
  13. OnboardingConfig,
  14. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  15. import {
  16. getCrashReportJavaScriptInstallStep,
  17. getCrashReportModalConfigDescription,
  18. getCrashReportModalIntroduction,
  19. getFeedbackConfigureDescription,
  20. getFeedbackSDKSetupSnippet,
  21. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  22. import {MaybeBrowserProfilingBetaWarning} from 'sentry/components/onboarding/gettingStartedDoc/utils/profilingOnboarding';
  23. import {
  24. getReplayConfigureDescription,
  25. getReplaySDKSetupSnippet,
  26. getReplayVerifyStep,
  27. } from 'sentry/components/onboarding/gettingStartedDoc/utils/replayOnboarding';
  28. import {featureFlagOnboarding} from 'sentry/gettingStartedDocs/javascript/javascript';
  29. import {t, tct, tctCode} from 'sentry/locale';
  30. type Params = DocsParams;
  31. const getConfigStep = ({isSelfHosted, organization, projectSlug}: Params) => {
  32. const urlParam = isSelfHosted ? '' : '--saas';
  33. return [
  34. {
  35. type: StepType.INSTALL,
  36. description: tct(
  37. 'Configure your app automatically by running the [wizardLink:Sentry wizard] in the root of your project.',
  38. {
  39. wizardLink: (
  40. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/nuxt/#install" />
  41. ),
  42. }
  43. ),
  44. configurations: [
  45. {
  46. language: 'bash',
  47. code: `npx @sentry/wizard@latest -i nuxt ${urlParam} --org ${organization.slug} --project ${projectSlug}`,
  48. },
  49. ],
  50. },
  51. ];
  52. };
  53. const getInstallConfig = (params: Params) => [
  54. {
  55. type: StepType.INSTALL,
  56. configurations: getConfigStep(params),
  57. },
  58. ];
  59. const getVerifyNuxtSnippet = () => `
  60. <script setup>
  61. const triggerError = () => {
  62. throw new Error("Nuxt Button Error");
  63. };
  64. </script>
  65. <template>
  66. <button id="errorBtn" @click="triggerError">Trigger Error</button>
  67. </template>`;
  68. const onboarding: OnboardingConfig = {
  69. install: (params: Params) => [
  70. {
  71. title: t('Automatic Configuration (Recommended)'),
  72. configurations: getConfigStep(params),
  73. },
  74. ],
  75. configure: params => [
  76. {
  77. title: t('Manual Configuration'),
  78. collapsible: true,
  79. description: tct(
  80. 'Alternatively, you can also [manualSetupLink:set up the SDK manually], by following these steps:',
  81. {
  82. manualSetupLink: (
  83. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/nuxt/manual-setup/" />
  84. ),
  85. }
  86. ),
  87. configurations: [
  88. {
  89. description: (
  90. <List symbol="bullet">
  91. <ListItem>
  92. {tctCode('Add [code:@sentry/nuxt/module] to your [code:nuxt.config.ts].')}
  93. </ListItem>
  94. <ListItem>
  95. {tctCode(
  96. 'Create or update [code:sentry.client.config.ts] and [code:sentry.server.config.ts] with the default [code:Sentry.init] call.'
  97. )}
  98. </ListItem>
  99. <ListItem>
  100. {tctCode(
  101. 'Configure source maps upload options in your [code:nuxt.config.ts].'
  102. )}
  103. </ListItem>
  104. </List>
  105. ),
  106. },
  107. {
  108. description: <CopyDsnField params={params} />,
  109. },
  110. ],
  111. },
  112. ],
  113. verify: () => [
  114. {
  115. type: StepType.VERIFY,
  116. description: (
  117. <Fragment>
  118. <p>
  119. {tctCode(
  120. 'Build and run your application and visit [code:/sentry-example-page] if you have set it up. Click the button to trigger a test error.'
  121. )}
  122. </p>
  123. <p>{t('Or, throw an error in a simple vue component.')}</p>
  124. </Fragment>
  125. ),
  126. configurations: [
  127. {
  128. code: [
  129. {
  130. label: 'Vue',
  131. value: 'vue',
  132. language: 'html',
  133. code: getVerifyNuxtSnippet(),
  134. },
  135. ],
  136. },
  137. ],
  138. additionalInfo: t(
  139. 'If you see an issue in your Sentry dashboard, you have successfully set up Sentry.'
  140. ),
  141. },
  142. ],
  143. nextSteps: () => [
  144. {
  145. id: 'nuxt-features',
  146. name: t('Nuxt Features'),
  147. description: t('Learn about our first class integration with the Nuxt framework.'),
  148. link: 'https://docs.sentry.io/platforms/javascript/guides/nuxt/features/',
  149. },
  150. ],
  151. };
  152. const replayOnboarding: OnboardingConfig = {
  153. install: (params: Params) => getInstallConfig(params),
  154. configure: (params: Params) => [
  155. {
  156. type: StepType.INSTALL,
  157. description: getReplayConfigureDescription({
  158. link: 'https://docs.sentry.io/platforms/javascript/guides/nuxt/session-replay/',
  159. }),
  160. configurations: [
  161. {
  162. code: [
  163. {
  164. label: 'JavaScript',
  165. value: 'javascript',
  166. language: 'javascript',
  167. code: getReplaySDKSetupSnippet({
  168. importStatement: `import * as Sentry from "@sentry/nuxt";`,
  169. dsn: params.dsn.public,
  170. mask: params.replayOptions?.mask,
  171. block: params.replayOptions?.block,
  172. }),
  173. },
  174. ],
  175. },
  176. ],
  177. additionalInfo: <TracePropagationMessage />,
  178. },
  179. ],
  180. verify: getReplayVerifyStep(),
  181. nextSteps: () => [],
  182. };
  183. const feedbackOnboarding: OnboardingConfig = {
  184. install: (params: Params) => [
  185. {
  186. type: StepType.INSTALL,
  187. description: tct(
  188. 'For the User Feedback integration to work, you must have the Sentry browser SDK package, or an equivalent framework SDK (e.g. [code:@sentry/nuxt]) installed, minimum version 7.85.0.',
  189. {
  190. code: <code />,
  191. }
  192. ),
  193. configurations: getInstallConfig(params),
  194. },
  195. ],
  196. configure: (params: Params) => [
  197. {
  198. type: StepType.CONFIGURE,
  199. description: getFeedbackConfigureDescription({
  200. linkConfig:
  201. 'https://docs.sentry.io/platforms/javascript/guides/nuxt/user-feedback/configuration/',
  202. linkButton:
  203. 'https://docs.sentry.io/platforms/javascript/guides/nuxt/user-feedback/configuration/#bring-your-own-button',
  204. }),
  205. configurations: [
  206. {
  207. code: [
  208. {
  209. label: 'JavaScript',
  210. value: 'javascript',
  211. language: 'javascript',
  212. code: getFeedbackSDKSetupSnippet({
  213. importStatement: `import * as Sentry from "@sentry/nuxt";`,
  214. dsn: params.dsn.public,
  215. feedbackOptions: params.feedbackOptions,
  216. }),
  217. },
  218. ],
  219. },
  220. ],
  221. additionalInfo: crashReportCallout({
  222. link: 'https://docs.sentry.io/platforms/javascript/guides/nuxt/user-feedback/#crash-report-modal',
  223. }),
  224. },
  225. ],
  226. verify: () => [],
  227. nextSteps: () => [],
  228. };
  229. const crashReportOnboarding: OnboardingConfig = {
  230. introduction: () => getCrashReportModalIntroduction(),
  231. install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
  232. configure: () => [
  233. {
  234. type: StepType.CONFIGURE,
  235. description: getCrashReportModalConfigDescription({
  236. link: 'https://docs.sentry.io/platforms/javascript/guides/nuxt/user-feedback/configuration/#crash-report-modal',
  237. }),
  238. additionalInfo: widgetCallout({
  239. link: 'https://docs.sentry.io/platforms/javascript/guides/nuxt/user-feedback/#user-feedback-widget',
  240. }),
  241. },
  242. ],
  243. verify: () => [],
  244. nextSteps: () => [],
  245. };
  246. const profilingOnboarding: OnboardingConfig = {
  247. ...onboarding,
  248. introduction: params => <MaybeBrowserProfilingBetaWarning {...params} />,
  249. };
  250. const docs: Docs = {
  251. onboarding,
  252. feedbackOnboardingNpm: feedbackOnboarding,
  253. replayOnboarding,
  254. crashReportOnboarding,
  255. profilingOnboarding,
  256. featureFlagOnboarding,
  257. };
  258. export default docs;