nextjs.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import List from 'sentry/components/list/';
  5. import ListItem from 'sentry/components/list/listItem';
  6. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  7. import {
  8. Docs,
  9. DocsParams,
  10. OnboardingConfig,
  11. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  12. import TextCopyInput from 'sentry/components/textCopyInput';
  13. import {t, tct} from 'sentry/locale';
  14. import {space} from 'sentry/styles/space';
  15. import {trackAnalytics} from 'sentry/utils/analytics';
  16. type Params = DocsParams;
  17. const onboarding: OnboardingConfig = {
  18. install: (params: Params) => [
  19. {
  20. type: StepType.INSTALL,
  21. configurations: [
  22. {
  23. description: tct(
  24. 'Configure your app automatically with the [wizardLink:Sentry wizard].',
  25. {
  26. wizardLink: (
  27. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/nextjs/#install" />
  28. ),
  29. }
  30. ),
  31. language: 'bash',
  32. code: `npx @sentry/wizard@latest -i nextjs`,
  33. },
  34. ],
  35. additionalInfo: (
  36. <Fragment>
  37. {t(
  38. 'The Sentry wizard will automatically patch your application to configure the Sentry SDK:'
  39. )}
  40. <List symbol="bullet">
  41. <ListItem>
  42. {tct(
  43. 'Create [clientCode:sentry.client.config.js] and [serverCode:sentry.server.config.js] with the default [sentryInitCode:Sentry.init].',
  44. {
  45. clientCode: <code />,
  46. serverCode: <code />,
  47. sentryInitCode: <code />,
  48. }
  49. )}
  50. </ListItem>
  51. <ListItem>
  52. {tct(
  53. 'Create or update your Next.js config [nextConfig:next.config.js] with the default Sentry configuration.',
  54. {
  55. nextConfig: <code />,
  56. }
  57. )}
  58. </ListItem>
  59. <ListItem>
  60. {tct(
  61. 'Create [sentryClircCode:.sentryclirc] and [sentryPropertiesCode:sentry.properties] files with configuration for sentry-cli (which is used when automatically uploading source maps).',
  62. {
  63. sentryClircCode: <code />,
  64. sentryPropertiesCode: <code />,
  65. }
  66. )}
  67. </ListItem>
  68. <ListItem>
  69. {tct('Add an example page to your app to verify your Sentry setup.', {
  70. sentryClircCode: <code />,
  71. })}
  72. </ListItem>
  73. </List>
  74. <br />
  75. <ManualSetupTitle>{t('Manual Setup')}</ManualSetupTitle>
  76. <p>
  77. {tct(
  78. 'Alternatively, you can also [manualSetupLink:set up the SDK manually].',
  79. {
  80. manualSetupLink: (
  81. <ExternalLink href="https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/" />
  82. ),
  83. }
  84. )}
  85. </p>
  86. <br />
  87. <DSNText>
  88. <p>
  89. {tct(
  90. "If you already have the configuration for Sentry in your application, and just need this project's ([projectSlug]) DSN, you can find it below:",
  91. {
  92. projectSlug: <code>{params.projectSlug}</code>,
  93. }
  94. )}
  95. </p>
  96. </DSNText>
  97. {params.organization && (
  98. <TextCopyInput
  99. onCopy={() =>
  100. trackAnalytics('onboarding.nextjs-dsn-copied', {
  101. organization: params.organization,
  102. })
  103. }
  104. >
  105. {params.dsn}
  106. </TextCopyInput>
  107. )}
  108. </Fragment>
  109. ),
  110. },
  111. ],
  112. configure: () => [],
  113. verify: () => [],
  114. };
  115. const docs: Docs = {
  116. onboarding,
  117. };
  118. export default docs;
  119. const DSNText = styled('div')`
  120. margin-bottom: ${space(0.5)};
  121. `;
  122. const ManualSetupTitle = styled('p')`
  123. font-size: ${p => p.theme.fontSizeLarge};
  124. font-weight: bold;
  125. `;