rack.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  2. import type {
  3. Docs,
  4. DocsParams,
  5. OnboardingConfig,
  6. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import {CrashReportWebApiOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  8. import {getRubyMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  9. import {tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const getConfigureSnippet = (params: Params) => `
  12. require 'sentry-ruby'
  13. Sentry.init do |config|
  14. config.dsn = '${params.dsn}'
  15. # Set traces_sample_rate to 1.0 to capture 100%
  16. # of transactions for performance monitoring.
  17. # We recommend adjusting this value in production.
  18. config.traces_sample_rate = 1.0
  19. # or
  20. config.traces_sampler = lambda do |context|
  21. true
  22. end
  23. end
  24. use Sentry::Rack::CaptureExceptions`;
  25. const onboarding: OnboardingConfig = {
  26. install: () => [
  27. {
  28. type: StepType.INSTALL,
  29. description: tct(
  30. 'Install the SDK via Rubygems by adding it to your [code:Gemfile]:',
  31. {
  32. code: <code />,
  33. }
  34. ),
  35. configurations: [
  36. {
  37. language: 'ruby',
  38. code: `gem "sentry-ruby"`,
  39. },
  40. ],
  41. },
  42. ],
  43. configure: params => [
  44. {
  45. type: StepType.CONFIGURE,
  46. description: tct(
  47. 'Add use [sentryRackCode:Sentry::Rack::CaptureExceptions] to your [sentryConfigCode:config.ru] or other rackup file (this is automatically inserted in Rails):',
  48. {
  49. sentryRackCode: <code />,
  50. sentryConfigCode: <code />,
  51. }
  52. ),
  53. configurations: [
  54. {
  55. language: 'ruby',
  56. code: getConfigureSnippet(params),
  57. },
  58. ],
  59. },
  60. ],
  61. verify: () => [],
  62. };
  63. const docs: Docs = {
  64. onboarding,
  65. customMetricsOnboarding: getRubyMetricsOnboarding(),
  66. crashReportOnboarding: CrashReportWebApiOnboarding,
  67. };
  68. export default docs;