gristlabs_grist-core/app/server/lib/AuditLogger.ts
George Gevoian 3e22b89fa2 (core) Add audit logging machinery
Summary:
Adds machinery to support audit logging in the backend.

Logging is currently implemented by streaming events to external HTTP
endpoints. All flavors of Grist support a default "grist" payload format,
and Grist Enterprise additionally supports an HEC-compatible payload format.

Logging of all audit events will be added at a later date.

Test Plan: Server tests.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D4331
2024-09-12 12:13:41 -04:00

41 lines
953 B
TypeScript

import {AuditEventDetails, AuditEventName} from 'app/common/AuditEvent';
import {RequestOrSession} from 'app/server/lib/requestUtils';
export interface IAuditLogger {
/**
* Logs an audit event.
*/
logEvent<Name extends AuditEventName>(
requestOrSession: RequestOrSession,
props: AuditEventProperties<Name>
): void;
/**
* Asynchronous variant of `logEvent`.
*
* Throws on failure to log an event.
*/
logEventAsync<Name extends AuditEventName>(
requestOrSession: RequestOrSession,
props: AuditEventProperties<Name>
): Promise<void>;
}
export interface AuditEventProperties<Name extends AuditEventName> {
event: {
/**
* The event name.
*/
name: Name;
/**
* Additional event details.
*/
details?: AuditEventDetails[Name];
};
/**
* ISO 8601 timestamp (e.g. `2024-09-04T14:54:50Z`) of when the event occured.
*
* Defaults to now.
*/
timestamp?: string;
}