symfony.tsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. description: tct(
  44. "The Excimer PHP extension supports PHP 7.2 and up. Excimer requires Linux or macOS and doesn't support Windows. For additional ways to install Excimer, see [sentryPhpDocumentationLink: Sentry documentation].",
  45. {
  46. sentryPhpDocumentationLink: (
  47. <ExternalLink href="https://docs.sentry.io/platforms/php/profiling/#installation" />
  48. ),
  49. }
  50. ),
  51. },
  52. ]
  53. : []),
  54. ],
  55. },
  56. ],
  57. configure: (params: Params) => [
  58. {
  59. type: StepType.CONFIGURE,
  60. configurations: [
  61. {
  62. description: (
  63. <p>{tct('Add your DSN to your [code:.env] file:', {code: <code />})}</p>
  64. ),
  65. language: 'shell',
  66. code: `
  67. ###> sentry/sentry-symfony ###
  68. SENTRY_DSN="${params.dsn.public}"
  69. ###< sentry/sentry-symfony ###
  70. `,
  71. },
  72. ...(params.isPerformanceSelected || params.isProfilingSelected
  73. ? [
  74. {
  75. description: (
  76. <p>
  77. {tct(
  78. 'Add further configuration options to your [code:config/packages/sentry.yaml] file:',
  79. {code: <code />}
  80. )}
  81. </p>
  82. ),
  83. language: 'yaml',
  84. code: `when@prod:
  85. sentry:
  86. dsn: '%env(SENTRY_DSN)%'${
  87. params.isPerformanceSelected
  88. ? `
  89. # Specify a fixed sample rate
  90. traces_sample_rate: 1.0`
  91. : ''
  92. }${
  93. params.isProfilingSelected
  94. ? `
  95. # Set a sampling rate for profiling - this is relative to traces_sample_rate
  96. profiles_sample_rate: 1.0`
  97. : ''
  98. }`,
  99. },
  100. ]
  101. : []),
  102. ],
  103. },
  104. ],
  105. verify: () => [
  106. {
  107. type: StepType.VERIFY,
  108. configurations: [
  109. {
  110. language: 'php',
  111. code: `
  112. <?php
  113. namespace App\\Controller;
  114. use Psr\\Log\\LoggerInterface;
  115. use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;
  116. use Symfony\\Component\\Routing\\Annotation\\Route;
  117. class SentryTestController extends AbstractController {
  118. /**
  119. * @var LoggerInterface
  120. */
  121. private $logger;
  122. public function __construct(LoggerInterface $logger)
  123. {
  124. $this->logger = $logger;
  125. }
  126. /**
  127. * @Route(name="sentry_test", path="/_sentry-test")
  128. */
  129. public function testLog()
  130. {
  131. // the following code will test if monolog integration logs to sentry
  132. $this->logger->error('My custom logged error.');
  133. // the following code will test if an uncaught exception logs to sentry
  134. throw new \\RuntimeException('Example exception.');
  135. }
  136. }
  137. `,
  138. },
  139. ],
  140. additionalInfo: (
  141. <p>
  142. {tct(
  143. "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.",
  144. {sentryLink: <ExternalLink href="https://sentry.io" />, code: <code />}
  145. )}
  146. </p>
  147. ),
  148. },
  149. ],
  150. nextSteps: () => [],
  151. };
  152. const crashReportOnboarding: OnboardingConfig = {
  153. introduction: () => getCrashReportModalIntroduction(),
  154. install: (params: Params) => getCrashReportPHPInstallStep(params),
  155. configure: () => [
  156. {
  157. type: StepType.CONFIGURE,
  158. description: getCrashReportModalConfigDescription({
  159. link: 'https://docs.sentry.io/platforms/php/guides/symfony/user-feedback/configuration/#crash-report-modal',
  160. }),
  161. },
  162. ],
  163. verify: () => [],
  164. nextSteps: () => [],
  165. };
  166. const docs: Docs = {
  167. onboarding,
  168. replayOnboardingJsLoader,
  169. crashReportOnboarding,
  170. };
  171. export default docs;