symfony.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 || params.isProfilingSelected
  84. ? `
  85. options:`
  86. : ''
  87. }${
  88. params.isPerformanceSelected
  89. ? `
  90. # Specify a fixed sample rate
  91. traces_sample_rate: 1.0`
  92. : ''
  93. }${
  94. params.isProfilingSelected
  95. ? `
  96. # Set a sampling rate for profiling - this is relative to traces_sample_rate
  97. profiles_sample_rate: 1.0`
  98. : ''
  99. }`,
  100. },
  101. ]
  102. : []),
  103. {
  104. description: (
  105. <Alert type="warning">
  106. {tct(
  107. 'In order to receive stack trace arguments in your errors, make sure to set [code:zend.exception_ignore_args: Off] in your php.ini',
  108. {
  109. code: <code />,
  110. }
  111. )}
  112. </Alert>
  113. ),
  114. },
  115. ],
  116. },
  117. ],
  118. verify: () => [
  119. {
  120. type: StepType.VERIFY,
  121. configurations: [
  122. {
  123. language: 'php',
  124. code: `
  125. <?php
  126. namespace App\\Controller;
  127. use Psr\\Log\\LoggerInterface;
  128. use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;
  129. use Symfony\\Component\\Routing\\Annotation\\Route;
  130. class SentryTestController extends AbstractController {
  131. /**
  132. * @var LoggerInterface
  133. */
  134. private $logger;
  135. public function __construct(LoggerInterface $logger)
  136. {
  137. $this->logger = $logger;
  138. }
  139. /**
  140. * @Route(name="sentry_test", path="/_sentry-test")
  141. */
  142. public function testLog()
  143. {
  144. // the following code will test if monolog integration logs to sentry
  145. $this->logger->error('My custom logged error.');
  146. // the following code will test if an uncaught exception logs to sentry
  147. throw new \\RuntimeException('Example exception.');
  148. }
  149. }
  150. `,
  151. },
  152. ],
  153. additionalInfo: tct(
  154. "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.",
  155. {sentryLink: <ExternalLink href="https://sentry.io" />, code: <code />}
  156. ),
  157. },
  158. ],
  159. nextSteps: () => [],
  160. };
  161. const crashReportOnboarding: OnboardingConfig = {
  162. introduction: () => getCrashReportModalIntroduction(),
  163. install: (params: Params) => getCrashReportPHPInstallStep(params),
  164. configure: () => [
  165. {
  166. type: StepType.CONFIGURE,
  167. description: getCrashReportModalConfigDescription({
  168. link: 'https://docs.sentry.io/platforms/php/guides/symfony/user-feedback/configuration/#crash-report-modal',
  169. }),
  170. },
  171. ],
  172. verify: () => [],
  173. nextSteps: () => [],
  174. };
  175. const docs: Docs = {
  176. onboarding,
  177. replayOnboardingJsLoader,
  178. crashReportOnboarding,
  179. };
  180. export default docs;