pyramid.tsx 3.0 KB

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