symfony.tsx 5.7 KB

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