Skip to content

Add scoped calculate analytics endpoint#1502

Merged
anth-volk merged 4 commits into
mainfrom
codex/analytics-variable-requests-endpoint
May 13, 2026
Merged

Add scoped calculate analytics endpoint#1502
anth-volk merged 4 commits into
mainfrom
codex/analytics-variable-requests-endpoint

Conversation

@anth-volk
Copy link
Copy Markdown
Collaborator

Fixes #1501

Summary

  • Add GET /analytics/calculate/requests for value-free calculate request analytics.
  • Support optional start_time/end_time filters and unique=true variable-key aggregation.
  • Require the read:calculate-analytics scope for the analytics endpoint only.
  • Wire static test-token scopes through config and CI token fetching.
  • Document the endpoint and schemas in OpenAPI.

Testing

  • uv run pytest -q tests/unit/decorators/test_auth.py tests/unit/endpoints/test_analytics.py
  • uv run pytest -q tests/unit/utils/test_config_loader.py::TestEnvironmentVariableOverrides::test__given_traditional_env_vars__config_maps_them_correctly tests/unit/utils/test_config_loader.py::TestEnvironmentVariableSubstitution::test__given_auth0_config_with_env_vars__substitution_enables_auth tests/unit/utils/test_config_loader.py::TestConfigValueSettings::test__integration_with_real_config_structure
  • uv run ruff check policyengine_household_api/decorators/auth.py policyengine_household_api/api.py policyengine_household_api/utils/config_loader.py tests/conftest.py tests/fixtures/decorators/auth.py tests/unit/decorators/test_auth.py tests/fixtures/endpoints/analytics.py tests/unit/endpoints/test_analytics.py
  • uv run ruff format --check policyengine_household_api/decorators/auth.py policyengine_household_api/api.py policyengine_household_api/utils/config_loader.py tests/conftest.py tests/fixtures/decorators/auth.py tests/unit/decorators/test_auth.py tests/fixtures/endpoints/analytics.py tests/unit/endpoints/test_analytics.py
  • uv run python -c "import yaml; yaml.safe_load(open('policyengine_household_api/openapi_spec.yaml'))"

Manual setup

  • Auth0 Household API audience needs read:calculate-analytics.
  • Grant that scope only to internal/admin clients.
  • GitHub secret AUTH0_TEST_TOKEN_SCOPES should be set to read:calculate-analytics where scoped token fetching is needed.

@anth-volk anth-volk marked this pull request as ready for review May 13, 2026 17:00
@anth-volk anth-volk merged commit d6afa4c into main May 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose scoped calculate variable analytics endpoint

1 participant