Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(dashboard): the events date range includes the last selected day

Carl-Gerhard Lindesvärd7f887ddb798b
diff --git a/apps/start/src/modals/date-ranger-picker.tsx b/apps/start/src/modals/date-ranger-picker.tsx
index a08c15266..2b340a9d6 100644
--- a/apps/start/src/modals/date-ranger-picker.tsx
+++ b/apps/start/src/modals/date-ranger-picker.tsx
@@ -1,6 +1,6 @@
import type { IInterval } from '@openpanel/core/modules/report/report.constants';
import { getDefaultIntervalByDates } from '@openpanel/core/modules/report/report.constants';
-import { endOfDay, subMonths } from 'date-fns';
+import { endOfDay, startOfDay, subMonths } from 'date-fns';
import { CheckIcon, XIcon } from 'lucide-react';
import { useState } from 'react';
import { popModal } from '.';
@@ -11,6 +11,7 @@ import { useBreakpoint } from '@/hooks/use-breakpoint';
import { formatDate } from '@/utils/date';
interface Props {
+ /** `startDate` is the start of the first picked day, `endDate` the end of the last, in the browser's timezone. */
onChange: (payload: {
startDate: Date;
endDate: Date;
@@ -73,12 +74,14 @@ export default function DateRangerPicker({
onClick={() => {
popModal();
if (startDate && endDate) {
+ const rangeStart = startOfDay(startDate);
+ const rangeEnd = endOfDay(endDate);
onChange({
- startDate,
- endDate,
+ startDate: rangeStart,
+ endDate: rangeEnd,
interval: getDefaultIntervalByDates(
- startDate.toISOString(),
- endDate.toISOString()
+ rangeStart.toISOString(),
+ rangeEnd.toISOString()
)!,
});
}