symfony.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import {
  4. Docs,
  5. DocsParams,
  6. OnboardingConfig,
  7. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  8. import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  9. import {t, tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const onboarding: OnboardingConfig = {
  12. introduction: () =>
  13. tct(
  14. 'Symfony is supported via the [code:sentry-symfony] package as a native bundle.',
  15. {code: <code />}
  16. ),
  17. install: (params: Params) => [
  18. {
  19. type: StepType.INSTALL,
  20. configurations: [
  21. {
  22. language: 'bash',
  23. description: (
  24. <p>
  25. {tct('Install the [code:sentry/sentry-symfony] bundle:', {code: <code />})}
  26. </p>
  27. ),
  28. code: 'composer require sentry/sentry-symfony',
  29. },
  30. ...(params.isProfilingSelected
  31. ? [
  32. {
  33. description: t('Install the Excimer extension via PECL:'),
  34. language: 'bash',
  35. code: 'pecl install excimer',
  36. },
  37. ]
  38. : []),
  39. ],
  40. },
  41. ],
  42. configure: (params: Params) => [
  43. {
  44. type: StepType.CONFIGURE,
  45. configurations: [
  46. {
  47. description: (
  48. <p>{tct('Add your DSN to your [code:.env] file:', {code: <code />})}</p>
  49. ),
  50. language: 'shell',
  51. code: `
  52. ###> sentry/sentry-symfony ###
  53. SENTRY_DSN="${params.dsn}"
  54. ###< sentry/sentry-symfony ###
  55. `,
  56. },
  57. ...(params.isPerformanceSelected || params.isProfilingSelected
  58. ? [
  59. {
  60. description: (
  61. <p>
  62. {tct(
  63. 'Add further configuration options to your [code:config/packages/sentry.yaml] file:',
  64. {code: <code />}
  65. )}
  66. </p>
  67. ),
  68. language: 'yaml',
  69. code: `when@prod:
  70. sentry:
  71. dsn: '%env(SENTRY_DSN)%'${
  72. params.isPerformanceSelected
  73. ? `
  74. # Specify a fixed sample rate
  75. traces_sample_rate: 1.0`
  76. : ''
  77. }${
  78. params.isProfilingSelected
  79. ? `
  80. # Set a sampling rate for profiling - this is relative to traces_sample_rate
  81. profiles_sample_rate: 1.0`
  82. : ''
  83. }`,
  84. },
  85. ]
  86. : []),
  87. ],
  88. },
  89. ],
  90. verify: () => [
  91. {
  92. type: StepType.VERIFY,
  93. configurations: [
  94. {
  95. language: 'php',
  96. code: `
  97. <?php
  98. namespace App\\Controller;
  99. use Psr\\Log\\LoggerInterface;
  100. use Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;
  101. use Symfony\\Component\\Routing\\Annotation\\Route;
  102. class SentryTestController extends AbstractController {
  103. /**
  104. * @var LoggerInterface
  105. */
  106. private $logger;
  107. public function __construct(LoggerInterface $logger)
  108. {
  109. $this->logger = $logger;
  110. }
  111. /**
  112. * @Route(name="sentry_test", path="/_sentry-test")
  113. */
  114. public function testLog()
  115. {
  116. // the following code will test if monolog integration logs to sentry
  117. $this->logger->error('My custom logged error.');
  118. // the following code will test if an uncaught exception logs to sentry
  119. throw new \\RuntimeException('Example exception.');
  120. }
  121. }
  122. `,
  123. },
  124. ],
  125. additionalInfo: (
  126. <p>
  127. {tct(
  128. "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.",
  129. {sentryLink: <ExternalLink href="https://sentry.io" />, code: <code />}
  130. )}
  131. </p>
  132. ),
  133. },
  134. ],
  135. nextSteps: () => [],
  136. };
  137. const docs: Docs = {
  138. onboarding,
  139. replayOnboardingJsLoader,
  140. };
  141. export default docs;