diff --git a/app/api/endpoints/session.py b/app/api/endpoints/session.py index 81e6820..82670ae 100644 --- a/app/api/endpoints/session.py +++ b/app/api/endpoints/session.py @@ -10,6 +10,7 @@ import logging from fastapi import APIRouter, Depends from app.cloud_session import CloudUser, _auth_label, get_session +from app.core.config import settings router = APIRouter() log = logging.getLogger(__name__) @@ -22,8 +23,13 @@ def session_bootstrap(session: CloudUser = Depends(get_session)) -> dict: Expected log output: INFO:app.api.endpoints.session: session auth=authed tier=paid INFO:app.api.endpoints.session: session auth=anon tier=free + + E2E test sessions (E2E_TEST_USER_ID) are logged at DEBUG so they don't + pollute analytics counts while still being visible when DEBUG=true. """ - log.info("session auth=%s tier=%s", _auth_label(session.user_id), session.tier) + is_test = bool(settings.E2E_TEST_USER_ID and session.user_id == settings.E2E_TEST_USER_ID) + logger = log.debug if is_test else log.info + logger("session auth=%s tier=%s%s", _auth_label(session.user_id), session.tier, " e2e=true" if is_test else "") return { "auth": _auth_label(session.user_id), "tier": session.tier, diff --git a/app/core/config.py b/app/core/config.py index fa55bc1..6b55f07 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -60,6 +60,10 @@ class Settings: # CFOrchClient reads CF_LICENSE_KEY automatically; exposed here for startup validation. CF_LICENSE_KEY: str | None = os.environ.get("CF_LICENSE_KEY") + # E2E test account — analytics logging is suppressed for this user_id so test + # runs don't pollute session counts. Set to the Directus UUID of the test user. + E2E_TEST_USER_ID: str | None = os.environ.get("E2E_TEST_USER_ID") or None + # Feature flags ENABLE_OCR: bool = os.environ.get("ENABLE_OCR", "false").lower() in ("1", "true", "yes")