ruby.tsx 2.1 KB

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