rust.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 {
  8. getCrashReportBackendInstallStep,
  9. getCrashReportModalConfigDescription,
  10. getCrashReportModalIntroduction,
  11. } from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
  12. import {t, tct} from 'sentry/locale';
  13. import {getPackageVersion} from 'sentry/utils/gettingStartedDocs/getPackageVersion';
  14. type Params = DocsParams;
  15. const getInstallSnippet = (params: Params) => `
  16. [dependencies]
  17. sentry = "${getPackageVersion(params, 'sentry.rust', '0.32.1')}"`;
  18. const getConfigureSnippet = (params: Params) => `
  19. let _guard = sentry::init(("${params.dsn.public}", sentry::ClientOptions {
  20. release: sentry::release_name!(),
  21. ..Default::default()
  22. }));`;
  23. const getVerifySnippet = (params: Params) => `
  24. fn main() {
  25. let _guard = sentry::init(("${params.dsn.public}", sentry::ClientOptions {
  26. release: sentry::release_name!(),
  27. ..Default::default()
  28. }));
  29. // Sentry will capture this
  30. panic!("Everything is on fire!");
  31. }`;
  32. const onboarding: OnboardingConfig = {
  33. install: params => [
  34. {
  35. type: StepType.INSTALL,
  36. description: tct(
  37. 'To add Sentry to your Rust project you just need to add a new dependency to your [code:Cargo.toml]:',
  38. {code: <code />}
  39. ),
  40. configurations: [
  41. {
  42. language: 'toml',
  43. partialLoading: params.sourcePackageRegistries.isLoading,
  44. code: getInstallSnippet(params),
  45. },
  46. ],
  47. },
  48. ],
  49. configure: params => [
  50. {
  51. type: StepType.CONFIGURE,
  52. description: tct(
  53. '[code:Sentry.init()] will return you a guard that when freed, will prevent process exit until all events have been sent (within a timeout):',
  54. {code: <code />}
  55. ),
  56. configurations: [
  57. {
  58. language: 'rust',
  59. code: getConfigureSnippet(params),
  60. },
  61. ],
  62. },
  63. ],
  64. verify: params => [
  65. {
  66. type: StepType.VERIFY,
  67. description: t(
  68. 'The quickest way to verify Sentry in your Rust application is to cause a panic:'
  69. ),
  70. configurations: [
  71. {
  72. language: 'rust',
  73. code: getVerifySnippet(params),
  74. },
  75. ],
  76. },
  77. ],
  78. };
  79. const crashReportOnboarding: OnboardingConfig = {
  80. introduction: () => getCrashReportModalIntroduction(),
  81. install: (params: Params) => getCrashReportBackendInstallStep(params),
  82. configure: () => [
  83. {
  84. type: StepType.CONFIGURE,
  85. description: getCrashReportModalConfigDescription({
  86. link: 'https://docs.sentry.io/platforms/rust/user-feedback/configuration/#crash-report-modal',
  87. }),
  88. },
  89. ],
  90. verify: () => [],
  91. nextSteps: () => [],
  92. };
  93. const docs: Docs = {
  94. onboarding,
  95. crashReportOnboarding,
  96. };
  97. export default docs;