ruby.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. }: {
  9. dsn?: string;
  10. } = {}): LayoutProps['steps'] => [
  11. {
  12. type: StepType.INSTALL,
  13. description: (
  14. <p>
  15. {tct(
  16. 'Sentry Ruby comes as a gem and is straightforward to install. If you are using Bundler just add this to your [code:Gemfile]:',
  17. {code: <code />}
  18. )}
  19. </p>
  20. ),
  21. configurations: [
  22. {
  23. language: 'ruby',
  24. code: 'gem "sentry-ruby"',
  25. },
  26. ],
  27. },
  28. {
  29. type: StepType.CONFIGURE,
  30. description: (
  31. <p>
  32. {tct(
  33. '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]:',
  34. {sentryDSN: <code />, sentryInit: <code />}
  35. )}
  36. </p>
  37. ),
  38. configurations: [
  39. {
  40. language: 'ruby',
  41. code: `
  42. Sentry.init do |config|
  43. config.dsn = '${dsn}'
  44. # Set traces_sample_rate to 1.0 to capture 100%
  45. # of transactions for performance monitoring.
  46. # We recommend adjusting this value in production.
  47. config.traces_sample_rate = 1.0
  48. # or
  49. config.traces_sampler = lambda do |context|
  50. true
  51. end
  52. end
  53. `,
  54. },
  55. ],
  56. },
  57. {
  58. type: StepType.VERIFY,
  59. description: t('You can then report errors or messages to Sentry:'),
  60. configurations: [
  61. {
  62. language: 'ruby',
  63. code: `
  64. begin
  65. 1 / 0
  66. rescue ZeroDivisionError => exception
  67. Sentry.capture_exception(exception)
  68. end
  69. Sentry.capture_message("test message")
  70. `,
  71. },
  72. ],
  73. },
  74. ];
  75. // Configuration End
  76. export function GettingStartedWithRuby({dsn, ...props}: ModuleProps) {
  77. return <Layout steps={steps({dsn})} {...props} />;
  78. }
  79. export default GettingStartedWithRuby;