Browse Source

ref(onboarding): Move filename into snippet header - python platforms (#76159)

Priscila Oliveira 6 months ago
parent
commit
ddab8f3395

+ 33 - 12
static/app/gettingStartedDocs/python/rq.tsx

@@ -36,7 +36,6 @@ sentry_sdk.init(
 )`;
 
 const getSdkSetupSnippet = (params: Params) => `
-# mysettings.py
 import sentry_sdk
 
 ${getInitCallSnippet(params)}`;
@@ -46,20 +45,18 @@ rq worker \
 -c mysettings \  # module name of mysettings.py
 --sentry-dsn="..."  # only necessary for RQ < 1.0`;
 
-const getJobDefinitionSnippet = () => `# jobs.py
+const getJobDefinitionSnippet = () => `
 def hello(name):
     1/0  # raises an error
     return "Hello %s!" % name`;
 
 const getWorkerSetupSnippet = (params: Params) => `
-# mysettings.py
 import sentry_sdk
 
 # Sentry configuration for RQ worker processes
 ${getInitCallSnippet(params)}`;
 
 const getMainPythonScriptSetupSnippet = (params: Params) => `
-# main.py
 from redis import Redis
 from rq import Queue
 
@@ -123,8 +120,14 @@ const onboarding: OnboardingConfig = {
       ),
       configurations: [
         {
-          language: 'python',
-          code: getSdkSetupSnippet(params),
+          code: [
+            {
+              label: 'mysettings.py',
+              value: 'mysettings.py',
+              language: 'python',
+              code: getSdkSetupSnippet(params),
+            },
+          ],
         },
         {
           description: t('Start your worker with:'),
@@ -150,18 +153,36 @@ const onboarding: OnboardingConfig = {
       configurations: [
         {
           description: <h5>{t('Job definition')}</h5>,
-          language: 'python',
-          code: getJobDefinitionSnippet(),
+          code: [
+            {
+              language: 'python',
+              label: 'jobs.py',
+              value: 'jobs.py',
+              code: getJobDefinitionSnippet(),
+            },
+          ],
         },
         {
           description: <h5>{t('Settings for worker')}</h5>,
-          language: 'python',
-          code: getWorkerSetupSnippet(params),
+          code: [
+            {
+              label: 'mysettings.py',
+              value: 'mysettings.py',
+              language: 'python',
+              code: getWorkerSetupSnippet(params),
+            },
+          ],
         },
         {
           description: <h5>{t('Main Python Script')}</h5>,
-          language: 'python',
-          code: getMainPythonScriptSetupSnippet(params),
+          code: [
+            {
+              label: 'main.py',
+              value: 'main.py',
+              language: 'python',
+              code: getMainPythonScriptSetupSnippet(params),
+            },
+          ],
         },
       ],
       additionalInfo: (

+ 1 - 1
static/app/gettingStartedDocs/python/sanic.tsx

@@ -46,7 +46,7 @@ const onboarding: OnboardingConfig = {
           description: (
             <p>
               {tct(
-                "f you're on Python 3.6, you also need the [code:aiocontextvars] package:",
+                "If you're on Python 3.6, you also need the [code:aiocontextvars] package:",
                 {
                   code: <code />,
                 }

+ 17 - 5
static/app/gettingStartedDocs/python/tryton.tsx

@@ -11,7 +11,6 @@ import {t, tct} from 'sentry/locale';
 type Params = DocsParams;
 
 const getSdkSetupSnippet = (params: Params) => `
-# wsgi.py
 import sentry_sdk
 from sentry_sdk.integrations.trytond import TrytondWSGIIntegration
 
@@ -41,7 +40,7 @@ from trytond.application import app as application
 
 # ...`;
 
-const getErrorHandlerSnippet = () => `# wsgi.py
+const getErrorHandlerSnippet = () => `
 # ...
 
 from trytond.exceptions import TrytonException
@@ -73,15 +72,28 @@ const onboarding: OnboardingConfig = {
       ),
       configurations: [
         {
-          language: 'python',
-          code: getSdkSetupSnippet(params),
+          code: [
+            {
+              label: 'wsgi.py',
+              value: 'wsgi.py',
+              language: 'python',
+              code: getSdkSetupSnippet(params),
+            },
+          ],
         },
         {
           description: t(
             'In Tryton>=5.4 an error handler can be registered to respond the client with a custom error message including the Sentry event id instead of a traceback.'
           ),
           language: 'python',
-          code: getErrorHandlerSnippet(),
+          code: [
+            {
+              label: 'wsgi.py',
+              value: 'wsgi.py',
+              language: 'python',
+              code: getErrorHandlerSnippet(),
+            },
+          ],
         },
       ],
     },