Skip to content

Commit

Permalink
Use common event model for determining if event is v0 or v1 (#60667)
Browse files Browse the repository at this point in the history
  • Loading branch information
kqualters-elastic authored Mar 19, 2020
1 parent f47022a commit cd2d54d
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,25 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { ResolverEvent, LegacyEndpointEvent } from '../../../../common/types';

function isLegacyData(data: ResolverEvent): data is LegacyEndpointEvent {
return data.agent?.type === 'endgame';
}
import { ResolverEvent } from '../../../../common/types';
import { isLegacyEvent } from '../../../../common/models/event';

export function extractEventID(event: ResolverEvent) {
if (isLegacyData(event)) {
if (isLegacyEvent(event)) {
return String(event.endgame.serial_event_id);
}
return event.event.id;
}

export function extractEntityID(event: ResolverEvent) {
if (isLegacyData(event)) {
if (isLegacyEvent(event)) {
return String(event.endgame.unique_pid);
}
return event.process.entity_id;
}

export function extractParentEntityID(event: ResolverEvent) {
if (isLegacyData(event)) {
if (isLegacyEvent(event)) {
const ppid = event.endgame.unique_ppid;
return ppid && String(ppid); // if unique_ppid is undefined return undefined
}
Expand Down

0 comments on commit cd2d54d

Please sign in to comment.