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.

fix(metrics): type the has_metrics response schema (#69190)

Frank Hamanded391653123e
diff --git a/products/metrics/backend/presentation/api.py b/products/metrics/backend/presentation/api.py
index 1a0e382efeed..efd1d5dc35d6 100644
--- a/products/metrics/backend/presentation/api.py
+++ b/products/metrics/backend/presentation/api.py
@@ -333,6 +333,10 @@ class _MetricAnomalyReportSerializer(serializers.Serializer):
)
+class _HasMetricsResponseSerializer(serializers.Serializer):
+ hasMetrics = serializers.BooleanField(help_text="Whether the team has ingested any metrics.")
+
+
class _MetricNameSerializer(serializers.Serializer):
name = serializers.CharField(help_text="Metric name as it appears in the team's data.")
metric_type = serializers.CharField(
@@ -419,7 +423,7 @@ class MetricsViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
scope_object = "metrics"
serializer_class = _FallbackSerializer
- @extend_schema(responses={200: OpenApiTypes.OBJECT})
+ @extend_schema(responses={200: _HasMetricsResponseSerializer})
@action(detail=False, methods=["GET"], required_scopes=["metrics:read"])
def has_metrics(self, request: Request, *args, **kwargs) -> Response:
tag_queries(product=Product.METRICS, feature=Feature.QUERY)
diff --git a/products/metrics/frontend/generated/api.schemas.ts b/products/metrics/frontend/generated/api.schemas.ts
index 0ecdbdfe3c76..814e738e55fa 100644
--- a/products/metrics/frontend/generated/api.schemas.ts
+++ b/products/metrics/frontend/generated/api.schemas.ts
@@ -241,6 +241,11 @@ export interface _MetricAnomalyReportApi {
series: _MetricSeriesApi
}
+export interface _HasMetricsResponseApi {
+ /** Whether the team has ingested any metrics. */
+ hasMetrics: boolean
+}
+
export interface _MetricGroupByApi {
/**
* Attribute name to split series by (e.g. 'k8s.pod.name', 'env').
@@ -458,8 +463,6 @@ export interface _MetricNamesResponseApi {
results: _MetricNameApi[]
}
-export type MetricsHasMetricsRetrieve200 = { [key: string]: unknown }
-
export type MetricsValuesRetrieveParams = {
/**
* Max number of names to return. Defaults to 100; maximum 1000.
diff --git a/products/metrics/frontend/generated/api.ts b/products/metrics/frontend/generated/api.ts
index f40ec42b3370..2aafa50799e4 100644
--- a/products/metrics/frontend/generated/api.ts
+++ b/products/metrics/frontend/generated/api.ts
@@ -11,8 +11,8 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
import type {
AppMetricsResponseApi,
AppMetricsTotalsResponseApi,
- MetricsHasMetricsRetrieve200,
MetricsValuesRetrieveParams,
+ _HasMetricsResponseApi,
_MetricAnomalyReportApi,
_MetricAnomalyRequestApi,
_MetricNamesResponseApi,
@@ -92,8 +92,8 @@ export const getMetricsHasMetricsRetrieveUrl = (projectId: string) => {
export const metricsHasMetricsRetrieve = async (
projectId: string,
options?: RequestInit
-): Promise<MetricsHasMetricsRetrieve200> => {
- return apiMutator<MetricsHasMetricsRetrieve200>(getMetricsHasMetricsRetrieveUrl(projectId), {
+): Promise<_HasMetricsResponseApi> => {
+ return apiMutator<_HasMetricsResponseApi>(getMetricsHasMetricsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d969af101c0a..c69136c64007 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -56106,6 +56106,11 @@ export namespace Schemas {
detail: string;
}
+ export interface _HasMetricsResponse {
+ /** Whether the team has ingested any metrics. */
+ hasMetrics: boolean;
+ }
+
export interface _HasSpansResponse {
/** Whether the team has ingested any tracing spans yet. Used to gate the onboarding empty state. */
hasSpans: boolean;
@@ -61072,8 +61077,6 @@ export namespace Schemas {
offset?: number;
};
- export type EnvironmentsMetricsHasMetricsRetrieve200 = { [key: string]: unknown };
-
export type EnvironmentsMetricsValuesRetrieveParams = {
/**
* Max number of names to return. Defaults to 100; maximum 1000.
@@ -68269,8 +68272,6 @@ export namespace Schemas {
offset?: number;
};
- export type MetricsHasMetricsRetrieve200 = { [key: string]: unknown };
-
export type MetricsValuesRetrieveParams = {
/**
* Max number of names to return. Defaults to 100; maximum 1000.