rails.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {Fragment} from 'react';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {t, tct} from 'sentry/locale';
  6. // Configuration Start
  7. const introduction = (
  8. <Fragment>
  9. {t('In Rails, all uncaught exceptions will be automatically reported.')}
  10. {t('We support Rails 5 and newer.')}
  11. </Fragment>
  12. );
  13. export const steps = ({
  14. dsn,
  15. }: {
  16. dsn?: string;
  17. } = {}): LayoutProps['steps'] => [
  18. {
  19. type: StepType.INSTALL,
  20. description: (
  21. <p>
  22. {tct(
  23. 'Add [sentryRubyCode:sentry-ruby] and [sentryRailsCode:sentry-rails] to your [sentryGemfileCode:Gemfile]:',
  24. {
  25. sentryRubyCode: <code />,
  26. sentryRailsCode: <code />,
  27. sentryGemfileCode: <code />,
  28. }
  29. )}
  30. </p>
  31. ),
  32. configurations: [
  33. {
  34. language: 'ruby',
  35. code: `
  36. gem "sentry-ruby"
  37. gem "sentry-rails"
  38. `,
  39. },
  40. ],
  41. },
  42. {
  43. type: StepType.CONFIGURE,
  44. description: (
  45. <p>
  46. {tct('Initialize the SDK within your [code:config/initializers/sentry.rb]:', {
  47. code: <code />,
  48. })}
  49. </p>
  50. ),
  51. configurations: [
  52. {
  53. language: 'ruby',
  54. code: `
  55. Sentry.init do |config|
  56. config.dsn = '${dsn}'
  57. config.breadcrumbs_logger = [:active_support_logger, :http_logger]
  58. # Set traces_sample_rate to 1.0 to capture 100%
  59. # of transactions for performance monitoring.
  60. # We recommend adjusting this value in production.
  61. config.traces_sample_rate = 1.0
  62. # or
  63. config.traces_sampler = lambda do |context|
  64. true
  65. end
  66. end
  67. `,
  68. },
  69. ],
  70. },
  71. {
  72. title: t('Caveats'),
  73. description: (
  74. <p>
  75. {tct(
  76. 'Currently, custom exception applications [code:(config.exceptions_app)] are not supported. If you are using a custom exception app, you must manually integrate Sentry yourself.',
  77. {
  78. code: <code />,
  79. }
  80. )}
  81. </p>
  82. ),
  83. },
  84. ];
  85. // Configuration End
  86. export function GettingStartedWithRubyRails({dsn, ...props}: ModuleProps) {
  87. return <Layout steps={steps({dsn})} introduction={introduction} {...props} />;
  88. }
  89. export default GettingStartedWithRubyRails;