Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

679 B
Raw Blame
from collections.abc import Iterator

import pytest
from unittest.mock import patch

from posthog.api.snuffle_proxy import SNUFFLE_API_FEATURE_FLAG


@pytest.fixture(autouse=True)
def enable_metrics_feature_flag() -> Iterator[None]:
    # Enable the flags needed by the metrics endpoint tests.
    # MetricsViewSet needs `metrics`.
    # The Prometheus proxy needs `SNUFFLE_API_FEATURE_FLAG`.
    # Gate tests set their flag to False.
    def _feature_enabled(flag_key: str, *args: object, **kwargs: object) -> bool:
        return flag_key in ("metrics", SNUFFLE_API_FEATURE_FLAG)

    with patch("posthoganalytics.feature_enabled", side_effect=_feature_enabled):
        yield