pyramid.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. from pyramid.config import Configurator
  13. import sentry_sdk
  14. sentry_sdk.init(
  15. dsn="${params.dsn}",
  16. )
  17. `;
  18. const onboarding: OnboardingConfig = {
  19. introduction: () =>
  20. tct('The Pyramid integration adds support for the [link:Pyramid Web Framework].', {
  21. link: <ExternalLink href="https://trypyramid.com/" />,
  22. }),
  23. install: () => [
  24. {
  25. type: StepType.INSTALL,
  26. description: tct('Install [code:sentry-sdk] from PyPI:', {code: <code />}),
  27. configurations: [
  28. {
  29. language: 'bash',
  30. code: '$ pip install --upgrade sentry-sdk',
  31. },
  32. ],
  33. },
  34. ],
  35. configure: (params: Params) => [
  36. {
  37. type: StepType.CONFIGURE,
  38. description: tct(
  39. '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:',
  40. {
  41. codePyramid: <code />,
  42. }
  43. ),
  44. configurations: [
  45. {
  46. language: 'python',
  47. code: `
  48. ${getSdkSetupSnippet(params)}
  49. with Configurator() as config:
  50. # ...
  51. `,
  52. },
  53. ],
  54. },
  55. ],
  56. verify: (params: Params) => [
  57. {
  58. type: StepType.VERIFY,
  59. description: t(
  60. 'You can easily verify your Sentry installation by creating a route that triggers an error:'
  61. ),
  62. configurations: [
  63. {
  64. language: 'python',
  65. code: `from wsgiref.simple_server import make_server
  66. from pyramid.response import Response${getSdkSetupSnippet(params)}
  67. def hello_world(request):
  68. 1/0 # raises an error
  69. return Response('Hello World!')
  70. if __name__ == '__main__':
  71. with Configurator() as config:
  72. config.add_route('hello', '/')
  73. config.add_view(hello_world, route_name='hello')
  74. app = config.make_wsgi_app()
  75. server = make_server('0.0.0.0', 6543, app)
  76. server.serve_forever()
  77. `,
  78. },
  79. ],
  80. additionalInfo: tct(
  81. 'When you point your browser to [link:http://localhost:6543/] an error event will be sent to Sentry.',
  82. {
  83. link: <ExternalLink href="http://localhost:6543/" />,
  84. }
  85. ),
  86. },
  87. ],
  88. nextSteps: () => [],
  89. };
  90. const docs: Docs = {
  91. onboarding,
  92. replayOnboardingJsLoader,
  93. };
  94. export default docs;