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.

feat(replay-vision): add spend per scanner onto scanner list column (#71135)

Hayne Ryu24269c4c60e4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 76f56a7b389c..7f69b5099584 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6807,9 +6807,9 @@ snapshots:
scenes-app-quickstart-product-card--playground--light:
hash: v1.k794b7964.b85349f783d2e37dc3d8f34c47a0cf0279472dd5f4b57a98972274fc6a08fac5.KzPnkFBWU41BKwOOklmvlpw3U_7UfSmDr-9HBibnCrc
scenes-app-replay-vision--scanners-list--dark:
- hash: v1.k794b7964.daa9f38b95aa3296a6f7f6afd822e0016ffb7877c2397ad7ce23b2be1d67640f.DD8sIGjdkm46sZUGxHk84xhn3jk4Umrnx4ecrNUrrCs
+ hash: v1.k794b7964.d34dcdf0513228fba74671c5ae8a086341a25da4072215f3017fbfecb30d709e.X5uu0XrowQzhQYiyylzfo6X3ovcKYa2Qz0JNsoO0ivc
scenes-app-replay-vision--scanners-list--light:
- hash: v1.k794b7964.45152642e4bab1d33429f7a8ab7012c317622d06b04d3cc6bb0da0f58c417baa.1iizSOBB9Nn8M9-s4kIZ3X1-GFYB1UKqyCW9D1qlVOw
+ hash: v1.k794b7964.1922cbe5bcba96f64f4de8bfbaf270693c3acf561ab279f48b1fd95e2653eaa9.azCzWZ0LusXCVTJ6XQlTYpHdBzf7vXjYoOsEWR3Jd2s
scenes-app-revenue-analytics--revenue-analytics-dashboard--dark:
hash: v1.k794b7964.3ea83eb81304d8f428406dd91932063929413974fe5d5a9efeedae5af86810ea.HkT7YP6qgm9kWpEwPA8TPmx_2kkLGLto_mEgUAby5Ts
scenes-app-revenue-analytics--revenue-analytics-dashboard--light:
diff --git a/products/replay_vision/backend/api/scanners.py b/products/replay_vision/backend/api/scanners.py
index 04ff5ceeac8f..80c330cf0b71 100644
--- a/products/replay_vision/backend/api/scanners.py
+++ b/products/replay_vision/backend/api/scanners.py
@@ -1,7 +1,7 @@
from typing import Any, NoReturn, cast
from django.db import IntegrityError
-from django.db.models import CharField, Count, F, Q, QuerySet, Value
+from django.db.models import CharField, Count, F, IntegerField, OuterRef, Q, QuerySet, Subquery, Sum, Value
from django.db.models.functions import Coalesce, NullIf
from django.utils import timezone
@@ -35,7 +35,7 @@ from products.replay_vision.backend.api.trigger import (
check_team_in_flight_capacity,
start_apply_scanner_workflow,
)
-from products.replay_vision.backend.billing import observation_credits_for_model
+from products.replay_vision.backend.billing import observation_credits_case, observation_credits_for_model
from products.replay_vision.backend.digest import provision_scanner_digest
from products.replay_vision.backend.feature_flag import ReplayVisionEnabledPermission, is_replay_vision_actions_enabled
from products.replay_vision.backend.feedback_themes import cached_feedback_themes
@@ -44,7 +44,11 @@ from products.replay_vision.backend.impact import (
compute_scanner_impact,
create_affected_cohort,
)
-from products.replay_vision.backend.models.replay_observation import ObservationTrigger
+from products.replay_vision.backend.models.replay_observation import (
+ ObservationStatus,
+ ObservationTrigger,
+ ReplayObservation,
+)
from products.replay_vision.backend.models.replay_scanner import (
ReplayScanner,
SamplingMode,
@@ -60,7 +64,11 @@ from products.replay_vision.backend.queries import (
project_monthly_observations,
refresh_scanner_estimate,
)
-from products.replay_vision.backend.quota import sum_enabled_scanner_estimated_credits
+from products.replay_vision.backend.quota import (
+ credits_used_by_scanner,
+ current_period_bounds,
+ sum_enabled_scanner_estimated_credits,
+)
from products.replay_vision.backend.tag_suggestions import SuggestionError, suggest_classifier_tags
from products.replay_vision.backend.tags import slugify_tag
from products.replay_vision.backend.temporal.constants import MAX_SESSION_ID_LENGTH
@@ -240,6 +248,12 @@ class ReplayScannerSerializer(serializers.ModelSerializer):
estimated_monthly_credits = serializers.SerializerMethodField(
help_text="`estimated_monthly_observations` priced at `credits_per_observation`. Null until the estimate is first computed.",
)
+ credits_this_month = serializers.SerializerMethodField(
+ help_text=(
+ "Credits this scanner's succeeded observations consumed in the current billing period "
+ "(1 credit = $0.01). Matches the window of the org-wide quota meter."
+ ),
+ )
last_swept_at = serializers.DateTimeField(
read_only=True,
help_text="Watermark for the scanner's last scheduled fire. Mirrors Temporal schedule state for recovery.",
@@ -286,6 +300,7 @@ class ReplayScannerSerializer(serializers.ModelSerializer):
"estimated_monthly_observations",
"credits_per_observation",
"estimated_monthly_credits",
+ "credits_this_month",
"last_swept_at",
"created_at",
"created_by",
@@ -298,6 +313,7 @@ class ReplayScannerSerializer(serializers.ModelSerializer):
"estimated_monthly_observations",
"credits_per_observation",
"estimated_monthly_credits",
+ "credits_this_month",
"last_swept_at",
"created_at",
"created_by",
@@ -315,6 +331,18 @@ class ReplayScannerSerializer(serializers.ModelSerializer):
return None
return scanner.estimated_monthly_observations * observation_credits_for_model(scanner.model)
+ @extend_schema_field(serializers.IntegerField())
+ def get_credits_this_month(self, scanner: ReplayScanner) -> int:
+ # The context dict is shared across the list's children, so the page's totals are computed once.
+ totals = self.context.get("_scanner_credits_used")
+ if totals is None:
+ root = self.root
+ instance = root.instance if isinstance(root, serializers.ListSerializer) else None
+ scanner_ids = [s.id for s in instance] if instance is not None else [scanner.id]
+ totals = credits_used_by_scanner(self.context["get_team"]().organization_id, scanner_ids)
+ self.context["_scanner_credits_used"] = totals
+ return totals.get(scanner.id, 0)
+
def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
# Surface the (team_id, name) uniqueness as a 400 instead of letting the DB raise 500.
name = attrs.get("name")
@@ -425,6 +453,7 @@ SCANNER_ORDER_FIELDS = (
"enabled",
"sampling_rate",
"created_by",
+ "credits_this_month",
)
_SCANNER_ENABLED_CHOICES = frozenset({"enabled", "disabled"})
# Map `?enabled=true/false/1/0` to the CSV form so the conventional boolean stays supported.
@@ -437,6 +466,28 @@ class _ScannerOrderByFilter(OrderByFilter):
_allowed_keys = frozenset(SCANNER_ORDER_FIELDS)
def _handle(self, qs: QuerySet[ReplayScanner], key: str, descending: bool) -> QuerySet[ReplayScanner]:
+ if key == "credits_this_month":
+ # Same window and pricing as `credits_this_month`, in SQL so the database can order by it.
+ organization_id = qs.values_list("team__organization_id", flat=True).first()
+ if organization_id is None:
+ return qs.order_by(self._tiebreaker)
+ period_start, period_end = current_period_bounds(organization_id)
+ spend = (
+ ReplayObservation.objects.filter(
+ scanner_id=OuterRef("pk"),
+ status=ObservationStatus.SUCCEEDED,
+ created_at__gte=period_start,
+ created_at__lt=period_end,
+ )
+ .order_by()
+ .values("scanner_id")
+ .annotate(total=Sum(observation_credits_case()))
+ .values("total")
+ )
+ qs = qs.annotate(
+ _order_credits=Coalesce(Subquery(spend, output_field=IntegerField()), Value(0)),
+ )
+ return self._order_plain(qs, "_order_credits", descending)
if key == "created_by":
# Mirrors the frontend `createdByLabel` fallback so a row rendered "Brown" sorts on "Brown", not its email.
qs = qs.annotate(
@@ -474,10 +525,7 @@ class ReplayScannerFilter(django_filters.FilterSet):
help_text="Case-insensitive substring match across name, description, and the prompt in scanner_config.",
)
order_by = _ScannerOrderByFilter(
- help_text=(
- "Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, or "
- "created_by. Prefix with `-` for descending."
- ),
+ help_text=f"Sort scanners by {', '.join(SCANNER_ORDER_FIELDS)}. Prefix with `-` for descending.",
)
class Meta:
@@ -826,10 +874,7 @@ class AffectedCohortResponseSerializer(serializers.Serializer):
OpenApiParameter.QUERY,
required=False,
enum=ordering_enum(SCANNER_ORDER_FIELDS),
- description=(
- "Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, or "
- "created_by. Prefix with `-` for descending."
- ),
+ description=(f"Sort scanners by {', '.join(SCANNER_ORDER_FIELDS)}. Prefix with `-` for descending."),
)
]
)
diff --git a/products/replay_vision/backend/billing.py b/products/replay_vision/backend/billing.py
index f43a066bee60..bea7334684bb 100644
--- a/products/replay_vision/backend/billing.py
+++ b/products/replay_vision/backend/billing.py
@@ -8,7 +8,7 @@ price changes never reprice history.
from datetime import datetime
from typing import cast
-from django.db.models import IntegerField, Sum
+from django.db.models import Case, IntegerField, Sum, Value, When
from django.db.models.functions import Coalesce
import structlog
@@ -42,6 +42,18 @@ def observation_credits_for_model(model: str) -> int:
return credits
+def observation_credits_case() -> Case:
+ """SQL mirror of `observation_credits_for_model`, for pricing observations inside a query."""
+ return Case(
+ *(
+ When(scanner_snapshot__model=model, then=Value(credits))
+ for model, credits in OBSERVATION_CREDITS_BY_MODEL.items()
+ ),
+ default=Value(_FALLBACK_CREDITS),
+ output_field=IntegerField(),
+ )
+
+
def get_replay_vision_credits_by_team(begin: datetime, end: datetime) -> list[tuple[int, int]]:
# Bucket by receipt write time so a late receipt is never dropped from an already-run daily report.
rows = (
diff --git a/products/replay_vision/backend/quota.py b/products/replay_vision/backend/quota.py
index 8a4e2151bbd9..238cf62249cf 100644
--- a/products/replay_vision/backend/quota.py
+++ b/products/replay_vision/backend/quota.py
@@ -14,7 +14,11 @@ from posthog.models.organization import Organization
from posthog.settings.utils import get_from_env
from products.replay_vision.backend.billing import observation_credits_for_model
-from products.replay_vision.backend.models.replay_observation import IN_FLIGHT_STATUSES, ReplayObservation
+from products.replay_vision.backend.models.replay_observation import (
+ IN_FLIGHT_STATUSES,
+ ObservationStatus,
+ ReplayObservation,
+)
from products.replay_vision.backend.models.replay_observation_usage import ReplayObservationUsage
from products.replay_vision.backend.models.replay_quota_grant import ReplayQuotaGrant
from products.replay_vision.backend.models.replay_scanner import ReplayScanner
@@ -69,6 +73,47 @@ def _as_utc(value: datetime) -> datetime:
return value if value.tzinfo else value.replace(tzinfo=UTC)
+def _current_period_bounds(organization: Organization | None, now: datetime) -> tuple[datetime, datetime]:
+ """The org's active billing period when synced and current, else the calendar month containing `now`."""
+ billing_period = organization.current_billing_period if organization else None
+ if billing_period:
+ billing_period = (_as_utc(billing_period[0]), _as_utc(billing_period[1]))
+ if billing_period[0] <= now < billing_period[1]:
+ return billing_period
+ return _current_month_bounds(now)
+
+
+def current_period_bounds(organization_id: UUID) -> tuple[datetime, datetime]:
+ """The org's active billing period when synced and current, else the current calendar month."""
+ organization = Organization.objects.filter(pk=organization_id).only("usage").first()
+ return _current_period_bounds(organization, datetime.now(UTC))
+
+
+def credits_used_by_scanner(organization_id: UUID, scanner_ids: list[UUID]) -> dict[UUID, int]:
+ """Credits each scanner's succeeded observations consumed in the current billing period.
+
+ Priced at current rates from each observation's frozen snapshot model. Receipts freeze prices
+ at success time, so these totals can drift from the billed ledger after a mid-period price
+ change. Scanners with no spend are omitted.
+ """
+ if not scanner_ids:
+ return {}
+ period_start, period_end = current_period_bounds(organization_id)
+ pairs = Counter(
+ ReplayObservation.objects.filter(
+ scanner_id__in=scanner_ids,
+ team__organization_id=organization_id,
+ status=ObservationStatus.SUCCEEDED,
+ created_at__gte=period_start,
+ created_at__lt=period_end,
+ ).values_list("scanner_id", "scanner_snapshot__model")
+ )
+ totals: dict[UUID, int] = {}
+ for (scanner_id, model), count in pairs.items():
+ totals[scanner_id] = totals.get(scanner_id, 0) + observation_credits_for_model(model or "") * count
+ return totals
+
+
def sum_enabled_scanner_estimated_credits(organization_id: UUID, exclude_scanner_id: UUID | None = None) -> int:
"""Projected monthly credit spend from the org's enabled scanners' cached estimates."""
scanners = ReplayScanner.objects.filter(team__organization_id=organization_id, enabled=True)
@@ -107,13 +152,7 @@ def compute_quota_snapshot(organization_id: UUID) -> QuotaSnapshot:
now = datetime.now(UTC)
organization = Organization.objects.filter(pk=organization_id).only("usage").first()
# Billing is the source of truth once synced, falling back to the env cap and calendar months otherwise.
- billing_period = organization.current_billing_period if organization else None
- if billing_period:
- billing_period = (_as_utc(billing_period[0]), _as_utc(billing_period[1]))
- if billing_period and billing_period[0] <= now < billing_period[1]:
- period_start, period_end = billing_period
- else:
- period_start, period_end = _current_month_bounds(now)
+ period_start, period_end = _current_period_bounds(organization, now)
# Permanently-spent (succeeded) from the immutable ledger; deletes can't refund it.
consumed = ReplayObservationUsage.objects.filter(
organization_id=organization_id,
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index d5578dfc7b54..df79ac260975 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -1,10 +1,10 @@
-from datetime import timedelta
+from datetime import UTC, datetime, timedelta
from typing import Any
from posthog.test.base import APIBaseTest, ClickhouseTestMixin
from unittest.mock import MagicMock, patch
-from django.test import override_settings
+from django.test import SimpleTestCase, override_settings
from django.utils import timezone
from parameterized import parameterized
@@ -14,6 +14,7 @@ from posthog.models import Organization, PersonalAPIKey, Team, User
from posthog.models.utils import generate_random_token_personal, hash_key_value, uuid7
from posthog.session_recordings.queries.test.session_replay_sql import produce_replay_summary
+from products.replay_vision.backend.billing import observation_credits_for_model
from products.replay_vision.backend.digest import SCANNER_DIGEST_RRULE
from products.replay_vision.backend.models.replay_observation import (
ObservationStatus,
@@ -28,6 +29,7 @@ from products.replay_vision.backend.models.replay_scanner import (
)
from products.replay_vision.backend.models.vision_action import VisionAction
from products.replay_vision.backend.queries.scanner_candidate_query import SETTLE_INTERVAL
+from products.replay_vision.backend.quota import _current_period_bounds
from products.replay_vision.backend.temporal.constants import (
APPLY_SCANNER_WORKFLOW_NAME,
build_apply_scanner_workflow_id,
@@ -1990,3 +1992,86 @@ class TestReplayScannerEstimateAction(ClickhouseTestMixin, _VisionAPITestCase):
resp = self.client.post(self.estimate_url, data={"scanner_id": str(other_scanner.id)}, format="json")
self.assertEqual(resp.status_code, 400, resp.json())
self.assertEqual(resp.json()["attr"], "scanner_id")
+
+
+class TestScannerSpend(_VisionAPITestCase):
+ def _succeeded_observation(self, scanner: ReplayScanner, session_id: str, created_at=None) -> ReplayObservation:
+ observation = ReplayObservation.objects.create(
+ scanner=scanner,
+ session_id=session_id,
+ scanner_snapshot=_snapshot_for(scanner),
+ triggered_by=ObservationTrigger.SCHEDULE,
+ status=ObservationStatus.SUCCEEDED,
+ completed_at=timezone.now(),
+ )
+ if created_at is not None:
+ ReplayObservation.objects.filter(pk=observation.pk).update(created_at=created_at)
+ return observation
+
+ def _credits_by_name(self, response_json: dict) -> dict[str, int]:
+ return {row["name"]: row["credits_this_month"] for row in response_json["results"]}
+
+ def test_credits_this_month_sums_current_period_succeeded_observations(self) -> None:
+ spender = self._create_scanner(name="spender")
+ self._create_scanner(name="idle")
+ self._succeeded_observation(spender, "in-window-1")
+ self._succeeded_observation(spender, "in-window-2")
+ ReplayObservation.objects.create(
+ scanner=spender,
+ session_id="failed-in-window",
+ scanner_snapshot=_snapshot_for(spender),
+ triggered_by=ObservationTrigger.SCHEDULE,
+ status=ObservationStatus.FAILED,
+ completed_at=timezone.now(),
+ )
+ self._succeeded_observation(spender, "last-period", created_at=timezone.now() - timedelta(days=45))
+
+ resp = self.client.get(self.scanners_url)
+ self.assertEqual(resp.status_code, 200, resp.json())
+ credits = self._credits_by_name(resp.json())
+ self.assertEqual(credits["spender"], 2 * observation_credits_for_model(spender.model))
+ self.assertEqual(credits["idle"], 0)
+
+ def test_order_by_credits_matches_displayed_values(self) -> None:
+ low = self._create_scanner(name="low")
+ high = self._create_scanner(name="high")
+ self._succeeded_observation(low, "low-1")
+ for i in range(3):
+ self._succeeded_observation(high, f"high-{i}")
+
+ resp = self.client.get(f"{self.scanners_url}?order_by=-credits_this_month")
+ self.assertEqual(resp.status_code, 200, resp.json())
+ rows = resp.json()["results"]
+ displayed = [row["credits_this_month"] for row in rows]
+ self.assertEqual(displayed, sorted(displayed, reverse=True))
+ self.assertEqual([row["name"] for row in rows[:2]], ["high", "low"])
+
+
+class TestCurrentPeriodBounds(SimpleTestCase):
+ NOW = datetime(2026, 7, 15, 12, 0, tzinfo=UTC)
+ MONTH_BOUNDS = (datetime(2026, 7, 1, tzinfo=UTC), datetime(2026, 8, 1, tzinfo=UTC))
+
+ @parameterized.expand(
+ [
+ ("no_organization", None, MONTH_BOUNDS),
+ ("no_usage", {}, MONTH_BOUNDS),
+ (
+ "current_billing_period",
+ {"period": ["2026-07-10T00:00:00+00:00", "2026-08-10T00:00:00+00:00"]},
+ (datetime(2026, 7, 10, tzinfo=UTC), datetime(2026, 8, 10, tzinfo=UTC)),
+ ),
+ (
+ "stale_billing_period_falls_back_to_month",
+ {"period": ["2026-05-10T00:00:00+00:00", "2026-06-10T00:00:00+00:00"]},
+ MONTH_BOUNDS,
+ ),
+ (
+ "naive_timestamps_treated_as_utc",
+ {"period": ["2026-07-10T00:00:00", "2026-08-10T00:00:00"]},
+ (datetime(2026, 7, 10, tzinfo=UTC), datetime(2026, 8, 10, tzinfo=UTC)),
+ ),
+ ]
+ )
+ def test_period_selection(self, _name: str, usage: dict | None, expected: tuple[datetime, datetime]) -> None:
+ organization = Organization(usage=usage) if usage is not None else None
+ self.assertEqual(_current_period_bounds(organization, self.NOW), expected)
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index 1f85048f8bac..1bca88f43d95 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -795,6 +795,8 @@ export interface ReplayScannerApi {
* @nullable
*/
readonly estimated_monthly_credits: number | null
+ /** Credits this scanner's succeeded observations consumed in the current billing period (1 credit = $0.01). Matches the window of the org-wide quota meter. */
+ readonly credits_this_month: number
/** Watermark for the scanner's last scheduled fire. Mirrors Temporal schedule state for recovery. */
readonly last_swept_at: string
readonly created_at: string
@@ -877,6 +879,8 @@ export interface PatchedReplayScannerApi {
* @nullable
*/
readonly estimated_monthly_credits?: number | null
+ /** Credits this scanner's succeeded observations consumed in the current billing period (1 credit = $0.01). Matches the window of the org-wide quota meter. */
+ readonly credits_this_month?: number
/** Watermark for the scanner's last scheduled fire. Mirrors Temporal schedule state for recovery. */
readonly last_swept_at?: string
readonly created_at?: string
@@ -1494,7 +1498,7 @@ export type VisionScannersListParams = {
*/
offset?: number
/**
- * Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, or created_by. Prefix with `-` for descending.
+ * Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, created_by, credits_this_month. Prefix with `-` for descending.
*/
order_by?: string
/**
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
index 48c103d0aa61..a6dca82efec2 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
@@ -27,6 +27,7 @@ import { FilterPill } from '../components/FilterPill'
import { IngestionLimitBanner } from '../components/IngestionLimitBanner'
import { ReplayVisionFeedbackButton } from '../components/ReplayVisionFeedbackButton'
import { ScannerTypeBadge } from '../components/ScannerTypeBadge'
+import { formatCredits } from '../utils/credits'
import { VisionMetrics } from './components/VisionMetrics'
import { type ScannersSorting, SCANNERS_PAGE_SIZE, replayScannersLogic } from './replayScannersLogic'
import { ENABLED_OPTIONS, EnabledFilter, SCANNER_TYPE_OPTIONS, ScannerType, ReplayScanner } from './types'
@@ -132,6 +133,14 @@ export function ReplayScannersScene(): JSX.Element {
),
sorter: true,
},
+ {
+ title: 'Spend this month',
+ key: 'credits_this_month',
+ render: (_, scanner) => (
+ <span className="text-sm tabular-nums">{formatCredits(scanner.credits_this_month)}</span>
+ ),
+ sorter: true,
+ },
{
title: 'Created by',
key: 'created_by',
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannersLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannersLogic.ts
index af0ae18a63f9..7bdc5db10434 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannersLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannersLogic.ts
@@ -41,6 +41,7 @@ export const SORTABLE_COLUMN_KEYS = [
'created_by',
'created_at',
'updated_at',
+ 'credits_this_month',
] as const
export type ScannerOrderKey = (typeof SORTABLE_COLUMN_KEYS)[number]
diff --git a/products/replay_vision/frontend/replay_scanners/scannerTemplates.ts b/products/replay_vision/frontend/replay_scanners/scannerTemplates.ts
index 3a63539af3ce..67f1ead2b065 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerTemplates.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerTemplates.ts
@@ -140,6 +140,7 @@ export function newScanner(templateKey?: string | null): ReplayScanner {
estimated_monthly_credits: null,
// Seed price for the unsaved scanner; the server-computed value takes over after the first save.
credits_per_observation: OBSERVATION_CREDITS_BY_MODEL[DEFAULT_MODEL],
+ credits_this_month: 0,
} as const
const template = findScannerTemplate(templateKey ?? undefined)
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index b87238359557..cca298eefc7e 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -39022,6 +39022,8 @@ export namespace Schemas {
* @nullable
*/
readonly estimated_monthly_credits: number | null;
+ /** Credits this scanner's succeeded observations consumed in the current billing period (1 credit = $0.01). Matches the window of the org-wide quota meter. */
+ readonly credits_this_month: number;
/** Watermark for the scanner's last scheduled fire. Mirrors Temporal schedule state for recovery. */
readonly last_swept_at: string;
readonly created_at: string;
@@ -47503,6 +47505,8 @@ export namespace Schemas {
* @nullable
*/
readonly estimated_monthly_credits?: number | null;
+ /** Credits this scanner's succeeded observations consumed in the current billing period (1 credit = $0.01). Matches the window of the org-wide quota meter. */
+ readonly credits_this_month?: number;
/** Watermark for the scanner's last scheduled fire. Mirrors Temporal schedule state for recovery. */
readonly last_swept_at?: string;
readonly created_at?: string;
@@ -70258,7 +70262,7 @@ export namespace Schemas {
*/
offset?: number;
/**
- * Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, or created_by. Prefix with `-` for descending.
+ * Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, created_by, credits_this_month. Prefix with `-` for descending.
*/
order_by?: string;
/**
@@ -79228,7 +79232,7 @@ export namespace Schemas {
*/
offset?: number;
/**
- * Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, or created_by. Prefix with `-` for descending.
+ * Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, created_by, credits_this_month. Prefix with `-` for descending.
*/
order_by?: string;
/**
diff --git a/services/mcp/src/generated/replay_vision/api.ts b/services/mcp/src/generated/replay_vision/api.ts
index 6c53e8df237d..4959d8adbf56 100644
--- a/services/mcp/src/generated/replay_vision/api.ts
+++ b/services/mcp/src/generated/replay_vision/api.ts
@@ -153,7 +153,7 @@ export const VisionScannersListQueryParams = /* @__PURE__ */ zod.object({
.string()
.optional()
.describe(
- 'Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, or created_by. Prefix with `-` for descending.'
+ 'Sort scanners by name, created_at, updated_at, scanner_type, enabled, sampling_rate, created_by, credits_this_month. Prefix with `-` for descending.'
),
scanner_type: zod
.string()