mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
3e22b89fa2
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
41 lines
953 B
TypeScript
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;
|
|
}
|