quart.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import type {
  4. Docs,
  5. DocsParams,
  6. OnboardingConfig,
  7. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  8. import {getPythonMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  9. import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  10. import {crashReportOnboardingPython} from 'sentry/gettingStartedDocs/python/python';
  11. import {t, tct} from 'sentry/locale';
  12. type Params = DocsParams;
  13. const getInstallSnippet = () => `pip install --upgrade 'sentry-sdk[quart]'`;
  14. const getSdkSetupSnippet = (params: Params) => `
  15. import sentry_sdk
  16. from sentry_sdk.integrations.quart import QuartIntegration
  17. from quart import Quart
  18. sentry_sdk.init(
  19. dsn="${params.dsn}",
  20. integrations=[QuartIntegration()],${
  21. params.isPerformanceSelected
  22. ? `
  23. # Set traces_sample_rate to 1.0 to capture 100%
  24. # of transactions for performance monitoring.
  25. traces_sample_rate=1.0,`
  26. : ''
  27. }${
  28. params.isProfilingSelected
  29. ? `
  30. # Set profiles_sample_rate to 1.0 to profile 100%
  31. # of sampled transactions.
  32. # We recommend adjusting this value in production.
  33. profiles_sample_rate=1.0,`
  34. : ''
  35. }
  36. )
  37. `;
  38. const onboarding: OnboardingConfig = {
  39. introduction: () =>
  40. tct('The Quart integration adds support for the [link:Quart Web Framework].', {
  41. link: <ExternalLink href="https://quart.palletsprojects.com/" />,
  42. }),
  43. install: (params: Params) => [
  44. {
  45. type: StepType.INSTALL,
  46. description: tct(
  47. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [sentryQuartCode:quart] extra:',
  48. {
  49. sentrySdkCode: <code />,
  50. sentryQuartCode: <code />,
  51. }
  52. ),
  53. configurations: [
  54. {
  55. description: params.isProfilingSelected
  56. ? tct(
  57. 'You need a minimum version [codeVersion:1.18.0] of the [codePackage:sentry-python] SDK for the profiling feature.',
  58. {
  59. codeVersion: <code />,
  60. codePackage: <code />,
  61. }
  62. )
  63. : undefined,
  64. language: 'bash',
  65. code: getInstallSnippet(),
  66. },
  67. ],
  68. },
  69. ],
  70. configure: (params: Params) => [
  71. {
  72. type: StepType.CONFIGURE,
  73. description: t(
  74. 'To configure the SDK, initialize it with the integration before or after your app has been initialized:'
  75. ),
  76. configurations: [
  77. {
  78. language: 'python',
  79. code: `
  80. ${getSdkSetupSnippet(params)}
  81. app = Quart(__name__)
  82. `,
  83. },
  84. ],
  85. },
  86. ],
  87. verify: (params: Params) => [
  88. {
  89. type: StepType.VERIFY,
  90. description: t(
  91. 'You can easily verify your Sentry installation by creating a route that triggers an error:'
  92. ),
  93. configurations: [
  94. {
  95. language: 'python',
  96. code: `
  97. ${getSdkSetupSnippet(params)}
  98. app = Quart(__name__)
  99. @app.route("/")
  100. async def hello():
  101. 1/0 # raises an error
  102. return {"hello": "world"}
  103. app.run()
  104. `,
  105. },
  106. ],
  107. additionalInfo: (
  108. <span>
  109. <p>
  110. {tct(
  111. 'When you point your browser to [link:http://localhost:5000/] a transaction in the Performance section of Sentry will be created.',
  112. {
  113. link: <ExternalLink href="http://localhost:5000/" />,
  114. }
  115. )}
  116. </p>
  117. <p>
  118. {t(
  119. 'Additionally, an error event will be sent to Sentry and will be connected to the transaction.'
  120. )}
  121. </p>
  122. <p>{t('It takes a couple of moments for the data to appear in Sentry.')}</p>
  123. </span>
  124. ),
  125. },
  126. ],
  127. nextSteps: () => [],
  128. };
  129. const docs: Docs = {
  130. onboarding,
  131. replayOnboardingJsLoader,
  132. customMetricsOnboarding: getPythonMetricsOnboarding({
  133. installSnippet: getInstallSnippet(),
  134. }),
  135. crashReportOnboarding: crashReportOnboardingPython,
  136. };
  137. export default docs;