Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export function getLastNDaysRange(id: DurationId) {
throw new Error(`Invalid duration id: ${id}`);
}

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

const value: Range = {
from: subDays(todayDate, durationInfo.days),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,34 @@ function processTimeSeriesData(
volumeStats: UniversalBridgeStats[],
): TimeSeriesMetrics[] {
const metrics: TimeSeriesMetrics[] = [];
const dates = [...new Set(userStats.map((a) => a.date))];
const dates = [
...new Set([
...userStats.map((a) => new Date(a.date).toISOString().slice(0, 10)),
...volumeStats.map((a) => new Date(a.date).toISOString().slice(0, 10)),
]),
];

for (const date of dates) {
const activeUsers = userStats
.filter(
(u) => new Date(u.date).toISOString() === new Date(date).toISOString(),
)
.filter((u) => new Date(u.date).toISOString().slice(0, 10) === date)
.reduce((acc, curr) => acc + curr.uniqueWalletsConnected, 0);

const newUsers = userStats
.filter(
(u) => new Date(u.date).toISOString() === new Date(date).toISOString(),
)
.filter((u) => new Date(u.date).toISOString().slice(0, 10) === date)
.reduce((acc, curr) => acc + curr.newUsers, 0);

const volume = volumeStats
.filter(
(v) =>
new Date(v.date).toISOString() === new Date(date).toISOString() &&
new Date(v.date).toISOString().slice(0, 10) === date &&
v.status === "completed",
)
.reduce((acc, curr) => acc + curr.amountUsdCents / 100, 0);

const fees = volumeStats
.filter(
(v) =>
new Date(v.date).toISOString() === new Date(date).toISOString() &&
new Date(v.date).toISOString().slice(0, 10) === date &&
v.status === "completed",
)
.reduce((acc, curr) => acc + curr.developerFeeUsdCents / 100, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type AsyncInAppWalletAnalyticsProps = Omit<
async function AsyncInAppWalletAnalytics(
props: AsyncInAppWalletAnalyticsProps,
) {
const range = props.range ?? getLastNDaysRange("last-120");
const range = props.range ?? getLastNDaysRange("last-30");

const stats = await getInAppWalletUsage(
{
Expand Down
Loading