Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Expand selected date range to start of first date

Tim Wilson2261332d37f4
diff --git a/apps/web/ui/analytics/index.tsx b/apps/web/ui/analytics/index.tsx
index afc6ca42de..6207cae4c5 100644
--- a/apps/web/ui/analytics/index.tsx
+++ b/apps/web/ui/analytics/index.tsx
@@ -8,7 +8,7 @@
import { VALID_ANALYTICS_FILTERS } from "@/lib/analytics/constants";
import useWorkspace from "@/lib/swr/use-workspace";
import { fetcher } from "@dub/utils";
-import { endOfDay, min, subDays } from "date-fns";
+import { endOfDay, min, startOfDay, subDays } from "date-fns";
import { useParams, usePathname, useSearchParams } from "next/navigation";
import { createContext, useEffect, useMemo, useState } from "react";
import { toast } from "sonner";
@@ -80,7 +80,10 @@ export default function Analytics({
// Default to last 24 hours
const { start, end } = useMemo(() => {
return {
- start: new Date(searchParams?.get("start") || subDays(new Date(), 1)),
+ // Set to start of day
+ start: startOfDay(
+ new Date(searchParams?.get("start") || subDays(new Date(), 1)),
+ ),
// Set to end of day or now if that's in the future
end: min([