import { ApmFields } from './apm_fields' ; import { Serializable } from '../serializable' ; import { generateLongId , generateShortId } from '../utils/generate_id' ; export class ApmError extends Serializable < ApmFields > { constructor ( fields ) { super ( { ... fields , 'processor.event' : 'error' , 'processor.name' : 'error' , 'error.id' : generateShortId ( ) , } ) ; } serialize ( ) { const [ data ] = super . serialize ( ) ; data [ 'error.grouping_key' ] = generateLongId ( this . fields [ 'error.grouping_name' ] || this . fields [ 'error.exception' ] ?. [ 0 ] ?. message ) ; return [ data ] ; } }