ip geolocation + ping analysis

This commit is contained in:
NextJS
2026-06-02 10:24:58 +00:00
parent dc8377177a
commit 4ed4a10eae
21 changed files with 1141 additions and 168 deletions
+10 -1
View File
@@ -1,6 +1,7 @@
import type { SupabaseClient } from "@supabase/supabase-js";
import type { DbMatch, DbTransaction } from "@/types/database";
import { txAmountToBigInt } from "@/lib/ledger-integrity";
import { countryCodeFromIp } from "@/lib/ip-geolocation";
const TX_PAGE = 5000;
/** Recent matches listed on the player card (newest first). */
@@ -22,8 +23,11 @@ export type PlayerCardMatchHistoryRow = {
export type PlayerCardData = {
id: number;
username: string | null;
email: string | null;
createdAt: string | null;
lastSeen: string | null;
lastLoggedInIp: string | null;
lastLoggedInCountryCode: string | null;
rcBalance: number | null;
ccBalance: number | null;
matchesPlayed: number;
@@ -83,7 +87,7 @@ export async function fetchPlayerCardData(
const { data: userRow, error: userErr } = await supabase
.from("users")
.select("id, username, created_at, last_logged_at, rc, cc")
.select("id, username, email, created_at, last_logged_at, ip_address, rc, cc")
.eq("id", userId)
.maybeSingle();
@@ -270,8 +274,13 @@ export async function fetchPlayerCardData(
data: {
id: userRow.id as number,
username: (userRow.username as string | null) ?? null,
email: (userRow.email as string | null) ?? null,
createdAt: (userRow.created_at as string) ?? null,
lastSeen: (userRow.last_logged_at as string | null) ?? null,
lastLoggedInIp: (userRow.ip_address as string | null) ?? null,
lastLoggedInCountryCode: await countryCodeFromIp(
(userRow.ip_address as string | null) ?? null,
),
rcBalance: (userRow.rc as number | null) ?? null,
ccBalance: (userRow.cc as number | null) ?? null,
matchesPlayed,