mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 09:14:09 +00:00
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:
co-authored by
evanpelle
parent
7b7cdfe19c
commit
d18908bb68
@@ -119,7 +119,7 @@ export function joinLobby(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createClientGame(
|
async function createClientGame(
|
||||||
lobbyConfig: LobbyConfig,
|
lobbyConfig: LobbyConfig,
|
||||||
eventBus: EventBus,
|
eventBus: EventBus,
|
||||||
transport: Transport,
|
transport: Transport,
|
||||||
@@ -224,6 +224,7 @@ export class ClientGameRunner {
|
|||||||
startTime(),
|
startTime(),
|
||||||
Date.now(),
|
Date.now(),
|
||||||
update.winner,
|
update.winner,
|
||||||
|
this.lobby.serverConfig,
|
||||||
);
|
);
|
||||||
endGame(record);
|
endGame(record);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ export class LocalServer {
|
|||||||
this.startedAt,
|
this.startedAt,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
this.winner?.winner,
|
this.winner?.winner,
|
||||||
|
this.lobbyConfig.serverConfig,
|
||||||
);
|
);
|
||||||
if (!saveFullGame) {
|
if (!saveFullGame) {
|
||||||
// Clear turns because beacon only supports up to 64kb
|
// Clear turns because beacon only supports up to 64kb
|
||||||
|
|||||||
@@ -526,6 +526,8 @@ export const AnalyticsRecordSchema = z.object({
|
|||||||
info: GameEndInfoSchema,
|
info: GameEndInfoSchema,
|
||||||
version: z.literal("v0.0.2"),
|
version: z.literal("v0.0.2"),
|
||||||
gitCommit: GitCommitSchema,
|
gitCommit: GitCommitSchema,
|
||||||
|
subdomain: z.string(),
|
||||||
|
domain: z.string(),
|
||||||
});
|
});
|
||||||
export type AnalyticsRecord = z.infer<typeof AnalyticsRecordSchema>;
|
export type AnalyticsRecord = z.infer<typeof AnalyticsRecordSchema>;
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -12,6 +12,7 @@ import {
|
|||||||
Winner,
|
Winner,
|
||||||
} from "./Schemas";
|
} from "./Schemas";
|
||||||
|
|
||||||
|
import { ServerConfig } from "./configuration/Config";
|
||||||
import {
|
import {
|
||||||
BOT_NAME_PREFIXES,
|
BOT_NAME_PREFIXES,
|
||||||
BOT_NAME_SUFFIXES,
|
BOT_NAME_SUFFIXES,
|
||||||
@@ -192,10 +193,13 @@ export function createGameRecord(
|
|||||||
start: number,
|
start: number,
|
||||||
end: number,
|
end: number,
|
||||||
winner: Winner,
|
winner: Winner,
|
||||||
|
serverConfig: ServerConfig,
|
||||||
): GameRecord {
|
): GameRecord {
|
||||||
const duration = Math.floor((end - start) / 1000);
|
const duration = Math.floor((end - start) / 1000);
|
||||||
const version = "v0.0.2";
|
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 num_turns = allTurns.length;
|
||||||
const turns = allTurns.filter(
|
const turns = allTurns.filter(
|
||||||
(t) => t.intents.length !== 0 || t.hash !== undefined,
|
(t) => t.intents.length !== 0 || t.hash !== undefined,
|
||||||
@@ -213,6 +217,8 @@ export function createGameRecord(
|
|||||||
},
|
},
|
||||||
version,
|
version,
|
||||||
gitCommit,
|
gitCommit,
|
||||||
|
subdomain,
|
||||||
|
domain,
|
||||||
turns,
|
turns,
|
||||||
};
|
};
|
||||||
return record;
|
return record;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export interface ServerConfig {
|
|||||||
workerPort(gameID: GameID): number;
|
workerPort(gameID: GameID): number;
|
||||||
workerPortByIndex(workerID: number): number;
|
workerPortByIndex(workerID: number): number;
|
||||||
env(): GameEnv;
|
env(): GameEnv;
|
||||||
region(): string;
|
|
||||||
adminToken(): string;
|
adminToken(): string;
|
||||||
adminHeader(): string;
|
adminHeader(): string;
|
||||||
// Only available on the server
|
// Only available on the server
|
||||||
|
|||||||
@@ -130,12 +130,6 @@ export abstract class DefaultServerConfig implements ServerConfig {
|
|||||||
otelPassword(): string {
|
otelPassword(): string {
|
||||||
return process.env.OTEL_PASSWORD ?? "";
|
return process.env.OTEL_PASSWORD ?? "";
|
||||||
}
|
}
|
||||||
region(): string {
|
|
||||||
if (this.env() === GameEnv.Dev) {
|
|
||||||
return "dev";
|
|
||||||
}
|
|
||||||
return process.env.REGION ?? "";
|
|
||||||
}
|
|
||||||
gitCommit(): string {
|
gitCommit(): string {
|
||||||
return process.env.GIT_COMMIT ?? "";
|
return process.env.GIT_COMMIT ?? "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,13 @@ export async function archive(gameRecord: GameRecord) {
|
|||||||
|
|
||||||
async function archiveAnalyticsToR2(gameRecord: GameRecord) {
|
async function archiveAnalyticsToR2(gameRecord: GameRecord) {
|
||||||
// Create analytics data object
|
// Create analytics data object
|
||||||
const { info, version, gitCommit } = gameRecord;
|
const { info, version, gitCommit, subdomain, domain } = gameRecord;
|
||||||
const analyticsData: AnalyticsRecord = {
|
const analyticsData: AnalyticsRecord = {
|
||||||
info,
|
info,
|
||||||
version,
|
version,
|
||||||
gitCommit,
|
gitCommit,
|
||||||
|
subdomain,
|
||||||
|
domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -628,6 +628,7 @@ export class GameServer {
|
|||||||
this._startTime ?? 0,
|
this._startTime ?? 0,
|
||||||
Date.now(),
|
Date.now(),
|
||||||
this.winner?.winner,
|
this.winner?.winner,
|
||||||
|
this.config,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ export class TestServerConfig implements ServerConfig {
|
|||||||
otelPassword(): string {
|
otelPassword(): string {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
region(): string {
|
|
||||||
return "test";
|
|
||||||
}
|
|
||||||
turnIntervalMs(): number {
|
turnIntervalMs(): number {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user