From a832a7dfaab71842b04dc6178d3d02922628c208 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Mon, 18 May 2026 15:38:48 +0000 Subject: [PATCH] feat(core-shared): add AnalyticsProtocol to BindContext and BindProductionContext Adds analytics?: Analytics generic field to both BindContext and BindProductionContext in bind-context.ts, mirroring the pattern used by IEventBus, IAuditLog, and IJobQueue. AnalyticsProtocol already existed in bind-protocols.ts and is re-exported from the @repo/core-shared/di barrel via the existing wildcard export. Also adds a type-level test for AnalyticsProtocol in bind-protocols.test.ts to match test coverage for the other protocol types. Co-Authored-By: Claude Sonnet 4.6 --- packages/core-shared/src/di/bind-context.ts | 6 +++++- packages/core-shared/src/di/bind-protocols.test.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/core-shared/src/di/bind-context.ts b/packages/core-shared/src/di/bind-context.ts index 9614bd2..91b074d 100644 --- a/packages/core-shared/src/di/bind-context.ts +++ b/packages/core-shared/src/di/bind-context.ts @@ -7,6 +7,7 @@ import type { RealtimeRegistryProtocol, MetricsProtocol, AuditLogProtocol, + AnalyticsProtocol, } from "./bind-protocols"; /** Always-present fields. Feature binders rely on these unconditionally. */ @@ -33,6 +34,7 @@ export type BindContext< RealtimeReg extends RealtimeRegistryProtocol = RealtimeRegistryProtocol, Metrics extends MetricsProtocol = MetricsProtocol, Audit extends AuditLogProtocol = AuditLogProtocol, + Analytics extends AnalyticsProtocol = AnalyticsProtocol, > = BindContextBase & { bus?: Bus; queue?: IJobQueue; @@ -40,6 +42,7 @@ export type BindContext< realtimeRegistry?: RealtimeReg; metrics?: Metrics; auditLog?: Audit; + analytics?: Analytics; }; /** Production binders also receive the resolved Payload config. */ @@ -49,6 +52,7 @@ export type BindProductionContext< RealtimeReg extends RealtimeRegistryProtocol = RealtimeRegistryProtocol, Metrics extends MetricsProtocol = MetricsProtocol, Audit extends AuditLogProtocol = AuditLogProtocol, -> = BindContext & { + Analytics extends AnalyticsProtocol = AnalyticsProtocol, +> = BindContext & { config: SanitizedConfig; }; diff --git a/packages/core-shared/src/di/bind-protocols.test.ts b/packages/core-shared/src/di/bind-protocols.test.ts index 90a5783..5601cc3 100644 --- a/packages/core-shared/src/di/bind-protocols.test.ts +++ b/packages/core-shared/src/di/bind-protocols.test.ts @@ -3,6 +3,7 @@ import type { EventBusProtocol, RealtimeBroadcasterProtocol, RealtimeRegistryProtocol, + AnalyticsProtocol, } from "./bind-protocols"; // Protocol-shape tests. These verify each protocol type EXPORTS the @@ -36,3 +37,10 @@ describe("RealtimeRegistryProtocol", () => { expectTypeOf().toBeFunction(); }); }); + +describe("AnalyticsProtocol", () => { + it("requires track(event, attributes?)", () => { + type A = AnalyticsProtocol; + expectTypeOf().toBeFunction(); + }); +});