Skip to content

Commit de2fbbe

Browse files
authored
Merge pull request #12 from RooCodeInc/cte/fix-event-schema
2 parents ba56b93 + 84f4931 commit de2fbbe

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/app/api/events/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export async function POST(request: NextRequest) {
2020
const result = cloudEventSchema.safeParse(await request.json());
2121

2222
if (!result.success) {
23+
console.error(result.error);
24+
2325
return NextResponse.json(
2426
{ success: false, error: result.error.message },
2527
{ status: 400 },

src/schemas/index.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { z } from 'zod';
33
// TODO: I'll add these types to our @roo-code/types NPM package so we
44
// don't need to manually copy them.
55

6-
// Copied from `src/schemas/index.ts`
7-
86
export const providerNames = [
97
'anthropic',
108
'glama',
@@ -29,8 +27,6 @@ export const providerNames = [
2927
'litellm',
3028
] as const;
3129

32-
// Copied from `src/services/telemetry/types.ts`
33-
3430
export const appPropertiesSchema = z.object({
3531
appVersion: z.string(),
3632
vscodeVersion: z.string(),
@@ -56,23 +52,42 @@ export const completionPropertiesSchema = z.object({
5652
cost: z.number().optional(),
5753
});
5854

59-
// Copied from `src/services/cloud/types.ts`.
55+
export enum TelemetryEventName {
56+
TASK_CREATED = 'Task Created',
57+
TASK_RESTARTED = 'Task Reopened',
58+
TASK_COMPLETED = 'Task Completed',
59+
TASK_CONVERSATION_MESSAGE = 'Conversation Message',
60+
LLM_COMPLETION = 'LLM Completion',
61+
MODE_SWITCH = 'Mode Switched',
62+
TOOL_USED = 'Tool Used',
63+
64+
CHECKPOINT_CREATED = 'Checkpoint Created',
65+
CHECKPOINT_RESTORED = 'Checkpoint Restored',
66+
CHECKPOINT_DIFFED = 'Checkpoint Diffed',
67+
68+
CODE_ACTION_USED = 'Code Action Used',
69+
PROMPT_ENHANCED = 'Prompt Enhanced',
70+
71+
TITLE_BUTTON_CLICKED = 'Title Button Clicked',
72+
73+
AUTHENTICATION_INITIATED = 'Authentication Initiated',
6074

61-
export enum CloudEventType {
62-
TaskCreated = 'task_created',
63-
Completion = 'completion',
75+
SCHEMA_VALIDATION_ERROR = 'Schema Validation Error',
76+
DIFF_APPLICATION_ERROR = 'Diff Application Error',
77+
SHELL_INTEGRATION_ERROR = 'Shell Integration Error',
78+
CONSECUTIVE_MISTAKE_ERROR = 'Consecutive Mistake Error',
6479
}
6580

6681
export const cloudEventSchema = z.discriminatedUnion('type', [
6782
z.object({
68-
type: z.literal(CloudEventType.TaskCreated),
83+
type: z.literal(TelemetryEventName.TASK_CREATED),
6984
properties: z.object({
7085
...appPropertiesSchema.shape,
7186
...taskPropertiesSchema.shape,
7287
}),
7388
}),
7489
z.object({
75-
type: z.literal(CloudEventType.Completion),
90+
type: z.literal(TelemetryEventName.LLM_COMPLETION),
7691
properties: z.object({
7792
...appPropertiesSchema.shape,
7893
...taskPropertiesSchema.shape,

0 commit comments

Comments
 (0)