import { Integration , WrappedFunction } from '@sentry/types' ; import { getOriginalFunction } from '@sentry/utils' ; let originalFunctionToString ; /** Patch toString calls to return proper name for wrapped functions */ export class FunctionToString implements Integration { inheritDoc public static id : string = 'FunctionToString' ; inheritDoc public name : string = FunctionToString . id ; inheritDoc public setupOnce ( ) { originalFunctionToString = Function . prototype . toString ; Function . prototype . toString = function ( this , ... args ) : string { const context = getOriginalFunction ( this ) || this ; return originalFunctionToString . apply ( context , args ) ; } ; } }