| 1 | import { createHash, randomUUID } from "crypto"; |
| 2 | import { db } |
| 3 | import { activityLogs } |
| 4 | |
| 5 | export function recordActivity(opts |
| 6 | eventType: string |
| 7 | userId?: string |
| 8 | serverId?: string |
| 9 | nodeId?: string |
| 10 | properties?: Record |
| 11 | ip?: string |
| 12 | }): void { |
| 13 | const row = |
| 14 | id: randomUUID(), |
| 15 | batchUuid: null, |
| 16 | eventType: opts.eventType |
| 17 | userId: opts.userId |
| 18 | serverId: opts.serverId |
| 19 | nodeId: opts.nodeId |
| 20 | properties: opts.properties |
| 21 | ip: opts.ip |
| 22 | hashedIp: opts.ip |
| 23 | timestamp: new Date |
| 24 | }; |
| 25 | |
| 26 | db.insert(activityLogs |
| 27 | } |