@@ -21,6 +21,8 @@ import {
2121 incHibpNotifyFailure ,
2222} from "../../../../../utils/metrics" ;
2323
24+ import * as Sentry from "@sentry/nextjs" ;
25+
2426export type PostHibpNotificationRequestBody = {
2527 breachName : string ;
2628 hashPrefix : string ;
@@ -62,6 +64,7 @@ export async function POST(req: NextRequest) {
6264 logger . error ( "error_processing_breach_alert_request:" , {
6365 exception : ex as string ,
6466 } ) ;
67+ Sentry . captureException ( ex ) ;
6568 incHibpNotifyFailure ( "server-error" ) ;
6669 return NextResponse . json ( { success : false } , { status : 500 } ) ;
6770 }
@@ -70,6 +73,7 @@ export async function POST(req: NextRequest) {
7073 pubsub = new PubSub ( { projectId, enableOpenTelemetryTracing : true } ) ;
7174 } catch ( ex ) {
7275 logger . error ( "error_connecting_to_pubsub:" , { exception : ex as string } ) ;
76+ Sentry . captureException ( ex ) ;
7377 incHibpNotifyFailure ( "pubsub-error" ) ;
7478 return NextResponse . json ( { success : false } , { status : 429 } ) ;
7579 }
@@ -82,6 +86,7 @@ export async function POST(req: NextRequest) {
8286 topic : topicName ,
8387 } ) ;
8488 incHibpNotifyFailure ( "pubsub-error" ) ;
89+ Sentry . captureException ( new Error ( "Pubsub topic does not exist" ) ) ;
8590 return NextResponse . json ( { success : false } , { status : 500 } ) ;
8691 }
8792 await topic . publishMessage ( { json } ) ;
@@ -90,9 +95,10 @@ export async function POST(req: NextRequest) {
9095 topic : topicName ,
9196 } ) ;
9297 return NextResponse . json ( { success : true } , { status : 200 } ) ;
93- } catch {
94- logger . error ( "error_queuing_hibp_breach:" , { topicName } ) ;
98+ } catch ( ex ) {
99+ logger . error ( "error_queuing_hibp_breach:" , { topicName, exception : ex } ) ;
95100 incHibpNotifyFailure ( "pubsub-error" ) ;
101+ Sentry . captureException ( ex ) ;
96102 return NextResponse . json ( { success : false } , { status : 429 } ) ;
97103 }
98104}
0 commit comments