Skip to content

Commit

Permalink
Lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
erbesharat committed Oct 27, 2024
1 parent 5844d0e commit 6aa8d74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ yargs(hideBin(process.argv))
(argv) => {
trackEvent(TelemetryEvents.INIT_COMMAND, { message: "Init command" });
initCommandHandler(argv.workdir);
}
},
)
// Annotate openai command
.command(
Expand Down Expand Up @@ -75,13 +75,13 @@ yargs(hideBin(process.argv))

if (!apiKey) {
console.error(
"Missing OpenAI API key. Please provide it via --apiKey or in a .napirc file using 'openaiApiKey' or 'openaiApiKeyFilePath'"
"Missing OpenAI API key. Please provide it via --apiKey or in a .napirc file using 'openaiApiKey' or 'openaiApiKeyFilePath'",
);
return;
}

annotateOpenAICommandHandler(napiConfig.entrypoint, apiKey);
}
},
)
// Split command
.command(
Expand All @@ -100,7 +100,7 @@ yargs(hideBin(process.argv))
}

splitCommandHandler(napiConfig.entrypoint, napiConfig.out);
}
},
)
// Open UI command
.command(
Expand Down Expand Up @@ -131,7 +131,7 @@ yargs(hideBin(process.argv))
createProxyMiddleware({
target: targetServiceUrl,
changeOrigin: true,
})
}),
);
} else {
app.use(express.static(path.join(__dirname, "../dist/app_dist")));
Expand All @@ -144,6 +144,6 @@ yargs(hideBin(process.argv))
console.info("Press Ctrl+C to stop the server");
openInBrowser(url);
});
}
},
)
.parse();
13 changes: 11 additions & 2 deletions packages/cli/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export enum TelemetryEvents {
USER_ACTION = "user_action",
}

export interface TelemetryEvent {
sessionId: string;
eventId: TelemetryEvents;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any;
timestamp: string;
}

const telemetry = new EventEmitter();
// TODO: @erbesharat: Deploy mongoose script to GCF and update the endpoint
const TELEMETRY_ENDPOINT =
Expand Down Expand Up @@ -48,7 +56,7 @@ telemetry.on("event", (data) => {
sendTelemetryData(data);
});

const sendTelemetryData = (data: any) => {
const sendTelemetryData = (data: TelemetryEvent) => {
try {
const url = new URL(TELEMETRY_ENDPOINT);
const options = {
Expand Down Expand Up @@ -85,8 +93,9 @@ const sendTelemetryData = (data: any) => {
}
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const trackEvent = (eventId: TelemetryEvents, eventData: any) => {
const telemetryPayload = {
const telemetryPayload: TelemetryEvent = {
sessionId: SESSION_ID,
eventId,
data: eventData,
Expand Down

0 comments on commit 6aa8d74

Please sign in to comment.