feat(telemetry): CaptureService emits capture event (#7 v0.2.3)
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user