quart.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 {t, tct} from 'sentry/locale';
  11. type Params = DocsParams;
  12. const getInstallSnippet = () => `pip install --upgrade sentry-sdk[quart]`;
  13. const getSdkSetupSnippet = (params: Params) => `
  14. import sentry_sdk
  15. from sentry_sdk.integrations.quart import QuartIntegration
  16. from quart import Quart
  17. sentry_sdk.init(
  18. dsn="${params.dsn}",
  19. integrations=[QuartIntegration()],${
  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. `;
  37. const onboarding: OnboardingConfig = {
  38. introduction: () =>
  39. tct('The Quart integration adds support for the [link:Quart Web Framework].', {
  40. link: <ExternalLink href="https://quart.palletsprojects.com/" />,
  41. }),
  42. install: () => [
  43. {
  44. type: StepType.INSTALL,
  45. description: tct(
  46. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [sentryQuartCode:quart] extra:',
  47. {
  48. sentrySdkCode: <code />,
  49. sentryQuartCode: <code />,
  50. }
  51. ),
  52. configurations: [
  53. {
  54. language: 'bash',
  55. code: getInstallSnippet(),
  56. },
  57. ],
  58. },
  59. ],
  60. configure: (params: Params) => [
  61. {
  62. type: StepType.CONFIGURE,
  63. description: t(
  64. 'To configure the SDK, initialize it with the integration before or after your app has been initialized:'
  65. ),
  66. configurations: [
  67. {
  68. language: 'python',
  69. code: `
  70. ${getSdkSetupSnippet(params)}
  71. app = Quart(__name__)
  72. `,
  73. },
  74. ],
  75. },
  76. ],
  77. verify: (params: Params) => [
  78. {
  79. type: StepType.VERIFY,
  80. description: t(
  81. 'You can easily verify your Sentry installation by creating a route that triggers an error:'
  82. ),
  83. configurations: [
  84. {
  85. language: 'python',
  86. code: `
  87. ${getSdkSetupSnippet(params)}
  88. app = Quart(__name__)
  89. @app.route("/")
  90. async def hello():
  91. 1/0 # raises an error
  92. return {"hello": "world"}
  93. app.run()
  94. `,
  95. },
  96. ],
  97. additionalInfo: (
  98. <span>
  99. <p>
  100. {tct(
  101. 'When you point your browser to [link:http://localhost:5000/] a transaction in the Performance section of Sentry will be created.',
  102. {
  103. link: <ExternalLink href="http://localhost:5000/" />,
  104. }
  105. )}
  106. </p>
  107. <p>
  108. {t(
  109. 'Additionally, an error event will be sent to Sentry and will be connected to the transaction.'
  110. )}
  111. </p>
  112. <p>{t('It takes a couple of moments for the data to appear in Sentry.')}</p>
  113. </span>
  114. ),
  115. },
  116. ],
  117. nextSteps: () => [],
  118. };
  119. const docs: Docs = {
  120. onboarding,
  121. replayOnboardingJsLoader,
  122. customMetricsOnboarding: getPythonMetricsOnboarding({
  123. installSnippet: getInstallSnippet(),
  124. }),
  125. };
  126. export default docs;