store client ips in bigquery table

This commit is contained in:
Evan
2024-12-14 10:03:05 -08:00
parent c93bca059f
commit 2fc81c7d17
12 changed files with 90 additions and 95 deletions
+6 -1
View File
@@ -15,11 +15,14 @@ export async function archive(gameRecord: GameRecord) {
end: new Date(gameRecord.endTimestampMS),
duration_seconds: gameRecord.durationSeconds,
number_turns: gameRecord.num_turns,
usernames: gameRecord.usernames,
game_mode: gameRecord.gameConfig.gameType,
winner: null,
difficulty: gameRecord.gameConfig.difficulty,
map: gameRecord.gameConfig.gameMap,
players: gameRecord.players.map(p => ({
username: p.username,
ip: p.ip,
})),
};
await bigquery
@@ -29,6 +32,8 @@ export async function archive(gameRecord: GameRecord) {
console.log(`wrote game metadata to BigQuery: ${gameRecord.id}`);
if (gameRecord.turns.length > 0) {
// Players will see this so make sure to clear PII.
gameRecord.players.forEach(p => p.ip = "REDACTED")
console.log(`writing game ${gameRecord.id} to gcs`)
const bucket = storage.bucket("openfront-games");
const file = bucket.file(gameRecord.id);