rails.tsx 2.4 KB

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