feat: track received image outcomes

This commit is contained in:
jjbrunton committed 2026-08-08 18:53:11 +01:00
1 parent 50de1c180d
commit d819a0f1e6
15 files changed
+145 -21

No files matched your search

+2
View File
@@ -8,6 +8,7 @@ export const SentMessageSchema = z.strictObject({
message: z.string(),
sentAt: z.number(),
gotResponse: z.boolean(),
gotImage: z.boolean(),
responseCheckedAt: z.number().nullable(),
strategyId: z.string().nullable(),
chatRoomId: z.string().nullable(),
@@ -43,6 +44,7 @@ export const SuccessfulExampleSchema = z.strictObject({
responseSnippet: z.string().nullable(),
subreddit: z.string().nullable(),
createdAt: z.number(),
gotImage: z.boolean().optional(),
});
export const SuccessfulExamplesResponseSchema = z.array(SuccessfulExampleSchema);
+2
View File
@@ -5,6 +5,8 @@ const PerformanceFields = {
totalSent: z.number(),
totalResponses: z.number(),
responseRate: z.number(),
totalImages: z.number(),
imageRate: z.number(),
};
export const StatsResponseSchema = z.strictObject({
@@ -86,6 +86,7 @@ describe('dashboard endpoint contracts', () => {
message: 'Hello',
sentAt: 1_700_000_000_000,
gotResponse: false,
gotImage: false,
responseCheckedAt: null,
strategyId: null,
chatRoomId: null,
@@ -115,13 +116,13 @@ describe('dashboard endpoint contracts', () => {
it('validates each analytics response shape', () => {
expect(SubredditPerformanceResponseSchema.safeParse([{
subreddit: 'example', totalSent: 10, totalResponses: 4, responseRate: 40,
subreddit: 'example', totalSent: 10, totalResponses: 4, responseRate: 40, totalImages: 2, imageRate: 20,
}]).success).toBe(true);
expect(StrategyPerformanceResponseSchema.safeParse([{
strategyId: 'direct', totalSent: 10, totalResponses: 4, responseRate: 40, configured: true,
strategyId: 'direct', totalSent: 10, totalResponses: 4, responseRate: 40, totalImages: 2, imageRate: 20, configured: true,
}]).success).toBe(true);
expect(DailyTrendResponseSchema.safeParse([{
date: '2026-08-08', totalSent: 10, totalResponses: 4, responseRate: 40,
date: '2026-08-08', totalSent: 10, totalResponses: 4, responseRate: 40, totalImages: 2, imageRate: 20,
}]).success).toBe(true);
expect(DailyTrendResponseSchema.safeParse([{ date: '2026-08-08', totalSent: '10' }]).success).toBe(false);
});