ruby.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  2. import type {
  3. Docs,
  4. DocsParams,
  5. OnboardingConfig,
  6. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import {CrashReportWebApiOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  8. import {getRubyMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  9. import {t, tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const getConfigureSnippet = (params: Params) => `
  12. Sentry.init do |config|
  13. config.dsn = '${params.dsn}'
  14. # Set traces_sample_rate to 1.0 to capture 100%
  15. # of transactions for performance monitoring.
  16. # We recommend adjusting this value in production.
  17. config.traces_sample_rate = 1.0
  18. # or
  19. config.traces_sampler = lambda do |context|
  20. true
  21. end
  22. end`;
  23. const getVerifySnippet = () => `
  24. begin
  25. 1 / 0
  26. rescue ZeroDivisionError => exception
  27. Sentry.capture_exception(exception)
  28. end
  29. Sentry.capture_message("test message")`;
  30. const onboarding: OnboardingConfig = {
  31. install: () => [
  32. {
  33. type: StepType.INSTALL,
  34. description: tct(
  35. 'Sentry Ruby comes as a gem and is straightforward to install. If you are using Bundler just add this to your [code:Gemfile]:',
  36. {code: <code />}
  37. ),
  38. configurations: [
  39. {
  40. language: 'ruby',
  41. code: 'gem "sentry-ruby"',
  42. },
  43. ],
  44. },
  45. ],
  46. configure: params => [
  47. {
  48. type: StepType.CONFIGURE,
  49. description: tct(
  50. '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]:',
  51. {sentryDSN: <code />, sentryInit: <code />}
  52. ),
  53. configurations: [
  54. {
  55. language: 'ruby',
  56. code: getConfigureSnippet(params),
  57. },
  58. ],
  59. },
  60. ],
  61. verify: () => [
  62. {
  63. type: StepType.VERIFY,
  64. description: t('You can then report errors or messages to Sentry:'),
  65. configurations: [
  66. {
  67. language: 'ruby',
  68. code: getVerifySnippet(),
  69. },
  70. ],
  71. },
  72. ],
  73. };
  74. const docs: Docs = {
  75. onboarding,
  76. customMetricsOnboarding: getRubyMetricsOnboarding(),
  77. crashReportOnboarding: CrashReportWebApiOnboarding,
  78. };
  79. export default docs;