File tree Expand file tree Collapse file tree 4 files changed +36
-9
lines changed
web/src/app/api/auth/[...nextauth] Expand file tree Collapse file tree 4 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,12 @@ async function syncMessageToStripe(messageData: {
301301 { ...logContext , error : errorMessage } ,
302302 'Failed to sync usage to Stripe after retries.' ,
303303 )
304- await logSyncFailure ( messageId , errorMessage , 'stripe' )
304+ await logSyncFailure ( {
305+ id : messageId ,
306+ errorMessage,
307+ provider : 'stripe' ,
308+ logger,
309+ } )
305310 }
306311}
307312
Original file line number Diff line number Diff line change 11import { sql } from 'drizzle-orm'
22
33import db from '../db'
4- import { logger } from './logger'
54import * as schema from '../db/schema'
65
7- export async function logSyncFailure (
8- id : string ,
9- errorMessage : string ,
6+ import type { Logger } from '@codebuff/types/logger'
7+
8+ export async function logSyncFailure ( {
9+ id,
10+ errorMessage,
1011 provider = 'stripe' ,
11- ) : Promise < void > {
12+ logger,
13+ } : {
14+ id : string
15+ errorMessage : string
16+ provider : string
17+ logger : Logger
18+ } ) : Promise < void > {
1219 try {
1320 await db
1421 . insert ( schema . syncFailure )
Original file line number Diff line number Diff line change @@ -259,7 +259,12 @@ export async function processAndGrantCredit(
259259 } ,
260260 )
261261 } catch ( error : any ) {
262- await logSyncFailure ( operationId , error . message , 'internal' )
262+ await logSyncFailure ( {
263+ id : operationId ,
264+ errorMessage : error . message ,
265+ provider : 'internal' ,
266+ logger,
267+ } )
263268 logger . error (
264269 { operationId, error } ,
265270 'processAndGrantCredit failed after retries, logged to sync_failure' ,
Original file line number Diff line number Diff line change @@ -67,7 +67,12 @@ async function createAndLinkStripeCustomer(
6767 { userId, error } ,
6868 'Failed to create Stripe customer or update user record.'
6969 )
70- await logSyncFailure ( userId , errorMessage )
70+ await logSyncFailure ( {
71+ id : userId ,
72+ errorMessage,
73+ provider : 'stripe' ,
74+ logger,
75+ } )
7176 return null
7277 }
7378}
@@ -107,7 +112,12 @@ async function createInitialCreditGrant(
107112 { userId, error : grantError } ,
108113 'Failed to create initial credit grant.'
109114 )
110- await logSyncFailure ( userId , errorMessage )
115+ await logSyncFailure ( {
116+ id : userId ,
117+ errorMessage,
118+ provider : 'stripe' ,
119+ logger,
120+ } )
111121 }
112122}
113123
You can’t perform that action at this time.
0 commit comments