Files
analytics/app/config.py
T
2026-06-18 12:43:42 +02:00

66 lines
2.7 KiB
Python

"""Runtime configuration read from environment variables.
AppFactory injects variables/secrets as environment variables (see AGENTS.md).
This module holds only NON-secret infrastructure configuration. Per-request
credentials are never stored here - they arrive in X- headers (see
``app.credentials``).
"""
import os
# Public app metadata
APP_NAME = os.getenv("APP_NAME", "analytics")
APP_VERSION = os.getenv("APP_VERSION", "1.0.0")
# Reverse-proxy prefix injected by AppFactory (e.g. "/apps/analytics").
# Empty when running locally at the domain root.
ROOT_PATH = os.getenv("ROOT_PATH", "")
# --- Google Analytics ---------------------------------------------------------
# Base URLs are configurable so we can point at a staging/mock endpoint, but
# default to the production Google endpoints.
GA_DATA_BASE_URL = os.getenv(
"GA_DATA_BASE_URL", "https://analyticsdata.googleapis.com/v1beta"
)
GA_ADMIN_BASE_URL = os.getenv(
"GA_ADMIN_BASE_URL", "https://analyticsadmin.googleapis.com/v1beta"
)
# OAuth scope requested when minting an access token from a service account.
# analytics.readonly is sufficient for reporting (Data API) and for listing
# accounts/properties/data streams (Admin API read operations).
GA_SCOPE = os.getenv(
"GA_SCOPE", "https://www.googleapis.com/auth/analytics.readonly"
)
# --- Google Search Console ----------------------------------------------------
# Search Analytics, Sites and Sitemaps live under the Webmasters v3 API; the
# newer URL Inspection lives under searchconsole.googleapis.com/v1.
GSC_DATA_BASE_URL = os.getenv(
"GSC_DATA_BASE_URL", "https://www.googleapis.com/webmasters/v3"
)
GSC_INSPECT_BASE_URL = os.getenv(
"GSC_INSPECT_BASE_URL", "https://searchconsole.googleapis.com/v1"
)
GSC_SCOPE = os.getenv(
"GSC_SCOPE", "https://www.googleapis.com/auth/webmasters.readonly"
)
# --- Google Ads ---------------------------------------------------------------
# Google Ads API versions are deprecated roughly yearly - keep the version in an
# env var so it can be bumped without a code change.
GOOGLE_ADS_BASE_URL = os.getenv(
"GOOGLE_ADS_BASE_URL", "https://googleads.googleapis.com"
)
GOOGLE_ADS_API_VERSION = os.getenv("GOOGLE_ADS_API_VERSION", "v19")
GOOGLE_ADS_SCOPE = os.getenv(
"GOOGLE_ADS_SCOPE", "https://www.googleapis.com/auth/adwords"
)
# --- Sklik (Seznam) -----------------------------------------------------------
# Sklik "Drak" JSON API. The method name is appended to this base URL and the
# HTTP body is a JSON array of positional arguments.
SKLIK_BASE_URL = os.getenv("SKLIK_BASE_URL", "https://api.sklik.cz/drak/json/v5")
# --- HTTP ---------------------------------------------------------------------
# Upstream request timeout in seconds.
HTTP_TIMEOUT_SECONDS = float(os.getenv("HTTP_TIMEOUT_SECONDS", "60"))