Add plugin telemetry bridge capability

Expose telemetry.track through the plugin SDK and server host bridge, forward plugin-prefixed events into the shared telemetry client, and demonstrate the capability in the kitchen sink example.\n\nCo-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-31 13:18:50 -05:00
parent 53dbcd185e
commit af844b778e
14 changed files with 209 additions and 1 deletions

View file

@ -71,6 +71,7 @@ export interface TestHarness {
logs: TestHarnessLogEntry[];
activity: Array<{ message: string; entityType?: string; entityId?: string; metadata?: Record<string, unknown> }>;
metrics: Array<{ name: string; value: number; tags?: Record<string, string> }>;
telemetry: Array<{ eventName: string; dimensions?: Record<string, string | number | boolean> }>;
}
type EventRegistration = {
@ -132,6 +133,7 @@ export function createTestHarness(options: TestHarnessOptions): TestHarness {
const logs: TestHarnessLogEntry[] = [];
const activity: TestHarness["activity"] = [];
const metrics: TestHarness["metrics"] = [];
const telemetry: TestHarness["telemetry"] = [];
const state = new Map<string, unknown>();
const entities = new Map<string, PluginEntityRecord>();
@ -631,6 +633,12 @@ export function createTestHarness(options: TestHarnessOptions): TestHarness {
metrics.push({ name, value, tags });
},
},
telemetry: {
async track(eventName, dimensions) {
requireCapability(manifest, capabilitySet, "telemetry.track");
telemetry.push({ eventName, dimensions });
},
},
logger: {
info(message, meta) {
logs.push({ level: "info", message, meta });
@ -729,6 +737,7 @@ export function createTestHarness(options: TestHarnessOptions): TestHarness {
logs,
activity,
metrics,
telemetry,
};
return harness;