sanic.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. }: {
  42. dsn?: string;
  43. } = {}): LayoutProps['steps'] => [
  44. {
  45. type: StepType.INSTALL,
  46. description: <p>{tct('Install [code:sentry-sdk] from PyPI:', {code: <code />})}</p>,
  47. configurations: [
  48. {
  49. language: 'bash',
  50. code: '$ pip install --upgrade sentry-sdk',
  51. },
  52. {
  53. description: (
  54. <p>
  55. {tct(
  56. "f you're on Python 3.6, you also need the [code:aiocontextvars] package:",
  57. {
  58. code: <code />,
  59. }
  60. )}
  61. </p>
  62. ),
  63. language: 'bash',
  64. code: '$ pip install --upgrade aiocontextvars',
  65. },
  66. ],
  67. },
  68. {
  69. type: StepType.CONFIGURE,
  70. description: t(
  71. 'To configure the SDK, initialize it with the integration before or after your app has been initialized:'
  72. ),
  73. configurations: [
  74. {
  75. language: 'python',
  76. code: `
  77. import sentry_sdk
  78. from sentry_sdk.integrations.sanic import SanicIntegration
  79. from sanic import Sanic
  80. sentry_sdk.init(
  81. dsn="${dsn}",
  82. integrations=[
  83. SanicIntegration(),
  84. ],
  85. # Set traces_sample_rate to 1.0 to capture 100%
  86. # of transactions for performance monitoring.
  87. # We recommend adjusting this value in production,
  88. traces_sample_rate=1.0,
  89. )
  90. app = Sanic(__name__)
  91. `,
  92. },
  93. ],
  94. },
  95. ];
  96. // Configuration End
  97. export function GettingStartedWithSanic({dsn, ...props}: ModuleProps) {
  98. return <Layout steps={steps({dsn})} introduction={introduction} {...props} />;
  99. }
  100. export default GettingStartedWithSanic;