diff --git a/BUILD_NUMBER b/BUILD_NUMBER index 780fea92..76a8b2b7 100644 --- a/BUILD_NUMBER +++ b/BUILD_NUMBER @@ -1 +1 @@ -77 \ No newline at end of file +83 diff --git a/README.md b/README.md index df452ab4..831c0498 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ LOLYMPUS는 리그 오브 레전드 커뮤니티의 여러 이벤트 중 내전(

- 3초 간격 데모 영상 보기 + 3초 간격 데모 영상 보기

## 배포 주소 | Environment | Version | URL | | ----------- | ------- | -------------------------------------- | -| Production | v77 | | -| Staging | v77 | | +| Production | v83 | | +| Staging | v83 | | ## 개요 diff --git a/apps/web/.env.development b/apps/web/.env.development index a91617fa..aa7767e6 100644 --- a/apps/web/.env.development +++ b/apps/web/.env.development @@ -5,3 +5,11 @@ VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64 VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback VITE_MSAL_SILENT_REDIRECT_URI=http://localhost:5173/auth/silent-callback.html +VITE_NEW_RELIC_ENABLED=false +VITE_NEW_RELIC_APPLICATION_ID=601654991 +VITE_NEW_RELIC_ACCOUNT_ID=8100154 +VITE_NEW_RELIC_AGENT_ID=601654991 +VITE_NEW_RELIC_LICENSE_KEY=NRJS-caad7f6e90b92fe88de +VITE_NEW_RELIC_TRUST_KEY=8100154 +VITE_NEW_RELIC_BEACON=bam.nr-data.net +VITE_NEW_RELIC_RELEASE_NAME=lolympus-web diff --git a/apps/web/.env.example b/apps/web/.env.example index 969d2d5c..ba1c2137 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -5,3 +5,13 @@ VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/ VITE_MSAL_API_SCOPE=api://lolympus-api/access_as_user VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback VITE_MSAL_SILENT_REDIRECT_URI=http://localhost:5173/auth/silent-callback.html +VITE_NEW_RELIC_ENABLED=false +VITE_NEW_RELIC_APPLICATION_ID= +VITE_NEW_RELIC_ACCOUNT_ID= +VITE_NEW_RELIC_AGENT_ID= +VITE_NEW_RELIC_LICENSE_KEY= +VITE_NEW_RELIC_TRUST_KEY= +VITE_NEW_RELIC_BEACON=bam.nr-data.net +VITE_NEW_RELIC_APPLICATION_VERSION= +VITE_NEW_RELIC_RELEASE_ID= +VITE_NEW_RELIC_RELEASE_NAME=lolympus-web diff --git a/apps/web/.env.production b/apps/web/.env.production index 64d88a8a..b64e84d1 100644 --- a/apps/web/.env.production +++ b/apps/web/.env.production @@ -5,4 +5,13 @@ VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64 VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev VITE_MSAL_REDIRECT_URI=https://lolympus.dahyeon.us/auth/callback VITE_MSAL_SILENT_REDIRECT_URI=https://lolympus.dahyeon.us/auth/silent-callback.html - +VITE_NEW_RELIC_ENABLED=true +VITE_NEW_RELIC_APPLICATION_ID=601654991 +VITE_NEW_RELIC_ACCOUNT_ID=8100154 +VITE_NEW_RELIC_AGENT_ID=601654991 +VITE_NEW_RELIC_LICENSE_KEY=NRJS-caad7f6e90b92fe88de +VITE_NEW_RELIC_TRUST_KEY=8100154 +VITE_NEW_RELIC_BEACON=bam.nr-data.net +VITE_NEW_RELIC_APPLICATION_VERSION=83 +VITE_NEW_RELIC_RELEASE_ID=release-83 +VITE_NEW_RELIC_RELEASE_NAME=lolympus-web diff --git a/apps/web/.env.staging b/apps/web/.env.staging index 8d308d67..0ddcecba 100644 --- a/apps/web/.env.staging +++ b/apps/web/.env.staging @@ -1,6 +1,16 @@ VITE_API_BASE_URL=https://lolympus-api-staging.dahyeon.us VITE_DEFAULT_COMMUNITY_ID=69ebe0adf627c11be2f020a1 -VITE_MSAL_CLIENT_ID=15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3 +VITE_MSAL_CLIENT_ID=66dadf46-418c-43c8-a908-3c15dcc0465d VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863 VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev -VITE_MSAL_REDIRECT_URI=http://localhost:5173/auth/callback +VITE_MSAL_REDIRECT_URI=https://release-83.lolympus.pages.dev/auth/callback +VITE_NEW_RELIC_ENABLED=true +VITE_NEW_RELIC_APPLICATION_ID=601654991 +VITE_NEW_RELIC_ACCOUNT_ID=8100154 +VITE_NEW_RELIC_AGENT_ID=601654991 +VITE_NEW_RELIC_LICENSE_KEY=NRJS-caad7f6e90b92fe88de +VITE_NEW_RELIC_TRUST_KEY=8100154 +VITE_NEW_RELIC_BEACON=bam.nr-data.net +VITE_NEW_RELIC_APPLICATION_VERSION=83 +VITE_NEW_RELIC_RELEASE_ID=release-83 +VITE_NEW_RELIC_RELEASE_NAME=lolympus-web diff --git a/apps/web/package.json b/apps/web/package.json index 8d9b78b5..20cad4cb 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -20,6 +20,7 @@ "dependencies": { "@azure/msal-browser": "^5.8.0", "@azure/msal-react": "^5.3.1", + "@newrelic/browser-agent": "^1.316.0", "@tanstack/react-query": "^5.100.1", "lucide-react": "^1.14.0", "react": "^19.2.4", diff --git a/apps/web/src/api/useAuctionSocket.ts b/apps/web/src/api/useAuctionSocket.ts index fb0842c7..d2c52333 100644 --- a/apps/web/src/api/useAuctionSocket.ts +++ b/apps/web/src/api/useAuctionSocket.ts @@ -8,6 +8,7 @@ import { resolveAuctionErrorMessage, resolveAuctionRejectionMessage, } from './auctionRejectionMessages'; +import { addNewRelicPageAction } from '../lib/observability/new-relic'; type ConnectionStatus = | 'idle' @@ -180,9 +181,36 @@ export function useAuctionSocket(matchId: string | undefined) { resolveCurrentBidPointAmount(nextAuction); } - function commitAuctionState(nextAuction: ApiAuction): boolean { + function commitAuctionState( + nextAuction: ApiAuction, + source = 'socket-state', + ): boolean { const currentAuction = latestAuctionRef.current; - if (!shouldApplyIncomingAuctionState(currentAuction, nextAuction)) { + const applied = shouldApplyIncomingAuctionState(currentAuction, nextAuction); + const currentRevision = + typeof currentAuction?.revision === 'number' + ? currentAuction.revision + : -1; + const incomingRevision = + typeof nextAuction?.revision === 'number' ? nextAuction.revision : -1; + // 단조성을 깨고 적용되는 경우(=revision이 같거나 뒤로 가는데도 반영됨). + // force-resync/lifecycle 교체로만 발생하며, "2~3 버전 롤백"의 직접 증거가 된다. + const isBackwardApply = + applied && + currentRevision >= 0 && + incomingRevision >= 0 && + incomingRevision <= currentRevision; + addNewRelicPageAction('AuctionClientStateApply', { + matchId: matchId ?? 'none', + source, + applied, + isBackwardApply, + revisionDelta: incomingRevision - currentRevision, + ...describeAuctionForTelemetry('current', currentAuction), + ...describeAuctionForTelemetry('incoming', nextAuction), + }); + + if (!applied) { return false; } @@ -361,7 +389,7 @@ export function useAuctionSocket(matchId: string | undefined) { }); socket.on('state', (nextAuction: ApiAuction) => { - const didApplyState = commitAuctionState(nextAuction); + const didApplyState = commitAuctionState(nextAuction, 'socket-state'); if (didApplyState) { clearPendingActionRequests(); } @@ -384,7 +412,24 @@ export function useAuctionSocket(matchId: string | undefined) { socket.on('bid', (payload: BidDeltaPayload) => { applyFallbackServerTimestamp(payload?.currentServerTimestampMS); + const beforeBid = latestAuctionRef.current; const didApplyBidDelta = commitBidDelta(payload); + addNewRelicPageAction('AuctionClientBidDelta', { + matchId: matchId ?? 'none', + applied: didApplyBidDelta, + deltaRevision: + typeof payload?.revision === 'number' ? payload.revision : -1, + deltaBidAmount: Number(payload?.currentHighestBidPointAmount ?? -1), + deltaBidderTeamIndex: Number( + payload?.currentHighestBidderTeamIndex ?? -1, + ), + beforeRevision: + typeof beforeBid?.revision === 'number' ? beforeBid.revision : -1, + beforeBidAmount: beforeBid + ? resolveCurrentBidPointAmount(beforeBid) + : -1, + beforePlayerUserId: beforeBid?.currentBidRoundPlayerUserId ?? 'none', + }); if (payload?.bidRequestId) { if ( didApplyBidDelta || @@ -429,6 +474,12 @@ export function useAuctionSocket(matchId: string | undefined) { }; latestAuctionRef.current = nextAuction; setAuction(nextAuction); + addNewRelicPageAction('AuctionClientSideEffect', { + matchId: matchId ?? 'none', + matchSideEffectStatus: matchSideEffectStatus ?? 'unknown', + matchSideEffectRevision, + ...describeAuctionForTelemetry('current', currentAuction), + }); }); socket.on('reset', (payload: ResetPayload) => { @@ -574,6 +625,23 @@ export function useAuctionSocket(matchId: string | undefined) { clearPendingActionRequest(auctionActionRequestId); setError('경매 진행 응답이 지연되어 최신 상태를 다시 확인해주세요.'); }, 10_000); + addNewRelicPageAction('AuctionClientActionSent', { + matchId: matchId ?? 'none', + action: eventName, + retryAttempt, + sentRevision: + typeof payload.clientObservedRevision === 'number' + ? payload.clientObservedRevision + : -1, + sentOrderIndex: + typeof payload.clientObservedCurrentAuctionPlayerOrderIndex === 'number' + ? payload.clientObservedCurrentAuctionPlayerOrderIndex + : -1, + sentPlayerUserId: + payload.clientObservedCurrentBidRoundPlayerUserId ?? 'none', + sentPhase: payload.clientObservedPhase ?? 'none', + ...describeAuctionForTelemetry('observed', latestAuctionRef.current), + }); socket.emit( eventName, actionPayload, @@ -590,14 +658,6 @@ export function useAuctionSocket(matchId: string | undefined) { clearPendingActionRequest( ack?.auctionActionRequestId ?? auctionActionRequestId, ); - // 1) rebaseline: 서버가 동봉한 최신 state를 즉시 반영(없으면 join으로 재요청). - // commitAuctionState는 latestAuctionRef를 동기로 갱신하므로, 이후 - // buildAuctionActionPayload는 최신 관측값(revision/phase/선수)을 읽는다. - if (ack.state) { - commitAuctionState(ack.state); - } else if (isAuctionResyncRecommended(ack)) { - resyncAuctionState(); - } // 2) 자동 재시도: "낡은 화면 때문에 거부"였고 동기 rebaseline 소스(state)가 // 있을 때만 1회. assignedPosition 등 원래 payload는 유지하고 관측값/요청 // id만 새로 만든다. 재시도 시에는 중간 에러 문구를 띄우지 않는다(무음 복구). @@ -605,6 +665,41 @@ export function useAuctionSocket(matchId: string | undefined) { Boolean(ack.state) && isAuctionResyncRecommended(ack) && retryAttempt < 1; + // 거부 시 "클라가 보낸 관측 revision"과 "서버가 동봉한 진짜 state"를 함께 + // 기록한다. observedRevision < serverRevision 이면 stale-client CONFLICT 확정. + addNewRelicPageAction('AuctionClientActionRejected', { + matchId: matchId ?? 'none', + action: eventName, + retryAttempt, + rejectionReason: + ack?.auctionRejectionReason ?? ack?.code ?? 'unknown', + rejectionCode: ack?.code ?? 'none', + resyncRecommended: isAuctionResyncRecommended(ack), + hasAckState: Boolean(ack?.state), + willAutoRetry: canAutoRetry, + sentRevision: + typeof payload.clientObservedRevision === 'number' + ? payload.clientObservedRevision + : -1, + sentOrderIndex: + typeof payload.clientObservedCurrentAuctionPlayerOrderIndex === + 'number' + ? payload.clientObservedCurrentAuctionPlayerOrderIndex + : -1, + sentPlayerUserId: + payload.clientObservedCurrentBidRoundPlayerUserId ?? 'none', + sentPhase: payload.clientObservedPhase ?? 'none', + ...describeAuctionForTelemetry('observed', latestAuctionRef.current), + ...describeAuctionForTelemetry('server', ack?.state ?? null), + }); + // 1) rebaseline: 서버가 동봉한 최신 state를 즉시 반영(없으면 join으로 재요청). + // commitAuctionState는 latestAuctionRef를 동기로 갱신하므로, 이후 + // buildAuctionActionPayload는 최신 관측값(revision/phase/선수)을 읽는다. + if (ack.state) { + commitAuctionState(ack.state, 'action-reject-rebaseline'); + } else if (isAuctionResyncRecommended(ack)) { + resyncAuctionState(); + } if (canAutoRetry) { emitAuctionAction( eventName, @@ -621,7 +716,17 @@ export function useAuctionSocket(matchId: string | undefined) { clearPendingActionRequest( ack.auctionActionRequestId ?? auctionActionRequestId, ); - commitAuctionState(ackState); + addNewRelicPageAction('AuctionClientActionAck', { + matchId: matchId ?? 'none', + action: eventName, + retryAttempt, + sentRevision: + typeof payload.clientObservedRevision === 'number' + ? payload.clientObservedRevision + : -1, + ...describeAuctionForTelemetry('server', ackState), + }); + commitAuctionState(ackState, 'action-ack'); } }, ); @@ -754,6 +859,58 @@ function resolveCurrentBidPointAmount(auction: ApiAuction): number { return Number.isFinite(bidPointAmount) ? bidPointAmount : 0; } +type AuctionTelemetryAttributes = Record; + +function readAuctionHistorySequence(auction: ApiAuction | null | undefined) { + const value = (auction as { currentAuctionHistorySequence?: unknown } | null) + ?.currentAuctionHistorySequence; + return typeof value === 'number' ? value : -1; +} + +function summarizeAuctionTeams(auction: ApiAuction | null | undefined) { + const teams = Array.isArray(auction?.auctionTeams) ? auction.auctionTeams : []; + let assignedMemberCount = 0; + for (const team of teams) { + const members = (team as { members?: unknown[] }).members; + if (Array.isArray(members)) assignedMemberCount += members.length; + } + return { teamCount: teams.length, assignedMemberCount }; +} + +// New Relic로 보내기 위해 경매 상태를 평탄한 속성 집합으로 요약한다. +// prefix로 두 상태(예: 현재 vs 수신)를 한 이벤트에 같이 실어 revision 어긋남을 +// 한눈에 비교할 수 있게 한다. +function describeAuctionForTelemetry( + prefix: string, + auction: ApiAuction | null | undefined, +): AuctionTelemetryAttributes { + const teamSummary = summarizeAuctionTeams(auction); + return { + [`${prefix}Revision`]: + typeof auction?.revision === 'number' ? auction.revision : -1, + [`${prefix}HistorySequence`]: readAuctionHistorySequence(auction), + [`${prefix}Phase`]: auction?.phase ?? 'unknown', + [`${prefix}LifecycleId`]: auction?.auctionLifecycleId ?? 'none', + [`${prefix}OrderIndex`]: + typeof auction?.currentAuctionPlayerOrderIndex === 'number' + ? auction.currentAuctionPlayerOrderIndex + : -1, + [`${prefix}PlayerUserId`]: auction?.currentBidRoundPlayerUserId ?? 'none', + [`${prefix}BidAmount`]: auction + ? resolveCurrentBidPointAmount(auction) + : -1, + [`${prefix}BidderTeamIndex`]: + typeof auction?.currentHighestBidderTeamIndex === 'number' + ? auction.currentHighestBidderTeamIndex + : typeof auction?.currentBidderTeamIndex === 'number' + ? auction.currentBidderTeamIndex + : -1, + [`${prefix}TeamCount`]: teamSummary.teamCount, + [`${prefix}AssignedMemberCount`]: teamSummary.assignedMemberCount, + [`${prefix}ForceResync`]: Boolean(auction?.shouldForceAuctionStateResync), + }; +} + function shouldApplyIncomingAuctionState( current: ApiAuction | null, incoming: ApiAuction, diff --git a/apps/web/src/lib/observability/new-relic.ts b/apps/web/src/lib/observability/new-relic.ts new file mode 100644 index 00000000..069331ca --- /dev/null +++ b/apps/web/src/lib/observability/new-relic.ts @@ -0,0 +1,160 @@ +import { BrowserAgent } from '@newrelic/browser-agent/loaders/browser-agent'; +import type { AgentOptions } from '@newrelic/browser-agent/loaders/agent'; + +type NewRelicBrowserAgent = InstanceType; +type NewRelicAttributeValue = string | number | boolean | null; +type NewRelicAttributes = Record; + +const DEFAULT_BEACON = 'bam.nr-data.net'; +const DEFAULT_RELEASE_NAME = 'lolympus-web'; + +let browserAgent: NewRelicBrowserAgent | null = null; + +function readEnvValue(name: string): string | undefined { + const value = import.meta.env[name]; + return typeof value === 'string' && value.trim() ? value.trim() : undefined; +} + +function readEnvNumber(name: string): number | undefined { + const value = Number(readEnvValue(name)); + return Number.isFinite(value) ? value : undefined; +} + +function isBrowserRuntime() { + return typeof window !== 'undefined'; +} + +export function isNewRelicBrowserMonitoringEnabled() { + return readEnvValue('VITE_NEW_RELIC_ENABLED') !== 'false'; +} + +export function createNewRelicBrowserAgentOptions(): AgentOptions | null { + if (!isNewRelicBrowserMonitoringEnabled()) return null; + + const applicationID = readEnvValue('VITE_NEW_RELIC_APPLICATION_ID'); + const accountID = readEnvNumber('VITE_NEW_RELIC_ACCOUNT_ID'); + const licenseKey = readEnvValue('VITE_NEW_RELIC_LICENSE_KEY'); + const beacon = readEnvValue('VITE_NEW_RELIC_BEACON') ?? DEFAULT_BEACON; + const agentID = readEnvNumber('VITE_NEW_RELIC_AGENT_ID') ?? Number(applicationID); + const applicationNumericID = Number(applicationID); + const trustKey = readEnvNumber('VITE_NEW_RELIC_TRUST_KEY') ?? accountID; + + if ( + !applicationID || + !accountID || + !licenseKey || + !Number.isFinite(agentID) || + !Number.isFinite(applicationNumericID) + ) { + return null; + } + + return { + info: { + applicationID, + beacon, + errorBeacon: beacon, + licenseKey, + sa: 1, + }, + init: { + ajax: { + deny_list: [beacon], + }, + browser_consent_mode: { + enabled: false, + }, + distributed_tracing: { + enabled: true, + }, + performance: { + capture_detail: false, + capture_marks: false, + capture_measures: true, + }, + privacy: { + cookies_enabled: true, + }, + session_replay: { + enabled: false, + autoStart: false, + }, + }, + loader_config: { + accountID, + agentID, + applicationID: applicationNumericID, + licenseKey, + trustKey, + }, + }; +} + +function applyReleaseMetadata(agent: NewRelicBrowserAgent) { + const applicationVersion = + readEnvValue('VITE_NEW_RELIC_APPLICATION_VERSION') ?? + readEnvValue('VITE_APP_VERSION') ?? + readEnvValue('VITE_BUILD_NUMBER'); + if (!applicationVersion) return; + + agent.setApplicationVersion(applicationVersion); + agent.addRelease( + readEnvValue('VITE_NEW_RELIC_RELEASE_NAME') ?? DEFAULT_RELEASE_NAME, + readEnvValue('VITE_NEW_RELIC_RELEASE_ID') ?? applicationVersion, + ); +} + +export function initializeNewRelicBrowserAgent( + options = createNewRelicBrowserAgentOptions(), +) { + if (!isBrowserRuntime() || !options) return null; + if (browserAgent) return browserAgent; + + // New Relic recommends instantiating the npm BrowserAgent from the earliest + // browser entry point: https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/ + browserAgent = new BrowserAgent(options); + applyReleaseMetadata(browserAgent); + + return browserAgent; +} + +export function getNewRelicBrowserAgent() { + return browserAgent; +} + +export function setNewRelicUserId(userId: string | null, resetSession = false) { + browserAgent?.setUserId(userId, resetSession); +} + +export function setNewRelicPageViewName(name: string, host?: string) { + browserAgent?.setPageViewName(name, host); +} + +export function setNewRelicCustomAttribute( + name: string, + value: NewRelicAttributeValue, + persist = false, +) { + browserAgent?.setCustomAttribute(name, value, persist); +} + +export function addNewRelicPageAction( + name: string, + attributes?: NewRelicAttributes, +) { + browserAgent?.addPageAction(name, attributes); +} + +export function recordNewRelicCustomEvent( + eventType: string, + attributes?: NewRelicAttributes, +) { + browserAgent?.recordCustomEvent(eventType, attributes); +} + +export function noticeNewRelicError( + error: Error | string, + attributes?: NewRelicAttributes, +) { + browserAgent?.noticeError(error, attributes); +} diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index af11ac47..40341e17 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -1,3 +1,4 @@ +import { initializeNewRelicBrowserAgent } from './lib/observability/new-relic.ts'; import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; @@ -6,6 +7,7 @@ import App from './App.tsx'; import { MsalAppProvider } from './lib/auth/MsalAppProvider.tsx'; import { initializeTheme } from './config.ts'; +initializeNewRelicBrowserAgent(); initializeTheme(); const queryClient = new QueryClient({ diff --git a/apps/web/src/pages/AuctionPage.tsx b/apps/web/src/pages/AuctionPage.tsx index 254482f8..6b36f505 100644 --- a/apps/web/src/pages/AuctionPage.tsx +++ b/apps/web/src/pages/AuctionPage.tsx @@ -50,10 +50,11 @@ import { teamIndexColorClasses, teamIndexLabel, } from "../lib/league"; -import { RankBadge, ResponsiveTierLabel } from "../components/RankBadge"; +import { formatRankDetail, RankBadge } from "../components/RankBadge"; import type { ApiAuction, ApiAuctionChatMessage, + ApiTierInfo, ApiRecentMatchView, ApiTierHistoryEntry, ApiRiotLaneStats, @@ -167,6 +168,25 @@ const POSITION_TO_RIOT_LANE = { SUP: "UTILITY", } as const; const LIVE_TIMER_TICK_MS = 100; +const PROFILE_TIER_ORDER = [ + "IRON", + "BRONZE", + "SILVER", + "GOLD", + "PLATINUM", + "EMERALD", + "DIAMOND", + "MASTER", + "GRANDMASTER", + "CHALLENGER", +]; +const PROFILE_APEX_TIERS = new Set(["MASTER", "GRANDMASTER", "CHALLENGER"]); +const PROFILE_RANK_INDEX: Record = { + IV: 0, + III: 1, + II: 2, + I: 3, +}; function getAuctionTeamSize(team: AuctionStateView["teams"][number]) { return team.members.length + 1; @@ -238,6 +258,47 @@ function getSoloTierHistory(entries: ApiTierHistoryEntry[]) { return entries.filter((entry) => entry.queueType === "RANKED_SOLO_5x5"); } +function getProfileTierValue( + tier: Pick, +) { + const tierIndex = PROFILE_TIER_ORDER.indexOf(tier.tier); + const base = Math.max(0, tierIndex) * 400; + if (PROFILE_APEX_TIERS.has(tier.tier)) { + return base + (tier.leaguePoints ?? 0); + } + return ( + base + + (PROFILE_RANK_INDEX[tier.rank ?? "IV"] ?? 0) * 100 + + (tier.leaguePoints ?? 0) + ); +} + +function tierHistoryEntryToTierInfo(entry: ApiTierHistoryEntry): ApiTierInfo { + return { + queueType: entry.queueType, + tier: entry.tier, + rank: entry.rank ?? "", + leaguePoints: entry.leaguePoints ?? 0, + wins: entry.wins ?? 0, + losses: entry.losses ?? 0, + fetchedAt: entry.recordedAt, + }; +} + +function getPeakSoloTier( + currentTier: ApiTierInfo | undefined, + tierHistory: ApiTierHistoryEntry[], +) { + const candidates = tierHistory.map(tierHistoryEntryToTierInfo); + if (currentTier?.queueType === "RANKED_SOLO_5x5") { + candidates.push(currentTier); + } + return candidates.reduce((peak, tier) => { + if (!peak) return tier; + return getProfileTierValue(tier) > getProfileTierValue(peak) ? tier : peak; + }, undefined); +} + type PlayerProfileTab = "internal" | "solo"; const INTERNAL_PROFILE_TOP_CHAMPION_LIMIT = 6; const INTERNAL_PROFILE_RECENT_MATCH_LIMIT = 5; @@ -643,6 +704,24 @@ function AuctionProfileMetric({ ); } +function ProfileTierSummary({ + label, + tier, +}: { + label: string; + tier: ApiTierInfo | undefined; +}) { + return ( +
+ + + {formatRankDetail(tier)}{" "} + ({label}) + +
+ ); +} + function InternalChampionSummary({ champion, ddragon, @@ -689,9 +768,11 @@ function InternalChampionSummary({ function InternalRecentMatchRow({ match, ddragon, + historyBackTo, }: { match: ApiRecentMatchView; ddragon: ReturnType["data"]; + historyBackTo: string; }) { const iconUrl = championIconUrl(ddragon, match.championId); const championName = @@ -743,6 +824,7 @@ function InternalRecentMatchRow({ return ( @@ -897,6 +979,7 @@ function InternalHistorySnapshot({ key={`${match.matchId}-${match.gameNumber ?? match.gameCreation}`} match={match} ddragon={ddragon} + historyBackTo={historyBackTo} /> )) ) : ( @@ -1176,6 +1259,7 @@ function PlayerProfileDetails({ snapshotSoloTierHistory.length > 0 ? snapshotSoloTierHistory : getSoloTierHistory(historyProfileQuery.data?.tierHistory ?? []); + const peakSoloTier = getPeakSoloTier(player.tier, tierHistory); return ( <> @@ -1205,8 +1289,9 @@ function PlayerProfileDetails({ #{player.tag} -
- +
+ +
@@ -2240,7 +2325,18 @@ export default function AuctionPage() { type="button" className="btn btn-primary btn-sm px-5 text-xs" onClick={() => socket.markSold(assignedPosition)} - disabled={socket.isAuctionActionPending} + disabled={ + socket.isAuctionActionPending || + !( + auctionState.currentBid > 0 && + auctionState.currentBidder != null + ) + } + title={ + auctionState.currentBid > 0 + ? undefined + : "입찰이 있어야 낙찰할 수 있습니다." + } > {socket.isAuctionActionPending ? "반영 중..." diff --git a/apps/web/src/pages/MatchGameDetailPage.tsx b/apps/web/src/pages/MatchGameDetailPage.tsx index 5d626f90..ff72cb9d 100644 --- a/apps/web/src/pages/MatchGameDetailPage.tsx +++ b/apps/web/src/pages/MatchGameDetailPage.tsx @@ -37,6 +37,14 @@ type DdragonManifestData = ReturnType["data"]; type RuneStyleEntry = NonNullable["runesReforged"][number]; type DetailTab = "scoreboard" | "matchup" | "build"; type TimelineMetric = "gold" | "xp"; +type MatchGameBackTarget = { + to: string; + label: string; +}; +type MatchGameNavigationState = { + backTo: string; + backLabel: string; +}; const DETAIL_TABS: Array<{ id: DetailTab; label: string }> = [ { id: "scoreboard", label: "스코어보드" }, @@ -49,6 +57,46 @@ const TIMELINE_METRICS: Array<{ id: TimelineMetric; label: string }> = [ { id: "xp", label: "경험치" }, ]; +function isRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null; +} + +function resolveBackTarget( + state: unknown, + fallbackTo: string, +): MatchGameBackTarget { + if ( + isRecord(state) && + typeof state.backTo === "string" && + state.backTo.startsWith("/") && + !state.backTo.startsWith("//") + ) { + return { + to: state.backTo, + label: + typeof state.backLabel === "string" + ? state.backLabel + : "돌아가기", + }; + } + + return { + to: fallbackTo, + label: "경기 결과로 돌아가기", + }; +} + +function createNavigationState( + backTarget: MatchGameBackTarget, + fallbackTo: string, +): MatchGameNavigationState | undefined { + if (backTarget.to === fallbackTo) return undefined; + return { + backTo: backTarget.to, + backLabel: backTarget.label, + }; +} + const SKILL_ROWS: Array<{ slot: 1 | 2 | 3 | 4; label: string; @@ -1924,9 +1972,11 @@ function GameAnalysisPanel({ function GameTabs({ detail, currentGameNumber, + navigationState, }: { detail: ApiInternalMatchDetailResponse; currentGameNumber: number; + navigationState: MatchGameNavigationState | undefined; }) { return (
- + ); } export default function MatchGameDetailPage() { const { id, gameNumber } = useParams(); + const location = useLocation(); const [activeTab, setActiveTab] = useState("scoreboard"); const requestedGameNumber = Number(gameNumber); const detailQuery = useInternalMatchDetail(id, DEFAULT_COMMUNITY_ID); const { data: ddragon } = useDdragonManifest(); const detail = detailQuery.data; + const fallbackBackTo = `/match/${id ?? ""}`; + const backTarget = resolveBackTarget(location.state, fallbackBackTo); + const navigationState = createNavigationState(backTarget, fallbackBackTo); if (detailQuery.isLoading) { return ( @@ -2065,8 +2128,8 @@ export default function MatchGameDetailPage() { return (

세트 기록을 찾을 수 없습니다

- - 경기 결과로 돌아가기 + + {backTarget.label}
); @@ -2081,10 +2144,10 @@ export default function MatchGameDetailPage() {

수집된 세트 기록이 없습니다

- 경기 결과로 돌아가기 + {backTarget.label}
); @@ -2092,7 +2155,12 @@ export default function MatchGameDetailPage() { return (
- + =12.17.0 < 13.0.0 || >=13.7.0'} + + '@newrelic/rrdom@1.1.2': + resolution: {integrity: sha512-fL49rcPCxT4sgCv6xIvopsq+fVHDRbp8Hb9C7QMVvk3G94wB5UKyVDkI+ubL/5HXLqaX6D06f7SWXJcxmoPZKw==} + + '@newrelic/rrweb-snapshot@1.1.2': + resolution: {integrity: sha512-iaKS4WSoDGkYdOy3GaqqYneeHz+2GcbQDEl2sR52nNkyEzt6ewiesBYcDCFkGk5QmqoYCQnokry66baJfCyUzw==} + + '@newrelic/rrweb-types@1.1.2': + resolution: {integrity: sha512-OEQBcT2J4xxArFQ45EYkDVBc9NT3fS7DIgganl4mZS6mZdLnK4UVrR3iSfSiEetIqGp/q6X+hCOqcgJll7NPjQ==} + + '@newrelic/rrweb-utils@1.1.2': + resolution: {integrity: sha512-L1X22OJbJCExp3IEClx6Nh1+sw3O+t79oAgGlBLlkDV/saFSbMpg09K2NLIWpkSxZs7yzouvRSeHh8QiDlA9bg==} + + '@newrelic/rrweb@1.1.0': + resolution: {integrity: sha512-3QmDsDf0ZTi0upNiSjTKSqmPF7Y/WIm9NvfEYQnqejfowIuV4tgDBt0FePSpgkT0usFGDigXpAGE+VZQi5OqEg==} + '@noble/hashes@1.8.0': resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} engines: {node: ^14.21.3 || >=16} @@ -1895,6 +1917,9 @@ packages: '@types/cors@2.8.19': resolution: {integrity: sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==} + '@types/css-font-loading-module@0.0.7': + resolution: {integrity: sha512-nl09VhutdjINdWyXxHWN/w9zlNCfr60JUqJbd24YXUuCwgeL0TpFSdElCwb6cxfB6ybE19Gjj4g0jsgkXxKv1Q==} + '@types/d3-array@3.2.2': resolution: {integrity: sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==} @@ -2226,6 +2251,9 @@ packages: '@webassemblyjs/wast-printer@1.14.1': resolution: {integrity: sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==} + '@xstate/fsm@1.6.5': + resolution: {integrity: sha512-b5o1I6aLNeYlU/3CPlj/Z91ybk1gUsKT+5NAJI+2W4UjvS5KLG28K9v5UvNoFVjHV8PajVZ00RH3vnjyQO7ZAw==} + '@xtuc/ieee754@1.2.0': resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} @@ -2384,6 +2412,10 @@ packages: resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} engines: {node: 18 || 20 || >=22} + base64-arraybuffer@1.0.2: + resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==} + engines: {node: '>= 0.6.0'} + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -2997,6 +3029,9 @@ packages: picomatch: optional: true + fflate@0.8.2: + resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} + file-entry-cache@8.0.0: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} @@ -3714,6 +3749,9 @@ packages: resolution: {integrity: sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==} engines: {node: '>=16 || 14 >=14.17'} + mitt@3.0.1: + resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} + mongodb-connection-string-url@7.0.1: resolution: {integrity: sha512-h0AZ9A7IDVwwHyMxmdMXKy+9oNlF0zFoahHiX3vQ8e3KFcSP3VmsmfvtRSuLPxmyv2vjIDxqty8smTgie/SNRQ==} engines: {node: '>=20.19.0'} @@ -4620,6 +4658,9 @@ packages: wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + web-vitals@4.2.4: + resolution: {integrity: sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==} + webidl-conversions@7.0.0: resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} engines: {node: '>=12'} @@ -6254,6 +6295,35 @@ snapshots: optionalDependencies: '@nestjs/platform-socket.io': 11.1.19(@nestjs/common@11.1.18(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/websockets@11.1.19)(rxjs@7.8.2) + '@newrelic/browser-agent@1.316.0': + dependencies: + '@newrelic/rrweb': 1.1.0 + fflate: 0.8.2 + web-vitals: 4.2.4 + + '@newrelic/rrdom@1.1.2': + dependencies: + '@newrelic/rrweb-snapshot': 1.1.2 + + '@newrelic/rrweb-snapshot@1.1.2': + dependencies: + postcss: 8.5.9 + + '@newrelic/rrweb-types@1.1.2': {} + + '@newrelic/rrweb-utils@1.1.2': {} + + '@newrelic/rrweb@1.1.0': + dependencies: + '@newrelic/rrdom': 1.1.2 + '@newrelic/rrweb-snapshot': 1.1.2 + '@newrelic/rrweb-types': 1.1.2 + '@newrelic/rrweb-utils': 1.1.2 + '@types/css-font-loading-module': 0.0.7 + '@xstate/fsm': 1.6.5 + base64-arraybuffer: 1.0.2 + mitt: 3.0.1 + '@noble/hashes@1.8.0': {} '@nuxt/opencollective@0.4.1': @@ -6802,6 +6872,8 @@ snapshots: dependencies: '@types/node': 24.12.2 + '@types/css-font-loading-module@0.0.7': {} + '@types/d3-array@3.2.2': {} '@types/d3-color@3.1.3': {} @@ -7243,6 +7315,8 @@ snapshots: '@webassemblyjs/ast': 1.14.1 '@xtuc/long': 4.2.2 + '@xstate/fsm@1.6.5': {} + '@xtuc/ieee754@1.2.0': {} '@xtuc/long@4.2.2': {} @@ -7407,6 +7481,8 @@ snapshots: balanced-match@4.0.4: {} + base64-arraybuffer@1.0.2: {} + base64-js@1.5.1: {} base64id@2.0.0: {} @@ -8031,6 +8107,8 @@ snapshots: optionalDependencies: picomatch: 4.0.4 + fflate@0.8.2: {} + file-entry-cache@8.0.0: dependencies: flat-cache: 4.0.1 @@ -8878,6 +8956,8 @@ snapshots: minipass@7.1.3: {} + mitt@3.0.1: {} + mongodb-connection-string-url@7.0.1: dependencies: '@types/whatwg-url': 13.0.0 @@ -9828,6 +9908,8 @@ snapshots: dependencies: defaults: 1.0.4 + web-vitals@4.2.4: {} + webidl-conversions@7.0.0: {} webpack-node-externals@3.0.0: {}