Files
agentic-dev/packages/core-analytics/src/analytics.interface.ts
Danijel Martinek 9b04fae975 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>
2026-07-10 16:25:09 +02:00

30 lines
837 B
TypeScript

import type { AnalyticsProtocol } from "@repo/core-shared/di/bind-protocols";
export type AnalyticsAttributeValue = string | number | boolean;
export type AnalyticsUser = {
id: string;
};
/**
* 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>,
): void;
identify(
user: AnalyticsUser,
attributes?: Record<string, AnalyticsAttributeValue>,
): void;
pageView(
path: string,
attributes?: Record<string, AnalyticsAttributeValue>,
): void;
flush(): Promise<void>;
}