rails.tsx 2.2 KB

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