quart.tsx 3.3 KB

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