symfony.tsx 5.5 KB

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