mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-23 09:52:43 +00:00
store user's persistent id in bigquery
This commit is contained in:
@@ -22,6 +22,8 @@ export async function archive(gameRecord: GameRecord) {
|
||||
players: gameRecord.players.map(p => ({
|
||||
username: p.username,
|
||||
ip: p.ip,
|
||||
persistentID: p.persistentID,
|
||||
clientID: p.clientID,
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -32,8 +34,11 @@ 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")
|
||||
// Players may see this so make sure to clear PII.
|
||||
gameRecord.players.forEach(p => {
|
||||
p.ip = "REDACTED"
|
||||
p.persistentID = "REDACTED"
|
||||
})
|
||||
console.log(`writing game ${gameRecord.id} to gcs`)
|
||||
const bucket = storage.bucket("openfront-games");
|
||||
const file = bucket.file(gameRecord.id);
|
||||
|
||||
@@ -10,6 +10,7 @@ export class Client {
|
||||
public readonly clientID: ClientID,
|
||||
public readonly persistentID: string,
|
||||
public readonly ip: string | null,
|
||||
public readonly username: string,
|
||||
public readonly ws: WebSocket,
|
||||
) { }
|
||||
}
|
||||
@@ -166,9 +166,19 @@ export class GameServer {
|
||||
const playerRecords: PlayerRecord[] = Array.from(this.allClients.values()).map(client => ({
|
||||
ip: client.ip,
|
||||
clientID: client.clientID,
|
||||
username: client.username,
|
||||
persistentID: client.persistentID,
|
||||
}));
|
||||
const record = CreateGameRecord(this.id, this.gameConfig, playerRecords, this.turns, this._startTime, Date.now())
|
||||
archive(record)
|
||||
archive(
|
||||
CreateGameRecord(
|
||||
this.id,
|
||||
this.gameConfig,
|
||||
playerRecords,
|
||||
this.turns,
|
||||
this._startTime,
|
||||
Date.now()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
console.log(`${this.id}: no clients joined, not archiving game`)
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ wss.on('connection', (ws, req) => {
|
||||
clientMsg.clientID,
|
||||
clientMsg.persistentID,
|
||||
ip,
|
||||
clientMsg.username,
|
||||
ws
|
||||
),
|
||||
clientMsg.gameID,
|
||||
|
||||
Reference in New Issue
Block a user