symfony.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import type {
  4. Docs,
  5. DocsParams,
  6. OnboardingConfig,
  7. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  8. import {
  9. getCrashReportModalConfigDescription,
  10. getCrashReportModalIntroduction,
  11. getCrashReportPHPInstallStep,
  12. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  13. import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  14. import {t, tct} from 'sentry/locale';
  15. type Params = DocsParams;
  16. const onboarding: OnboardingConfig = {
  17. introduction: () =>
  18. tct(
  19. 'Symfony is supported via the [code:sentry-symfony] package as a native bundle.',
  20. {code: <code />}
  21. ),
  22. install: (params: Params) => [
  23. {
  24. type: StepType.INSTALL,
  25. configurations: [
  26. {
  27. language: 'bash',
  28. description: (
  29. <p>
  30. {tct('Install the [code:sentry/sentry-symfony] bundle:', {code: <code />})}
  31. </p>
  32. ),
  33. code: 'composer require sentry/sentry-symfony',
  34. },
  35. ...(params.isProfilingSelected
  36. ? [
  37. {
  38. description: t('Install the Excimer extension via PECL:'),
  39. language: 'bash',
  40. code: 'pecl install excimer',
  41. },
  42. ]
  43. : []),
  44. ],
  45. },
  46. ],
  47. configure: (params: Params) => [
  48. {
  49. type: StepType.CONFIGURE,
  50. configurations: [
  51. {
  52. description: (
  53. <p>{tct('Add your DSN to your [code:.env] file:', {code: <code />})}</p>
  54. ),
  55. language: 'shell',
  56. code: `
  57. ###> sentry/sentry-symfony ###
  58. SENTRY_DSN="${params.dsn}"
  59. ###< sentry/sentry-symfony ###
  60. `,
  61. },
  62. ...(params.isPerformanceSelected || params.isProfilingSelected
  63. ? [
  64. {
  65. description: (
  66. <p>
  67. {tct(
  68. 'Add further configuration options to your [code:config/packages/sentry.yaml] file:',
  69. {code: <code />}
  70. )}
  71. </p>
  72. ),
  73. language: 'yaml',
  74. code: `when@prod:
  75. sentry:
  76. dsn: '%env(SENTRY_DSN)%'${
  77. params.isPerformanceSelected
  78. ? `
  79. # Specify a fixed sample rate
  80. traces_sample_rate: 1.0`
  81. : ''
  82. }${
  83. params.isProfilingSelected
  84. ? `
  85. # Set a sampling rate for profiling - this is relative to traces_sample_rate
  86. profiles_sample_rate: 1.0`
  87. : ''
  88. }`,
  89. },
  90. ]
  91. : []),
  92. ],
  93. },
  94. ],
  95. verify: () => [
  96. {
  97. type: StepType.VERIFY,
  98. configurations: [
  99. {
  100. language: 'php',
  101. code: `
  102. <?php
  103. namespace App\\Controller;
  104. use Psr\\Log\\LoggerInterface;
  105. use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;
  106. use Symfony\\Component\\Routing\\Annotation\\Route;
  107. class SentryTestController extends AbstractController {
  108. /**
  109. * @var LoggerInterface
  110. */
  111. private $logger;
  112. public function __construct(LoggerInterface $logger)
  113. {
  114. $this->logger = $logger;
  115. }
  116. /**
  117. * @Route(name="sentry_test", path="/_sentry-test")
  118. */
  119. public function testLog()
  120. {
  121. // the following code will test if monolog integration logs to sentry
  122. $this->logger->error('My custom logged error.');
  123. // the following code will test if an uncaught exception logs to sentry
  124. throw new \\RuntimeException('Example exception.');
  125. }
  126. }
  127. `,
  128. },
  129. ],
  130. additionalInfo: (
  131. <p>
  132. {tct(
  133. "After you visit the [code:/_sentry-test page], you can view and resolve the recorded error by logging into [sentryLink:sentry.io] and opening your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.",
  134. {sentryLink: <ExternalLink href="https://sentry.io" />, code: <code />}
  135. )}
  136. </p>
  137. ),
  138. },
  139. ],
  140. nextSteps: () => [],
  141. };
  142. const crashReportOnboarding: OnboardingConfig = {
  143. introduction: () => getCrashReportModalIntroduction(),
  144. install: (params: Params) => getCrashReportPHPInstallStep(params),
  145. configure: () => [
  146. {
  147. type: StepType.CONFIGURE,
  148. description: getCrashReportModalConfigDescription({
  149. link: 'https://docs.sentry.io/platforms/php/guides/symfony/user-feedback/configuration/#crash-report-modal',
  150. }),
  151. },
  152. ],
  153. verify: () => [],
  154. nextSteps: () => [],
  155. };
  156. const docs: Docs = {
  157. onboarding,
  158. replayOnboardingJsLoader,
  159. crashReportOnboarding,
  160. };
  161. export default docs;