-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (analytics) Add time dropdown to filter analytics with a time range
- Loading branch information
1 parent
07928c7
commit 515fcaf
Showing
7 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const timeFilterValues = [ | ||
'today', | ||
'last7Days', | ||
'last30Days', | ||
'yearToDate', | ||
'allTime', | ||
] as const | ||
|
||
export const timeFilterLabels: Record< | ||
(typeof timeFilterValues)[number], | ||
string | ||
> = { | ||
today: 'Today', | ||
last7Days: 'Last 7 days', | ||
last30Days: 'Last 30 days', | ||
yearToDate: 'Year to date', | ||
allTime: 'All time', | ||
} | ||
|
||
export const defaultTimeFilter = 'today' as const |
18 changes: 18 additions & 0 deletions
18
apps/builder/src/features/analytics/helpers/parseDateFromTimeFilter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { timeFilterValues } from '../constants' | ||
|
||
export const parseDateFromTimeFilter = ( | ||
timeFilter: (typeof timeFilterValues)[number] | ||
): Date | undefined => { | ||
switch (timeFilter) { | ||
case 'today': | ||
return new Date(new Date().setHours(0, 0, 0, 0)) | ||
case 'last7Days': | ||
return new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) | ||
case 'last30Days': | ||
return new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) | ||
case 'yearToDate': | ||
return new Date(new Date().getFullYear(), 0, 1) | ||
case 'allTime': | ||
return | ||
} | ||
} |