pyramid.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 {
  9. feedbackOnboardingJsLoader,
  10. replayOnboardingJsLoader,
  11. } from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  12. import {
  13. crashReportOnboardingPython,
  14. featureFlagOnboarding,
  15. } from 'sentry/gettingStartedDocs/python/python';
  16. import {t, tct} from 'sentry/locale';
  17. type Params = DocsParams;
  18. const getInstallSnippet = () => `pip install --upgrade sentry-sdk`;
  19. const getSdkSetupSnippet = (params: Params) => `
  20. from pyramid.config import Configurator
  21. import sentry_sdk
  22. sentry_sdk.init(
  23. dsn="${params.dsn.public}",
  24. # Add data like request headers and IP for users,
  25. # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
  26. send_default_pii=True,
  27. )
  28. `;
  29. const onboarding: OnboardingConfig = {
  30. introduction: () =>
  31. tct('The Pyramid integration adds support for the [link:Pyramid Web Framework].', {
  32. link: <ExternalLink href="https://trypyramid.com/" />,
  33. }),
  34. install: () => [
  35. {
  36. type: StepType.INSTALL,
  37. description: tct('Install [code:sentry-sdk] from PyPI:', {code: <code />}),
  38. configurations: [
  39. {
  40. language: 'bash',
  41. code: getInstallSnippet(),
  42. },
  43. ],
  44. },
  45. ],
  46. configure: (params: Params) => [
  47. {
  48. type: StepType.CONFIGURE,
  49. description: tct(
  50. 'If you have the [codePyramid:pyramid] package in your dependencies, the Pyramid integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:',
  51. {
  52. codePyramid: <code />,
  53. }
  54. ),
  55. configurations: [
  56. {
  57. language: 'python',
  58. code: `
  59. ${getSdkSetupSnippet(params)}
  60. with Configurator() as config:
  61. # ...
  62. `,
  63. },
  64. ],
  65. },
  66. ],
  67. verify: (params: Params) => [
  68. {
  69. type: StepType.VERIFY,
  70. description: t(
  71. 'You can easily verify your Sentry installation by creating a route that triggers an error:'
  72. ),
  73. configurations: [
  74. {
  75. language: 'python',
  76. code: `from wsgiref.simple_server import make_server
  77. from pyramid.response import Response${getSdkSetupSnippet(params)}
  78. def hello_world(request):
  79. 1/0 # raises an error
  80. return Response('Hello World!')
  81. if __name__ == '__main__':
  82. with Configurator() as config:
  83. config.add_route('hello', '/')
  84. config.add_view(hello_world, route_name='hello')
  85. app = config.make_wsgi_app()
  86. server = make_server('0.0.0.0', 6543, app)
  87. server.serve_forever()
  88. `,
  89. },
  90. ],
  91. additionalInfo: tct(
  92. 'When you point your browser to [link:http://localhost:6543/] an error event will be sent to Sentry.',
  93. {
  94. link: <ExternalLink href="http://localhost:6543/" />,
  95. }
  96. ),
  97. },
  98. ],
  99. nextSteps: () => [],
  100. };
  101. const docs: Docs = {
  102. onboarding,
  103. replayOnboardingJsLoader,
  104. crashReportOnboarding: crashReportOnboardingPython,
  105. featureFlagOnboarding,
  106. feedbackOnboardingJsLoader,
  107. };
  108. export default docs;