Add domain, subdomain to GameRecord (#1370)

## Description:

Add domain, subdomain to GameRecord.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
Scott Anderson
2025-07-08 15:45:27 -04:00
committed by GitHub
parent 7b7cdfe19c
commit d18908bb68
9 changed files with 16 additions and 13 deletions
+2 -1
View File
@@ -119,7 +119,7 @@ export function joinLobby(
};
}
export async function createClientGame(
async function createClientGame(
lobbyConfig: LobbyConfig,
eventBus: EventBus,
transport: Transport,
@@ -224,6 +224,7 @@ export class ClientGameRunner {
startTime(),
Date.now(),
update.winner,
this.lobby.serverConfig,
);
endGame(record);
}
+1
View File
@@ -199,6 +199,7 @@ export class LocalServer {
this.startedAt,
Date.now(),
this.winner?.winner,
this.lobbyConfig.serverConfig,
);
if (!saveFullGame) {
// Clear turns because beacon only supports up to 64kb
+2
View File
@@ -526,6 +526,8 @@ export const AnalyticsRecordSchema = z.object({
info: GameEndInfoSchema,
version: z.literal("v0.0.2"),
gitCommit: GitCommitSchema,
subdomain: z.string(),
domain: z.string(),
});
export type AnalyticsRecord = z.infer<typeof AnalyticsRecordSchema>;
+7 -1
View File
@@ -12,6 +12,7 @@ import {
Winner,
} from "./Schemas";
import { ServerConfig } from "./configuration/Config";
import {
BOT_NAME_PREFIXES,
BOT_NAME_SUFFIXES,
@@ -192,10 +193,13 @@ export function createGameRecord(
start: number,
end: number,
winner: Winner,
serverConfig: ServerConfig,
): GameRecord {
const duration = Math.floor((end - start) / 1000);
const version = "v0.0.2";
const gitCommit = process.env.GIT_COMMIT ?? "unknown";
const gitCommit = serverConfig.gitCommit();
const subdomain = serverConfig.subdomain();
const domain = serverConfig.domain();
const num_turns = allTurns.length;
const turns = allTurns.filter(
(t) => t.intents.length !== 0 || t.hash !== undefined,
@@ -213,6 +217,8 @@ export function createGameRecord(
},
version,
gitCommit,
subdomain,
domain,
turns,
};
return record;
-1
View File
@@ -39,7 +39,6 @@ export interface ServerConfig {
workerPort(gameID: GameID): number;
workerPortByIndex(workerID: number): number;
env(): GameEnv;
region(): string;
adminToken(): string;
adminHeader(): string;
// Only available on the server
-6
View File
@@ -130,12 +130,6 @@ export abstract class DefaultServerConfig implements ServerConfig {
otelPassword(): string {
return process.env.OTEL_PASSWORD ?? "";
}
region(): string {
if (this.env() === GameEnv.Dev) {
return "dev";
}
return process.env.REGION ?? "";
}
gitCommit(): string {
return process.env.GIT_COMMIT ?? "";
}
+3 -1
View File
@@ -47,11 +47,13 @@ export async function archive(gameRecord: GameRecord) {
async function archiveAnalyticsToR2(gameRecord: GameRecord) {
// Create analytics data object
const { info, version, gitCommit } = gameRecord;
const { info, version, gitCommit, subdomain, domain } = gameRecord;
const analyticsData: AnalyticsRecord = {
info,
version,
gitCommit,
subdomain,
domain,
};
try {
+1
View File
@@ -628,6 +628,7 @@ export class GameServer {
this._startTime ?? 0,
Date.now(),
this.winner?.winner,
this.config,
),
);
}
-3
View File
@@ -46,9 +46,6 @@ export class TestServerConfig implements ServerConfig {
otelPassword(): string {
throw new Error("Method not implemented.");
}
region(): string {
return "test";
}
turnIntervalMs(): number {
throw new Error("Method not implemented.");
}