feat(telemetry): CaptureService emits capture event (#7 v0.2.3)

This commit is contained in:
altair823
2026-05-01 17:15:24 +09:00
parent 36a5c67ed6
commit f0cef95d3f
2 changed files with 70 additions and 0 deletions

View File

@@ -1,9 +1,16 @@
import type { NoteRepository } from '../repository/NoteRepository.js';
import type { MediaStore } from './MediaStore.js';
export interface TelemetryEmitter {
emit(input:
| { kind: 'capture'; payload: { noteId: string; rawTextLength: number; hasMedia: boolean } }
): Promise<void>;
}
export interface CaptureDeps {
enqueue: (noteId: string) => Promise<void>;
celebrate: (noteId: string) => void;
telemetry?: TelemetryEmitter;
}
export interface SubmitInput {
@@ -39,6 +46,16 @@ export class CaptureService {
}
this.repo.insertMedia(rows);
}
if (this.deps.telemetry) {
await this.deps.telemetry.emit({
kind: 'capture',
payload: {
noteId: id,
rawTextLength: input.text.length,
hasMedia: input.images.length > 0
}
});
}
await this.deps.enqueue(id);
this.deps.celebrate(id);
return { noteId: id };