fix(telemetry): review nits
- dock h2h source corrected to match_dock; badge_viewed breakdown via value - stats filter guards unified, ref-based, double-tap safe - emoji picker reuses handleReactionClick; comment and import tidy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { playerQueries } from "@/features/players/queries";
|
||||
import PlayerStatsTable from "@/features/players/components/player-stats-table";
|
||||
import { Suspense, useState, useDeferredValue, useEffect } from "react";
|
||||
import { Suspense, useState, useDeferredValue, useEffect, useRef } from "react";
|
||||
import PlayerStatsTableSkeleton from "@/features/players/components/player-stats-table-skeleton";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import LeagueHeadToHead from "@/features/players/components/league-head-to-head";
|
||||
@@ -33,8 +33,11 @@ function Stats() {
|
||||
const isStale = viewType !== deferredViewType;
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const viewTypeRef = useRef(viewType);
|
||||
const changeViewType = (next: typeof viewType) => {
|
||||
if (viewType !== next) track("stats_filtered", { value: next });
|
||||
if (viewTypeRef.current === next) return;
|
||||
viewTypeRef.current = next;
|
||||
track("stats_filtered", { value: next });
|
||||
setViewType(next);
|
||||
};
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ const BadgeStatRow: React.FC<BadgeStatRowProps> = ({
|
||||
<Box key={badge.id}>
|
||||
<UnstyledButton
|
||||
onClick={() => {
|
||||
track("badge_viewed", { badge: badge.key });
|
||||
track("badge_viewed", { value: badge.key });
|
||||
badgeSheet.open();
|
||||
}}
|
||||
w='100%'
|
||||
|
||||
@@ -176,7 +176,7 @@ const MatchDock = ({ match, onClose }: MatchDockProps) => {
|
||||
variant="subtle"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
track("h2h_viewed", { source: "match_card" });
|
||||
track("h2h_viewed", { source: "match_dock" });
|
||||
h2hSheet.open();
|
||||
}}
|
||||
aria-label={t`View head-to-head`}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Box, Stack, Text, Divider, Group, Button } from "@mantine/core";
|
||||
import { Suspense, useState, useDeferredValue } from "react";
|
||||
import { Suspense, useState, useDeferredValue, useRef } from "react";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import Header from "./header";
|
||||
@@ -21,8 +21,10 @@ const StatsWithFilter = ({ id }: { id: string }) => {
|
||||
const deferredViewType = useDeferredValue(viewType);
|
||||
const isStale = viewType !== deferredViewType;
|
||||
|
||||
const viewTypeRef = useRef(viewType);
|
||||
const changeViewType = (next: typeof viewType) => {
|
||||
if (next === viewType) return;
|
||||
if (viewTypeRef.current === next) return;
|
||||
viewTypeRef.current = next;
|
||||
track("stats_filtered", { value: next, source: "profile" });
|
||||
setViewType(next);
|
||||
};
|
||||
|
||||
@@ -202,10 +202,7 @@ const EmojiBar = ({
|
||||
</AnimatePresence>
|
||||
</Group>
|
||||
<EmojiPicker
|
||||
onSelect={onReactionPress || ((emoji) => {
|
||||
if (!userReactions.includes(emoji)) track("reaction_sent", { emoji, source });
|
||||
toggleReaction.mutate({ data: { matchId, emoji } });
|
||||
})}
|
||||
onSelect={handleReactionClick}
|
||||
userReactions={userReactions}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
@@ -9,10 +9,10 @@ import {
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { DatePickerInput } from "@mantine/dates";
|
||||
import { ListSkeleton, StatTileSkeleton } from "@/components/skeletons";
|
||||
import { useRollupRange } from "../queries";
|
||||
import type { RollupRow } from "../types";
|
||||
import { DatePickerInput } from "@mantine/dates";
|
||||
import { fillDailySeries, lastNDays, latestValue, listDays, sumByDim } from "../range";
|
||||
import { BarList, Sparkline, StatTile } from "./charts";
|
||||
import { DetailSheet } from "./shared";
|
||||
|
||||
@@ -165,8 +165,6 @@ export function useServerEvents() {
|
||||
// an expired session rather than a network blip. Try to refresh; if the
|
||||
// session is genuinely gone, stop retrying so we don't hammer the
|
||||
// endpoint forever — a real re-login (or a wake event) will reconnect.
|
||||
// Cooldown: a flaky stream (proxy idle timeouts) must not turn every
|
||||
// reconnect into a refresh call.
|
||||
let sessionValid = true;
|
||||
if (Date.now() - lastRefreshAttemptAt > REFRESH_ATTEMPT_COOLDOWN_MS) {
|
||||
lastRefreshAttemptAt = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user