python.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 {getPythonMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  13. import {t, tct} from 'sentry/locale';
  14. type Params = DocsParams;
  15. const getInstallSnippet = () => `pip install --upgrade sentry-sdk`;
  16. const getSdkSetupSnippet = (params: Params) => `
  17. import sentry_sdk
  18. sentry_sdk.init(
  19. dsn="${params.dsn}",${
  20. params.isPerformanceSelected
  21. ? `
  22. # Set traces_sample_rate to 1.0 to capture 100%
  23. # of transactions for performance monitoring.
  24. traces_sample_rate=1.0,`
  25. : ''
  26. }${
  27. params.isProfilingSelected
  28. ? `
  29. # Set profiles_sample_rate to 1.0 to profile 100%
  30. # of sampled transactions.
  31. # We recommend adjusting this value in production.
  32. profiles_sample_rate=1.0,`
  33. : ''
  34. }
  35. )`;
  36. const onboarding: OnboardingConfig = {
  37. install: () => [
  38. {
  39. type: StepType.INSTALL,
  40. description: tct('Install our Python SDK using [code:pip]:', {
  41. code: <code />,
  42. }),
  43. configurations: [
  44. {
  45. language: 'bash',
  46. code: getInstallSnippet(),
  47. },
  48. ],
  49. },
  50. ],
  51. configure: (params: Params) => [
  52. {
  53. type: StepType.CONFIGURE,
  54. description: t(
  55. "Import and initialize the Sentry SDK early in your application's setup:"
  56. ),
  57. configurations: [
  58. {
  59. language: 'python',
  60. code: getSdkSetupSnippet(params),
  61. },
  62. ],
  63. },
  64. ],
  65. verify: () => [
  66. {
  67. type: StepType.VERIFY,
  68. description: t(
  69. 'One way to verify your setup is by intentionally causing an error that breaks your application.'
  70. ),
  71. configurations: [
  72. {
  73. language: 'python',
  74. description: t(
  75. 'Raise an unhandled Python exception by inserting a divide by zero expression into your application:'
  76. ),
  77. code: 'division_by_zero = 1 / 0',
  78. },
  79. ],
  80. },
  81. ],
  82. };
  83. export const crashReportOnboardingPython: OnboardingConfig = {
  84. introduction: () => getCrashReportModalIntroduction(),
  85. install: (params: Params) => getCrashReportBackendInstallStep(params),
  86. configure: () => [
  87. {
  88. type: StepType.CONFIGURE,
  89. description: getCrashReportModalConfigDescription({
  90. link: 'https://docs.sentry.io/platforms/python/user-feedback/configuration/#crash-report-modal',
  91. }),
  92. },
  93. ],
  94. verify: () => [],
  95. nextSteps: () => [],
  96. };
  97. const docs: Docs = {
  98. onboarding,
  99. customMetricsOnboarding: getPythonMetricsOnboarding({
  100. installSnippet: getInstallSnippet(),
  101. }),
  102. crashReportOnboarding: crashReportOnboardingPython,
  103. };
  104. export default docs;