ruby.tsx 2.3 KB

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