pylons.tsx 2.6 KB

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