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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<Bus, Realtime, RealtimeReg, Metrics, Audit> & {
|
||||
Analytics extends AnalyticsProtocol = AnalyticsProtocol,
|
||||
> = BindContext<Bus, Realtime, RealtimeReg, Metrics, Audit, Analytics> & {
|
||||
config: SanitizedConfig;
|
||||
};
|
||||
|
||||
@@ -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<Reg["listChannels"]>().toBeFunction();
|
||||
});
|
||||
});
|
||||
|
||||
describe("AnalyticsProtocol", () => {
|
||||
it("requires track(event, attributes?)", () => {
|
||||
type A = AnalyticsProtocol;
|
||||
expectTypeOf<A["track"]>().toBeFunction();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user