pylons.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  2. import type {
  3. Docs,
  4. DocsParams,
  5. OnboardingConfig,
  6. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  7. import {crashReportOnboardingPython} from 'sentry/gettingStartedDocs/python/python';
  8. import {t, tct} from 'sentry/locale';
  9. type Params = DocsParams;
  10. const getMidlewareSetupSnippet = () => `
  11. from raven.contrib.pylons import Sentry
  12. application = Sentry(application, config)`;
  13. const getConfigurationSnippet = (params: Params) => `
  14. [sentry]
  15. dsn=${params.dsn}
  16. include_paths=my.package,my.other.package,
  17. exclude_paths=my.package.crud`;
  18. const getLoggerSnippet = () => `
  19. [loggers]
  20. keys = root, sentry
  21. [handlers]
  22. keys = console, sentry
  23. [formatters]
  24. keys = generic
  25. [logger_root]
  26. level = INFO
  27. handlers = console, sentry
  28. [logger_sentry]
  29. level = WARN
  30. handlers = console
  31. qualname = sentry.errors
  32. propagate = 0
  33. [handler_console]
  34. class = StreamHandler
  35. args = (sys.stderr,)
  36. level = NOTSET
  37. formatter = generic
  38. [handler_sentry]
  39. class = raven.handlers.logging.SentryHandler
  40. args = ('SENTRY_DSN',)
  41. level = NOTSET
  42. formatter = generic
  43. [formatter_generic]
  44. format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
  45. datefmt = %H:%M:%S`;
  46. const onboarding: OnboardingConfig = {
  47. install: () => [
  48. {
  49. type: StepType.INSTALL,
  50. description: tct(
  51. 'If you haven’t already, start by downloading Raven. The easiest way is with [code:pip]:',
  52. {code: <code />}
  53. ),
  54. configurations: [
  55. {
  56. language: 'bash',
  57. code: 'pip install raven --upgrade',
  58. },
  59. ],
  60. },
  61. ],
  62. configure: (params: Params) => [
  63. {
  64. type: StepType.CONFIGURE,
  65. configurations: [
  66. {
  67. language: 'python',
  68. description: t(
  69. 'A Pylons-specific middleware exists to enable easy configuration from settings:'
  70. ),
  71. code: getMidlewareSetupSnippet(),
  72. },
  73. {
  74. language: 'ini',
  75. description: t('Configuration is handled via the sentry namespace:'),
  76. code: getConfigurationSnippet(params),
  77. },
  78. ],
  79. },
  80. {
  81. title: t('Logger setup'),
  82. configurations: [
  83. {
  84. language: 'python',
  85. description: tct(
  86. 'Add the following lines to your project’s [initCode:.ini] file to setup [sentryHandlerCode:SentryHandler]:',
  87. {
  88. initCode: <code />,
  89. sentryHandlerCode: <code />,
  90. }
  91. ),
  92. code: getLoggerSnippet(),
  93. },
  94. ],
  95. additionalInfo: t('You may want to set up other loggers as well.'),
  96. },
  97. ],
  98. verify: () => [],
  99. };
  100. const docs: Docs = {
  101. onboarding,
  102. crashReportOnboarding: crashReportOnboardingPython,
  103. };
  104. export default docs;