import { z } from "zod";

export const telemetryTypeSchema = z.enum([
	"start",
	"step_view",
	"choice",
	"complete",
	"dismiss",
	"target_lost",
]);

export const telemetryEventSchema = z.object({
	type: telemetryTypeSchema,
	tourId: z.string().uuid(),
	tourVersion: z.number().int().positive(),
	stepId: z.string().optional(),
	choiceId: z.string().optional(),
	sessionId: z.string().min(1),
});

export const telemetryBatchSchema = z.object({
	key: z.string().min(1),
	events: z.array(telemetryEventSchema).min(1).max(50),
});

export type TelemetryEvent = z.infer<typeof telemetryEventSchema>;
export type TelemetryBatch = z.infer<typeof telemetryBatchSchema>;
