sanic.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import List from 'sentry/components/list';
  4. import ListItem from 'sentry/components/list/listItem';
  5. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  6. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  7. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  8. import {t, tct} from 'sentry/locale';
  9. // Configuration Start
  10. const introduction = (
  11. <Fragment>
  12. <p>
  13. {tct(
  14. 'The Sanic integration adds support for the [link:Sanic Web Framework]. We support the following versions:',
  15. {
  16. link: <ExternalLink href="https://github.com/sanic-org/sanic" />,
  17. }
  18. )}
  19. </p>
  20. <List symbol="bullet">
  21. <ListItem>0.8</ListItem>
  22. <ListItem>18.12</ListItem>
  23. <ListItem>19.12</ListItem>
  24. <ListItem>20.12</ListItem>
  25. <ListItem>{t('Any version of the form "x.12" (LTS versions).')}</ListItem>
  26. </List>
  27. <p>
  28. {tct(
  29. '[strong:We do support all versions of Sanic]. However, Sanic versions between LTS releases should be considered Early Adopter. We may not support all the features in these non-LTS versions, since non-LTS versions change quickly and [link:have introduced breaking changes in the past], without prior notice.',
  30. {
  31. strong: <strong />,
  32. link: <ExternalLink href="https://github.com/sanic-org/sanic/issues/1532" />,
  33. }
  34. )}
  35. </p>
  36. {t('A Python version of "3.6" or greater is also required.')}
  37. </Fragment>
  38. );
  39. export const steps = ({
  40. dsn,
  41. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  42. {
  43. type: StepType.INSTALL,
  44. description: <p>{tct('Install [code:sentry-sdk] from PyPI:', {code: <code />})}</p>,
  45. configurations: [
  46. {
  47. language: 'bash',
  48. code: '$ pip install --upgrade sentry-sdk',
  49. },
  50. {
  51. description: (
  52. <p>
  53. {tct(
  54. "f you're on Python 3.6, you also need the [code:aiocontextvars] package:",
  55. {
  56. code: <code />,
  57. }
  58. )}
  59. </p>
  60. ),
  61. language: 'bash',
  62. code: '$ pip install --upgrade aiocontextvars',
  63. },
  64. ],
  65. },
  66. {
  67. type: StepType.CONFIGURE,
  68. description: t(
  69. 'To configure the SDK, initialize it with the integration before or after your app has been initialized:'
  70. ),
  71. configurations: [
  72. {
  73. language: 'python',
  74. code: `
  75. import sentry_sdk
  76. from sentry_sdk.integrations.sanic import SanicIntegration
  77. from sanic import Sanic
  78. sentry_sdk.init(
  79. dsn="${dsn}",
  80. integrations=[
  81. SanicIntegration(),
  82. ],
  83. # Set traces_sample_rate to 1.0 to capture 100%
  84. # of transactions for performance monitoring.
  85. # We recommend adjusting this value in production,
  86. traces_sample_rate=1.0,
  87. )
  88. app = Sanic(__name__)
  89. `,
  90. },
  91. ],
  92. },
  93. ];
  94. // Configuration End
  95. export function GettingStartedWithSanic({dsn, ...props}: ModuleProps) {
  96. return <Layout steps={steps({dsn})} introduction={introduction} {...props} />;
  97. }
  98. export default GettingStartedWithSanic;