Skip to content

Commit fd7e10d

Browse files
[Dashboard] Fix date handling in analytics components (#7885)
1 parent 3126d87 commit fd7e10d

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

apps/dashboard/src/@/components/analytics/date-range-selector.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ export function getLastNDaysRange(id: DurationId) {
8686
throw new Error(`Invalid duration id: ${id}`);
8787
}
8888

89-
const todayDate = new Date(Date.now());
89+
const todayDate = new Date();
90+
todayDate.setDate(todayDate.getDate() + 1); // Move to next day
91+
todayDate.setHours(0, 0, 0, 0); // Set to start of next day (00:00)
9092

9193
const value: Range = {
9294
from: subDays(todayDate, durationInfo.days),

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/overview/highlights-card.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,34 @@ function processTimeSeriesData(
105105
volumeStats: UniversalBridgeStats[],
106106
): TimeSeriesMetrics[] {
107107
const metrics: TimeSeriesMetrics[] = [];
108-
const dates = [...new Set(userStats.map((a) => a.date))];
108+
const dates = [
109+
...new Set([
110+
...userStats.map((a) => new Date(a.date).toISOString().slice(0, 10)),
111+
...volumeStats.map((a) => new Date(a.date).toISOString().slice(0, 10)),
112+
]),
113+
];
109114

110115
for (const date of dates) {
111116
const activeUsers = userStats
112-
.filter(
113-
(u) => new Date(u.date).toISOString() === new Date(date).toISOString(),
114-
)
117+
.filter((u) => new Date(u.date).toISOString().slice(0, 10) === date)
115118
.reduce((acc, curr) => acc + curr.uniqueWalletsConnected, 0);
116119

117120
const newUsers = userStats
118-
.filter(
119-
(u) => new Date(u.date).toISOString() === new Date(date).toISOString(),
120-
)
121+
.filter((u) => new Date(u.date).toISOString().slice(0, 10) === date)
121122
.reduce((acc, curr) => acc + curr.newUsers, 0);
122123

123124
const volume = volumeStats
124125
.filter(
125126
(v) =>
126-
new Date(v.date).toISOString() === new Date(date).toISOString() &&
127+
new Date(v.date).toISOString().slice(0, 10) === date &&
127128
v.status === "completed",
128129
)
129130
.reduce((acc, curr) => acc + curr.amountUsdCents / 100, 0);
130131

131132
const fees = volumeStats
132133
.filter(
133134
(v) =>
134-
new Date(v.date).toISOString() === new Date(date).toISOString() &&
135+
new Date(v.date).toISOString().slice(0, 10) === date &&
135136
v.status === "completed",
136137
)
137138
.reduce((acc, curr) => acc + curr.developerFeeUsdCents / 100, 0);

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/analytics/chart/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type AsyncInAppWalletAnalyticsProps = Omit<
4040
async function AsyncInAppWalletAnalytics(
4141
props: AsyncInAppWalletAnalyticsProps,
4242
) {
43-
const range = props.range ?? getLastNDaysRange("last-120");
43+
const range = props.range ?? getLastNDaysRange("last-30");
4444

4545
const stats = await getInAppWalletUsage(
4646
{

0 commit comments

Comments
 (0)