php.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. install: (params: Params) => [
  13. {
  14. type: StepType.INSTALL,
  15. description: tct(
  16. 'To install the PHP SDK, you need to be using Composer in your project. For more details about Composer, see the [composerDocumentationLink:Composer documentation].',
  17. {
  18. composerDocumentationLink: <ExternalLink href="https://getcomposer.org/doc/" />,
  19. }
  20. ),
  21. configurations: [
  22. {
  23. language: 'bash',
  24. code: 'composer require sentry/sdk',
  25. },
  26. ...(params.isProfilingSelected
  27. ? [
  28. {
  29. description: t('Install the Excimer extension via PECL:'),
  30. language: 'bash',
  31. code: 'pecl install excimer',
  32. },
  33. ]
  34. : []),
  35. ],
  36. },
  37. ],
  38. configure: (params: Params) => [
  39. {
  40. type: StepType.CONFIGURE,
  41. description: t(
  42. 'To capture all errors, even the one during the startup of your application, you should initialize the Sentry PHP SDK as soon as possible.'
  43. ),
  44. configurations: [
  45. {
  46. language: 'php',
  47. code: `\\Sentry\\init([
  48. 'dsn' => '${params.dsn}',${
  49. params.isPerformanceSelected
  50. ? `
  51. // Specify a fixed sample rate
  52. 'traces_sample_rate' => 1.0,`
  53. : ''
  54. }${
  55. params.isProfilingSelected
  56. ? `
  57. // Set a sampling rate for profiling - this is relative to traces_sample_rate
  58. 'profiles_sample_rate' => 1.0,`
  59. : ''
  60. }
  61. ]);`,
  62. additionalInfo: params.isPerformanceSelected && (
  63. <p>
  64. {tct(
  65. 'To instrument certain regions of your code, you can [instrumentationLink:create transactions to capture them].',
  66. {
  67. instrumentationLink: (
  68. <ExternalLink href="https://docs.sentry.io/platforms/php/performance/instrumentation/custom-instrumentation/" />
  69. ),
  70. }
  71. )}
  72. </p>
  73. ),
  74. },
  75. ],
  76. },
  77. ],
  78. verify: () => [
  79. {
  80. type: StepType.VERIFY,
  81. description: t(
  82. 'In PHP you can either capture a caught exception or capture the last error with captureLastError.'
  83. ),
  84. configurations: [
  85. {
  86. language: 'php',
  87. code: `
  88. try {
  89. $this->functionFailsForSure();
  90. } catch (\\Throwable $exception) {
  91. \\Sentry\\captureException($exception);
  92. }`,
  93. },
  94. ],
  95. },
  96. ],
  97. nextSteps: () => [],
  98. };
  99. const docs: Docs = {
  100. onboarding,
  101. replayOnboardingJsLoader,
  102. };
  103. export default docs;