ruby.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  2. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  3. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  4. import {t, tct} from 'sentry/locale';
  5. // Configuration Start
  6. export const steps = ({
  7. dsn,
  8. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  9. {
  10. type: StepType.INSTALL,
  11. description: (
  12. <p>
  13. {tct(
  14. 'Sentry Ruby comes as a gem and is straightforward to install. If you are using Bundler just add this to your [code:Gemfile]:',
  15. {code: <code />}
  16. )}
  17. </p>
  18. ),
  19. configurations: [
  20. {
  21. language: 'ruby',
  22. code: 'gem "sentry-ruby"',
  23. },
  24. ],
  25. },
  26. {
  27. type: StepType.CONFIGURE,
  28. description: (
  29. <p>
  30. {tct(
  31. 'To use Sentry Ruby all you need is your DSN. Like most Sentry libraries it will honor the [sentryDSN:SENTRY_DSN] environment variable. You can find it on the project settings page under API Keys. You can either export it as environment variable or manually configure it with [sentryInit:Sentry.init]:',
  32. {sentryDSN: <code />, sentryInit: <code />}
  33. )}
  34. </p>
  35. ),
  36. configurations: [
  37. {
  38. language: 'ruby',
  39. code: `
  40. Sentry.init do |config|
  41. config.dsn = '${dsn}'
  42. # Set traces_sample_rate to 1.0 to capture 100%
  43. # of transactions for performance monitoring.
  44. # We recommend adjusting this value in production.
  45. config.traces_sample_rate = 1.0
  46. # or
  47. config.traces_sampler = lambda do |context|
  48. true
  49. end
  50. end
  51. `,
  52. },
  53. ],
  54. },
  55. {
  56. type: StepType.VERIFY,
  57. description: t('You can then report errors or messages to Sentry:'),
  58. configurations: [
  59. {
  60. language: 'ruby',
  61. code: `
  62. begin
  63. 1 / 0
  64. rescue ZeroDivisionError => exception
  65. Sentry.capture_exception(exception)
  66. end
  67. Sentry.capture_message("test message")
  68. `,
  69. },
  70. ],
  71. },
  72. ];
  73. // Configuration End
  74. export function GettingStartedWithRuby({dsn, ...props}: ModuleProps) {
  75. return <Layout steps={steps({dsn})} {...props} />;
  76. }
  77. export default GettingStartedWithRuby;