feat(expiry): telemetry 2 events — expired_banner_shown / expired_batch_trash (#5 v0.2.3)

This commit is contained in:
altair823
2026-05-02 00:08:44 +09:00
parent fec80361dd
commit f76ca06d9e
6 changed files with 105 additions and 9 deletions

View File

@@ -101,3 +101,26 @@ describe('aggregateStats — trash family (v0.2.3 #4)', () => {
expect(r.md).toContain('휴지통 회수율: N/A');
});
});
describe('aggregateStats — expired_banner_shown / expired_batch_trash', () => {
it('counts both kinds per day and computes 만료 trash ratio', () => {
const events = [
{ ts: '2026-05-01T00:00:00.000Z', kind: 'expired_banner_shown' as const, payload: { candidateCount: 5 } },
{ ts: '2026-05-01T01:00:00.000Z', kind: 'expired_banner_shown' as const, payload: { candidateCount: 3 } },
{ ts: '2026-05-01T02:00:00.000Z', kind: 'expired_batch_trash' as const, payload: { count: 4 } }
];
const r = aggregateStats(events, new Date('2026-05-02T00:00:00Z'));
expect(r.md).toContain('expired_banner_shown');
expect(r.md).toContain('expired_batch_trash');
// 4 / (5 + 3) = 50.0%
expect(r.md).toMatch(/만료 trash ratio.*50\.0%/);
});
it('shows N/A when 만료 배너 노출 0건', () => {
const events = [
{ ts: '2026-05-01T00:00:00.000Z', kind: 'capture' as const, payload: { noteId: 'a', rawTextLength: 1, hasMedia: false } }
];
const r = aggregateStats(events, new Date('2026-05-02T00:00:00Z'));
expect(r.md).toMatch(/만료 trash ratio.*N\/A/);
});
});