bottle.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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) => `import sentry_sdk
  12. sentry_sdk.init(
  13. dsn="${params.dsn}",${
  14. params.isPerformanceSelected
  15. ? `
  16. # Set traces_sample_rate to 1.0 to capture 100%
  17. # of transactions for performance monitoring.
  18. traces_sample_rate=1.0,`
  19. : ''
  20. }${
  21. params.isProfilingSelected
  22. ? `
  23. # Set profiles_sample_rate to 1.0 to profile 100%
  24. # of sampled transactions.
  25. # We recommend adjusting this value in production.
  26. profiles_sample_rate=1.0,`
  27. : ''
  28. }
  29. )
  30. `;
  31. const onboarding: OnboardingConfig = {
  32. introduction: () =>
  33. tct('The Bottle integration adds support for the [link:Bottle Web Framework].', {
  34. link: <ExternalLink href="https://bottlepy.org/docs/dev/" />,
  35. }),
  36. install: () => [
  37. {
  38. type: StepType.INSTALL,
  39. description: tct(
  40. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [sentryBotteCode:bottle] extra:',
  41. {
  42. sentrySdkCode: <code />,
  43. sentryBotteCode: <code />,
  44. }
  45. ),
  46. configurations: [
  47. {
  48. language: 'bash',
  49. code: 'pip install --upgrade sentry-sdk[bottle]',
  50. },
  51. ],
  52. },
  53. ],
  54. configure: (params: Params) => [
  55. {
  56. type: StepType.CONFIGURE,
  57. description: tct(
  58. 'If you have the [code:bottle] package in your dependencies, the Bottle integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:',
  59. {
  60. code: <code />,
  61. }
  62. ),
  63. configurations: [
  64. {
  65. language: 'python',
  66. code: `from bottle import Bottle
  67. ${getSdkSetupSnippet(params)}
  68. app = Bottle()
  69. `,
  70. },
  71. ],
  72. },
  73. ],
  74. verify: (params: Params) => [
  75. {
  76. type: StepType.VERIFY,
  77. description: t(
  78. 'To verify that everything is working, trigger an error on purpose:'
  79. ),
  80. configurations: [
  81. {
  82. language: 'python',
  83. code: `from bottle import Bottle, run
  84. ${getSdkSetupSnippet(params)}
  85. app = Bottle()
  86. @app.route('/')
  87. def hello():
  88. 1/0
  89. return "Hello World!"
  90. run(app, host='localhost', port=8000)
  91. `,
  92. },
  93. ],
  94. additionalInfo: (
  95. <span>
  96. <p>
  97. {tct(
  98. 'When you point your browser to [link:http://localhost:8000/] a transaction in the Performance section of Sentry will be created.',
  99. {
  100. link: <ExternalLink href="http://localhost:8000/" />,
  101. }
  102. )}
  103. </p>
  104. <p>
  105. {t(
  106. 'Additionally, an error event will be sent to Sentry and will be connected to the transaction.'
  107. )}
  108. </p>
  109. <p>{t('It takes a couple of moments for the data to appear in Sentry.')}</p>
  110. </span>
  111. ),
  112. },
  113. ],
  114. nextSteps: () => [],
  115. };
  116. const docs: Docs = {
  117. onboarding,
  118. replayOnboardingJsLoader,
  119. };
  120. export default docs;