laravel.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. 'This guide is for Laravel 8+. We also provide instructions for [otherVersionsLink:other versions] as well as [lumenSpecificLink:Lumen-specific instructions].',
  15. {
  16. otherVersionsLink: (
  17. <ExternalLink href="https://docs.sentry.io/platforms/php/guides/laravel/other-versions/" />
  18. ),
  19. lumenSpecificLink: (
  20. <ExternalLink href="https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen/" />
  21. ),
  22. }
  23. ),
  24. install: (params: Params) => [
  25. {
  26. type: StepType.INSTALL,
  27. configurations: [
  28. {
  29. description: (
  30. <p>
  31. {tct('Install the [code:sentry/sentry-laravel] package:', {
  32. code: <code />,
  33. })}
  34. </p>
  35. ),
  36. language: 'bash',
  37. code: `composer require sentry/sentry-laravel`,
  38. },
  39. ...(params.isProfilingSelected
  40. ? [
  41. {
  42. description: t('Install the Excimer extension via PECL:'),
  43. language: 'bash',
  44. code: 'pecl install excimer',
  45. },
  46. ]
  47. : []),
  48. {
  49. description: (
  50. <p>
  51. {tct(
  52. 'Enable capturing unhandled exception to report to Sentry by making the following change to your [code:App/Exceptions/Handler.php]:',
  53. {
  54. code: <code />,
  55. }
  56. )}
  57. </p>
  58. ),
  59. language: 'php',
  60. code: `
  61. public function register() {
  62. $this->reportable(function (Throwable $e) {
  63. if (app()->bound('sentry')) {
  64. app('sentry')->captureException($e);
  65. }
  66. });
  67. }
  68. `,
  69. },
  70. ],
  71. },
  72. ],
  73. configure: (params: Params) => [
  74. {
  75. type: StepType.CONFIGURE,
  76. configurations: [
  77. {
  78. description: t('Configure the Sentry DSN with this command:'),
  79. language: 'shell',
  80. code: `php artisan sentry:publish --dsn=${params.dsn}`,
  81. },
  82. {
  83. description: (
  84. <p>
  85. {tct(
  86. 'It creates the config file ([sentryPHPCode:config/sentry.php]) and adds the [dsnCode:DSN] to your [envCode:.env] file where you can add further configuration options:',
  87. {sentryPHPCode: <code />, dsnCode: <code />, envCode: <code />}
  88. )}
  89. </p>
  90. ),
  91. language: 'shell',
  92. code: `SENTRY_LARAVEL_DSN=${params.dsn}${
  93. params.isPerformanceSelected
  94. ? `
  95. # Specify a fixed sample rate
  96. SENTRY_TRACES_SAMPLE_RATE=1.0`
  97. : ''
  98. }${
  99. params.isProfilingSelected
  100. ? `
  101. # Set a sampling rate for profiling - this is relative to traces_sample_rate
  102. SENTRY_PROFILES_SAMPLE_RATE=1.0`
  103. : ''
  104. }`,
  105. },
  106. ],
  107. },
  108. ],
  109. verify: () => [
  110. {
  111. type: StepType.VERIFY,
  112. configurations: [
  113. {
  114. description: (
  115. <p>
  116. {tct(
  117. 'You can test your configuration using the provided [code:sentry:test] artisan command:',
  118. {
  119. code: <code />,
  120. }
  121. )}
  122. </p>
  123. ),
  124. language: 'shell',
  125. code: 'php artisan sentry:test',
  126. },
  127. ],
  128. },
  129. ],
  130. nextSteps: () => [],
  131. };
  132. const docs: Docs = {
  133. onboarding,
  134. replayOnboardingJsLoader,
  135. };
  136. export default docs;