import ExternalLink from 'sentry/components/links/externalLink'; import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout'; import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation'; import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step'; import {t, tct} from 'sentry/locale'; // Configuration Start const introduction = (

{tct('The Sanic integration adds support for the [link:Sanic Web Framework].', { link: , })}

); export const steps = ({ sentryInitContent, }: { sentryInitContent: string; }): LayoutProps['steps'] => [ { type: StepType.INSTALL, description: (

{tct( 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [sentrySanicCode:sanic] extra:', { sentrySdkCode: , sentrySanicCode: , } )}

), configurations: [ { language: 'bash', code: '$ pip install --upgrade sentry-sdk[sanic]', }, { description: (

{tct( "f you're on Python 3.6, you also need the [code:aiocontextvars] package:", { code: , } )}

), language: 'bash', code: '$ pip install --upgrade aiocontextvars', }, ], }, { type: StepType.CONFIGURE, description: (

{tct( 'If you have the [codeSanic:sanic] package in your dependencies, the Sanic integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:', { codeSanic: , } )}

), configurations: [ { language: 'python', code: ` from sanic import Sanic import sentry_sdk sentry_sdk.init( ${sentryInitContent} ) app = Sanic(__name__) `, }, ], }, { type: StepType.VERIFY, description: t( 'You can easily verify your Sentry installation by creating a route that triggers an error:' ), configurations: [ { language: 'python', code: `from sanic import Sanic from sanic.response import text sentry_sdk.init( ${sentryInitContent} ) app = Sanic(__name__) @app.get("/") async def hello_world(request): 1 / 0 # raises an error return text("Hello, world.") `, }, ], additionalInfo: (

{tct( 'When you point your browser to [link:http://localhost:8000/] an error will be sent to Sentry.', { link: , } )}

), }, ]; // Configuration End export function GettingStartedWithSanic({dsn, ...props}: ModuleProps) { const otherConfigs: string[] = []; let sentryInitContent: string[] = [` dsn="${dsn}",`]; sentryInitContent = sentryInitContent.concat(otherConfigs); return ( ); } export default GettingStartedWithSanic;