chore: reflect observability updates in release 83
This commit is contained in:
1 parent
ab721873f3
commit
d2fc126fed
13 files changed
+636
-33
No files matched your search
@@ -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
|
||||
@@ -5,3 +5,13 @@ VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/<tenant-id>
|
||||
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
|
||||
@@ -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
|
||||
+12
-2
@@ -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
|
||||
@@ -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",
|
||||
|
||||
@@ -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<string, string | number | boolean | null>;
|
||||
|
||||
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,
|
||||
|
||||
@@ -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<typeof BrowserAgent>;
|
||||
type NewRelicAttributeValue = string | number | boolean | null;
|
||||
type NewRelicAttributes = Record<string, NewRelicAttributeValue>;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -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({
|
||||
|
||||
@@ -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<string, number> = {
|
||||
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<ApiTierInfo, "tier" | "rank" | "leaguePoints">,
|
||||
) {
|
||||
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<ApiTierInfo | undefined>((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 (
|
||||
<div className="flex min-w-0 items-center gap-1.5">
|
||||
<RankBadge tier={tier} size="sm" />
|
||||
<span className="truncate text-xs font-semibold text-base-content/55">
|
||||
{formatRankDetail(tier)}{" "}
|
||||
<span className="font-normal text-base-content/35">({label})</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function InternalChampionSummary({
|
||||
champion,
|
||||
ddragon,
|
||||
@@ -689,9 +768,11 @@ function InternalChampionSummary({
|
||||
function InternalRecentMatchRow({
|
||||
match,
|
||||
ddragon,
|
||||
historyBackTo,
|
||||
}: {
|
||||
match: ApiRecentMatchView;
|
||||
ddragon: ReturnType<typeof useDdragonManifest>["data"];
|
||||
historyBackTo: string;
|
||||
}) {
|
||||
const iconUrl = championIconUrl(ddragon, match.championId);
|
||||
const championName =
|
||||
@@ -743,6 +824,7 @@ function InternalRecentMatchRow({
|
||||
return (
|
||||
<Link
|
||||
to={detailPath}
|
||||
state={{ backTo: historyBackTo, backLabel: "경매로 돌아가기" }}
|
||||
className={`${className} transition-colors hover:border-primary/40 hover:bg-primary/[0.04] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`}
|
||||
aria-label={`${championName} ${match.remake ? "다시하기" : match.win ? "승리" : "패배"} 내전 상세 보기`}
|
||||
>
|
||||
@@ -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}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mb-2 text-xs">
|
||||
<ResponsiveTierLabel tier={player.tier} />
|
||||
<div className="mb-2 min-w-0 space-y-1">
|
||||
<ProfileTierSummary label="현재" tier={player.tier} />
|
||||
<ProfileTierSummary label="최고" tier={peakSoloTier} />
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<PosBadge pos={player.mainPosition} />
|
||||
@@ -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
|
||||
? "반영 중..."
|
||||
|
||||
@@ -37,6 +37,14 @@ type DdragonManifestData = ReturnType<typeof useDdragonManifest>["data"];
|
||||
type RuneStyleEntry = NonNullable<DdragonManifestData>["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<string, unknown> {
|
||||
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 (
|
||||
<nav
|
||||
@@ -1940,6 +1990,7 @@ function GameTabs({
|
||||
<Link
|
||||
key={game.gameNumber}
|
||||
to={`/match/${detail.match.matchId}/game/${game.gameNumber}`}
|
||||
state={navigationState}
|
||||
className={`min-w-[8rem] border-r border-base-content/8 px-4 py-3 text-xs transition-colors last:border-r-0 ${
|
||||
active
|
||||
? "bg-primary/8 text-primary"
|
||||
@@ -1962,9 +2013,13 @@ function GameTabs({
|
||||
function MatchScoreHero({
|
||||
detail,
|
||||
selectedGame,
|
||||
backTarget,
|
||||
navigationState,
|
||||
}: {
|
||||
detail: ApiInternalMatchDetailResponse;
|
||||
selectedGame: MatchGameDetail;
|
||||
backTarget: MatchGameBackTarget;
|
||||
navigationState: MatchGameNavigationState | undefined;
|
||||
}) {
|
||||
const selectedSeries = resolveSelectedSeries(detail, selectedGame);
|
||||
const [leftTeam, rightTeam] = selectedGame.teams;
|
||||
@@ -1982,10 +2037,10 @@ function MatchScoreHero({
|
||||
<div className="flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div className="min-w-0">
|
||||
<Link
|
||||
to={`/match/${detail.match.matchId}`}
|
||||
to={backTarget.to}
|
||||
className="text-xs text-base-content/40 hover:text-base-content"
|
||||
>
|
||||
← 경기 결과로 돌아가기
|
||||
← {backTarget.label}
|
||||
</Link>
|
||||
<h1 className="mt-4 text-2xl font-black text-base-content">
|
||||
{detail.match.title} · {selectedGame.gameNumber}세트
|
||||
@@ -2040,18 +2095,26 @@ function MatchScoreHero({
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<GameTabs detail={detail} currentGameNumber={selectedGame.gameNumber} />
|
||||
<GameTabs
|
||||
detail={detail}
|
||||
currentGameNumber={selectedGame.gameNumber}
|
||||
navigationState={navigationState}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export default function MatchGameDetailPage() {
|
||||
const { id, gameNumber } = useParams();
|
||||
const location = useLocation();
|
||||
const [activeTab, setActiveTab] = useState<DetailTab>("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 (
|
||||
<main className="mx-auto max-w-6xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">세트 기록을 찾을 수 없습니다</h1>
|
||||
<Link to={`/match/${id ?? ""}`} className="btn btn-ghost btn-sm mt-4">
|
||||
경기 결과로 돌아가기
|
||||
<Link to={backTarget.to} className="btn btn-ghost btn-sm mt-4">
|
||||
{backTarget.label}
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
@@ -2081,10 +2144,10 @@ export default function MatchGameDetailPage() {
|
||||
<main className="mx-auto max-w-6xl px-4 py-20 text-center">
|
||||
<h1 className="text-lg font-bold">수집된 세트 기록이 없습니다</h1>
|
||||
<Link
|
||||
to={`/match/${detail.match.matchId}`}
|
||||
to={backTarget.to}
|
||||
className="btn btn-ghost btn-sm mt-4"
|
||||
>
|
||||
경기 결과로 돌아가기
|
||||
{backTarget.label}
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
@@ -2092,7 +2155,12 @@ export default function MatchGameDetailPage() {
|
||||
|
||||
return (
|
||||
<main className="mx-auto max-w-6xl px-4 py-6 sm:px-6">
|
||||
<MatchScoreHero detail={detail} selectedGame={selectedGame} />
|
||||
<MatchScoreHero
|
||||
detail={detail}
|
||||
selectedGame={selectedGame}
|
||||
backTarget={backTarget}
|
||||
navigationState={navigationState}
|
||||
/>
|
||||
|
||||
<PostgameBreakdown
|
||||
selectedGame={selectedGame}
|
||||
|
||||
Reference in new issue
Block a user