mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 23:15:57 -05:00
17 lines
480 B
TypeScript
17 lines
480 B
TypeScript
|
import { debugConsole } from '@/utils/debugging'
|
||
|
|
||
|
type EditorEvent = { type: string; meta: unknown; date: Date }
|
||
|
|
||
|
// Record events and then do nothing with them.
|
||
|
export class EventLog {
|
||
|
private recentEvents: EditorEvent[] = []
|
||
|
|
||
|
pushEvent = (type: string, meta: unknown = {}) => {
|
||
|
debugConsole.log('event', type, meta)
|
||
|
this.recentEvents.push({ type, meta, date: new Date() })
|
||
|
if (this.recentEvents.length > 100) {
|
||
|
return this.recentEvents.shift()
|
||
|
}
|
||
|
}
|
||
|
}
|