
from flask import Flask


def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None:
    """Initialize and configure the Sentry SDK for the Flask-based web
    application (both in 'admin' and 'site' modes).
    """
    import sentry_sdk
    from sentry_sdk.integrations.flask import FlaskIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[FlaskIntegration()],
    )

    sentry_sdk.set_tag('app_mode', app.config.get('APP_MODE'))
    sentry_sdk.set_tag('site_id', app.config.get('SITE_ID'))


def configure_sentry_for_worker(dsn: str, environment: str) -> None:
    """Initialize and configure the Sentry SDK for the RQ worker."""
    import sentry_sdk
    from sentry_sdk.integrations.rq import RqIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[RqIntegration()],
    )

    sentry_sdk.set_tag('app_mode', 'worker')


from flask import Flask


def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None:
    """Initialize and configure the Sentry SDK for the Flask-based web
    application (both in 'admin' and 'site' modes).
    """
    import sentry_sdk
    from sentry_sdk.integrations.flask import FlaskIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[FlaskIntegration()],
    )

    app_mode = app.config.get('APP_MODE')
    sentry_sdk.set_tag('app_mode', app_mode)

    if app_mode == 'site':
        sentry_sdk.set_tag('site_id', app.config.get('SITE_ID'))


def configure_sentry_for_worker(dsn: str, environment: str) -> None:
    """Initialize and configure the Sentry SDK for the RQ worker."""
    import sentry_sdk
    from sentry_sdk.integrations.rq import RqIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[RqIntegration()],
    )

    sentry_sdk.set_tag('app_mode', 'worker')

Set Sentry `site_id` tag only in site app mode
Set Sentry `site_id` tag only in site app mode

  
  from flask import Flask
  
  
  def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None:
      """Initialize and configure the Sentry SDK for the Flask-based web
      application (both in 'admin' and 'site' modes).
      """
      import sentry_sdk
      from sentry_sdk.integrations.flask import FlaskIntegration
  
      sentry_sdk.init(
          dsn=dsn, environment=environment, integrations=[FlaskIntegration()],
      )
  
+     app_mode = app.config.get('APP_MODE')
-     sentry_sdk.set_tag('app_mode', app.config.get('APP_MODE'))
+     sentry_sdk.set_tag('app_mode', app_mode)
+ 
+     if app_mode == 'site':
-     sentry_sdk.set_tag('site_id', app.config.get('SITE_ID'))
+         sentry_sdk.set_tag('site_id', app.config.get('SITE_ID'))
  
  
  def configure_sentry_for_worker(dsn: str, environment: str) -> None:
      """Initialize and configure the Sentry SDK for the RQ worker."""
      import sentry_sdk
      from sentry_sdk.integrations.rq import RqIntegration
  
      sentry_sdk.init(
          dsn=dsn, environment=environment, integrations=[RqIntegration()],
      )
  
      sentry_sdk.set_tag('app_mode', 'worker')
  
Set Sentry `site_id` tag only in site app mode
## Code Before:

from flask import Flask


def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None:
    """Initialize and configure the Sentry SDK for the Flask-based web
    application (both in 'admin' and 'site' modes).
    """
    import sentry_sdk
    from sentry_sdk.integrations.flask import FlaskIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[FlaskIntegration()],
    )

    sentry_sdk.set_tag('app_mode', app.config.get('APP_MODE'))
    sentry_sdk.set_tag('site_id', app.config.get('SITE_ID'))


def configure_sentry_for_worker(dsn: str, environment: str) -> None:
    """Initialize and configure the Sentry SDK for the RQ worker."""
    import sentry_sdk
    from sentry_sdk.integrations.rq import RqIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[RqIntegration()],
    )

    sentry_sdk.set_tag('app_mode', 'worker')

## Instruction:
Set Sentry `site_id` tag only in site app mode
## Code After:

from flask import Flask


def configure_sentry_for_webapp(dsn: str, environment: str, app: Flask) -> None:
    """Initialize and configure the Sentry SDK for the Flask-based web
    application (both in 'admin' and 'site' modes).
    """
    import sentry_sdk
    from sentry_sdk.integrations.flask import FlaskIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[FlaskIntegration()],
    )

    app_mode = app.config.get('APP_MODE')
    sentry_sdk.set_tag('app_mode', app_mode)

    if app_mode == 'site':
        sentry_sdk.set_tag('site_id', app.config.get('SITE_ID'))


def configure_sentry_for_worker(dsn: str, environment: str) -> None:
    """Initialize and configure the Sentry SDK for the RQ worker."""
    import sentry_sdk
    from sentry_sdk.integrations.rq import RqIntegration

    sentry_sdk.init(
        dsn=dsn, environment=environment, integrations=[RqIntegration()],
    )

    sentry_sdk.set_tag('app_mode', 'worker')
