quart.tsx 4.6 KB

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