symfony.tsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import {Alert} from 'sentry/components/core/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.Container>
  109. <Alert type="warning">
  110. {tct(
  111. 'In order to receive stack trace arguments in your errors, make sure to set [code:zend.exception_ignore_args: Off] in your php.ini',
  112. {
  113. code: <code />,
  114. }
  115. )}
  116. </Alert>
  117. </Alert.Container>
  118. ),
  119. },
  120. ],
  121. },
  122. ],
  123. verify: () => [
  124. {
  125. type: StepType.VERIFY,
  126. configurations: [
  127. {
  128. language: 'php',
  129. code: `
  130. <?php
  131. namespace App\\Controller;
  132. use Psr\\Log\\LoggerInterface;
  133. use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;
  134. use Symfony\\Component\\Routing\\Annotation\\Route;
  135. class SentryTestController extends AbstractController {
  136. /**
  137. * @var LoggerInterface
  138. */
  139. private $logger;
  140. public function __construct(LoggerInterface $logger)
  141. {
  142. $this->logger = $logger;
  143. }
  144. /**
  145. * @Route(name="sentry_test", path="/_sentry-test")
  146. */
  147. public function testLog()
  148. {
  149. // the following code will test if monolog integration logs to sentry
  150. $this->logger->error('My custom logged error.');
  151. // the following code will test if an uncaught exception logs to sentry
  152. throw new \\RuntimeException('Example exception.');
  153. }
  154. }
  155. `,
  156. },
  157. ],
  158. additionalInfo: tct(
  159. "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.",
  160. {sentryLink: <ExternalLink href="https://sentry.io" />, code: <code />}
  161. ),
  162. },
  163. ],
  164. nextSteps: () => [],
  165. };
  166. const crashReportOnboarding: OnboardingConfig = {
  167. introduction: () => getCrashReportModalIntroduction(),
  168. install: (params: Params) => getCrashReportPHPInstallStep(params),
  169. configure: () => [
  170. {
  171. type: StepType.CONFIGURE,
  172. description: getCrashReportModalConfigDescription({
  173. link: 'https://docs.sentry.io/platforms/php/guides/symfony/user-feedback/configuration/#crash-report-modal',
  174. }),
  175. },
  176. ],
  177. verify: () => [],
  178. nextSteps: () => [],
  179. };
  180. const docs: Docs = {
  181. onboarding,
  182. replayOnboardingJsLoader,
  183. crashReportOnboarding,
  184. feedbackOnboardingJsLoader,
  185. };
  186. export default docs;