fix(core-shared): derive Analyzed + RateLimited brands in binding slot

ProductionUseCase<I, O, M> only demanded Instrumented + Captured (+
Audited for mutating-with-audits). The boot assertion additionally
requires __analyzed for non-empty analyticsEvents and __rateLimited for
non-empty rateLimit, so the type-level gate under-promised what boot
enforces. The slot now derives both from the manifest entry; the
feature-scoped requiresConsent brand stays boot-only (documented).
Also make IAnalytics extend AnalyticsProtocol from
core-shared/di/bind-protocols so narrowing the ctx protocol fails
typecheck in core-analytics instead of drifting silently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-10 16:25:09 +02:00
parent bf04ad70b2
commit 9b04fae975
3 changed files with 72 additions and 12 deletions

View File

@@ -1,10 +1,18 @@
import type { AnalyticsProtocol } from "@repo/core-shared/di/bind-protocols";
export type AnalyticsAttributeValue = string | number | boolean;
export type AnalyticsUser = {
id: string;
};
export interface IAnalytics {
/**
* Product-analytics sink. Extends `AnalyticsProtocol` from
* `@repo/core-shared/di/bind-protocols` — the surface feature binders see via
* `ctx.analytics` — so narrowing the protocol fails typecheck here instead of
* silently drifting apart.
*/
export interface IAnalytics extends AnalyticsProtocol {
track(
event: string,
attributes?: Record<string, AnalyticsAttributeValue>,