python.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.public}",${
  20. params.isPerformanceSelected
  21. ? `
  22. # Set traces_sample_rate to 1.0 to capture 100%
  23. # of transactions for tracing.
  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: (params: Params) => [
  38. {
  39. type: StepType.INSTALL,
  40. description: tct('Install our Python SDK using [code:pip]:', {
  41. code: <code />,
  42. }),
  43. configurations: [
  44. {
  45. description: params.isProfilingSelected
  46. ? tct(
  47. 'You need a minimum version [codeVersion:1.18.0] of the [codePackage:sentry-python] SDK for the profiling feature.',
  48. {
  49. codeVersion: <code />,
  50. codePackage: <code />,
  51. }
  52. )
  53. : undefined,
  54. language: 'bash',
  55. code: getInstallSnippet(),
  56. },
  57. ],
  58. },
  59. ],
  60. configure: (params: Params) => [
  61. {
  62. type: StepType.CONFIGURE,
  63. description: t(
  64. "Import and initialize the Sentry SDK early in your application's setup:"
  65. ),
  66. configurations: [
  67. {
  68. language: 'python',
  69. code: getSdkSetupSnippet(params),
  70. },
  71. ],
  72. },
  73. ],
  74. verify: () => [
  75. {
  76. type: StepType.VERIFY,
  77. description: t(
  78. 'One way to verify your setup is by intentionally causing an error that breaks your application.'
  79. ),
  80. configurations: [
  81. {
  82. language: 'python',
  83. description: t(
  84. 'Raise an unhandled Python exception by inserting a divide by zero expression into your application:'
  85. ),
  86. code: 'division_by_zero = 1 / 0',
  87. },
  88. ],
  89. },
  90. ],
  91. };
  92. export const crashReportOnboardingPython: OnboardingConfig = {
  93. introduction: () => getCrashReportModalIntroduction(),
  94. install: (params: Params) => getCrashReportBackendInstallStep(params),
  95. configure: () => [
  96. {
  97. type: StepType.CONFIGURE,
  98. description: getCrashReportModalConfigDescription({
  99. link: 'https://docs.sentry.io/platforms/python/user-feedback/configuration/#crash-report-modal',
  100. }),
  101. },
  102. ],
  103. verify: () => [],
  104. nextSteps: () => [],
  105. };
  106. const docs: Docs = {
  107. onboarding,
  108. customMetricsOnboarding: getPythonMetricsOnboarding({
  109. installSnippet: getInstallSnippet(),
  110. }),
  111. crashReportOnboarding: crashReportOnboardingPython,
  112. };
  113. export default docs;