import { ILogger } from 'polar-shared/src/logger/ILogger' ; import { captureException , init } from '@sentry/browser' ; import { SentryBrowser } from "./SentryBrowser" ; SentryBrowser . initWhenNecessary ( ) ; export class SentryBrowserLogger implements ILogger { public readonly name : string = 'sentry-browser-logger' ; public notice ( msg , ... args ) { SentryBrowser . initWhenNecessary ( ) ; } public warn ( msg , ... args ) { SentryBrowser . initWhenNecessary ( ) ; } public error ( msg , ... args ) { SentryBrowser . initWhenNecessary ( ) ; args . forEach ( arg => { if ( arg instanceof Error ) { try { captureException ( arg ) ; } catch ( e ) { console . error ( "Failed to process exception for sentry: " , e ) ; } } } ) ; } public info ( msg , ... args ) { SentryBrowser . initWhenNecessary ( ) ; } public verbose ( msg , ... args ) { SentryBrowser . initWhenNecessary ( ) ; } public debug ( msg , ... args ) { SentryBrowser . initWhenNecessary ( ) ; } public async sync ( ) { SentryBrowser . initWhenNecessary ( ) ; } }