Skip to content

Commit

Permalink
chore: remove rollbar from ai streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
SiTaggart committed Oct 26, 2023
1 parent c2a45e6 commit 27042ca
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions packages/paste-website/src/pages/api/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ import {
type CreateModerationResponse,
OpenAIApi,
} from "openai-edge";
import Rollbar from "rollbar";

const rollbar = new Rollbar({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
captureUncaught: true,
captureUnhandledRejections: true,
});

class ApplicationError extends Error {
// eslint-disable-next-line @typescript-eslint/no-parameter-properties
Expand All @@ -51,6 +44,11 @@ const config = new Configuration({
});
const openai = new OpenAIApi(config);

/**
* Because we're using an edge function for streaming we can't use winston for logging
* or rollbar for error reporting. Instead we'll use console.log and console.error and
* Datadog synthetics to monitor up time.
*/
export const runtime = "edge";

const LOG_PREFIX = "[/api/ai]:";
Expand Down Expand Up @@ -232,7 +230,6 @@ export default async function handler(req: NextRequest): Promise<void | Response
if (error instanceof UserError) {
// eslint-disable-next-line no-console
console.error(`${LOG_PREFIX} User error`, { error });
rollbar.error(error);

return new Response(
JSON.stringify({
Expand All @@ -248,12 +245,10 @@ export default async function handler(req: NextRequest): Promise<void | Response
// Print out application errors with their additional data
// eslint-disable-next-line no-console
console.error(`${LOG_PREFIX} ${error.message}: ${JSON.stringify(error.data)}`);
rollbar.error(error);
} else {
// Print out unexpected errors as is to help with debugging
// eslint-disable-next-line no-console
console.error(`${LOG_PREFIX} ${error}`);
rollbar.error(error as Error);
}

return new Response(
Expand Down

0 comments on commit 27042ca

Please sign in to comment.