Skip to content

Commit a6d62da

Browse files
Added logging + additional fields to error reporting function.
1 parent 1729144 commit a6d62da

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/errorReportingService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ErrorInfo } from 'react'
2+
import { logger } from '@/lib/logger'
23

34
// This is the relative path to the API endpoint we created.
45
const ERROR_REPORTING_ENDPOINT = '/api/errors'
@@ -19,6 +20,8 @@ export const reportError = async (error: Error, options?: ReportOptions): Promis
1920
const report = {
2021
message: error.message,
2122
stack: error.stack,
23+
errorInfo: options?.errorInfo || null,
24+
isFatal: options?.isFatal || false,
2225
platform: 'web', // Identify that the error came from the web client
2326
options,
2427
}
@@ -32,6 +35,6 @@ export const reportError = async (error: Error, options?: ReportOptions): Promis
3235
body: JSON.stringify(report),
3336
})
3437
} catch (e) {
35-
console.error('Failed to send error report:', e)
38+
logger.error('Failed to send error report:', e)
3639
}
3740
}

0 commit comments

Comments
 (0)