| 1 | import { createHash, randomUUID } from "crypto"; |
| 2 | import { db } |
| 3 | import { activityLogs } |
| 4 | |
| 5 | interface ActivityEvent { |
| 6 | event: string; |
| 7 | batch?: string |
| 8 | server?: string |
| 9 | user?: string |
| 10 | ip?: string |
| 11 | timestamp: string; |
| 12 | metadata?: Record |
| 13 | } |
| 14 | |
| 15 | export async function recordActivityBatch |
| 16 | if (events.length |
| 17 | |
| 18 | const rows = |
| 19 | id: randomUUID(), |
| 20 | batchUuid: e.batch |
| 21 | eventType: e.event |
| 22 | userId: e.user |
| 23 | serverId: e.server |
| 24 | nodeId: null, |
| 25 | properties: e.metadata |
| 26 | ip: e.ip |
| 27 | hashedIp: e.ip |
| 28 | timestamp: new Date |
| 29 | })); |
| 30 | |
| 31 | await db.insert |
| 32 | } |