symfony.tsx 5.5 KB

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