Skip to content

Commit a624a3d

Browse files
committed
hourly
1 parent e0fa7fc commit a624a3d

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

apps/web/src/components/tools/auth0/dashboard.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from "@/components/ui/select"
2020
import { Separator } from "@/components/ui/separator"
2121
import { Card, CardContent } from "@/components/ui/card"
22+
import { Button } from "@/components/ui/button"
2223

2324
interface ConversionData {
2425
new_signups: number
@@ -87,6 +88,7 @@ export default function Auth0Dashboard() {
8788
const [selectedConnection, setSelectedConnection] = useState<string>('all')
8889
const [applications, setApplications] = useState<Array<{ client_id: string, client_name: string }>>([])
8990
const [connections, setConnections] = useState<Array<{ connection_id: string, connection_name: string }>>([])
91+
const [timeRange, setTimeRange] = useState<'hourly' | 'daily' | 'monthly'>('daily')
9092

9193
useEffect(() => {
9294
async function fetchInitialData() {
@@ -124,12 +126,14 @@ export default function Auth0Dashboard() {
124126
const params = {
125127
date_from: fromDate,
126128
date_to: toDate,
129+
time_range: timeRange,
127130
...(selectedApp !== 'all' && { client_id: selectedApp }),
128131
...(selectedConnection !== 'all' && { connection_id: selectedConnection })
129132
}
130133

131134
const thirtyDayParams = {
132135
date_from: thirtyDaysAgo,
136+
time_range: timeRange,
133137
...(selectedApp !== 'all' && { client_id: selectedApp }),
134138
...(selectedConnection !== 'all' && { connection_id: selectedConnection })
135139
}
@@ -150,6 +154,7 @@ export default function Auth0Dashboard() {
150154
dailyLoginFailsResult
151155
] = await Promise.all([
152156
pipe<UsersResult>(token, 'auth0_users_total', selectedApp !== 'all' || selectedConnection !== 'all' ? {
157+
time_range: timeRange,
153158
...(selectedApp !== 'all' && { client_id: selectedApp }),
154159
...(selectedConnection !== 'all' && { connection_id: selectedConnection })
155160
} : undefined),
@@ -193,7 +198,7 @@ export default function Auth0Dashboard() {
193198
return () => {
194199
mounted = false
195200
}
196-
}, [token, dateRange.from, dateRange.to, dateRange.compareMode, selectedApp, selectedConnection])
201+
}, [token, dateRange.from, dateRange.to, dateRange.compareMode, selectedApp, selectedConnection, timeRange])
197202

198203
return (
199204
<div className="space-y-8">
@@ -275,18 +280,36 @@ export default function Auth0Dashboard() {
275280

276281
<Separator className="my-6" />
277282

278-
<div className="flex justify-end">
283+
<div className="flex justify-end items-center gap-4">
284+
<div className="flex items-center gap-2">
285+
<Button
286+
variant={timeRange === 'hourly' ? 'default' : 'outline'}
287+
size="sm"
288+
onClick={() => setTimeRange('hourly')}
289+
>
290+
Hourly
291+
</Button>
292+
<Button
293+
variant={timeRange === 'daily' ? 'default' : 'outline'}
294+
size="sm"
295+
onClick={() => setTimeRange('daily')}
296+
>
297+
Daily
298+
</Button>
299+
<Button
300+
variant={timeRange === 'monthly' ? 'default' : 'outline'}
301+
size="sm"
302+
onClick={() => setTimeRange('monthly')}
303+
>
304+
Monthly
305+
</Button>
306+
</div>
279307
<DateRangePicker
280308
initialDateRange={dateRange}
281309
onChange={(newRange) => setDateRange(newRange)}
282310
/>
283311
</div>
284312

285-
<DauChart
286-
data={dauData}
287-
comparisonData={dateRange.compareMode ? dauComparisonData : undefined}
288-
/>
289-
290313
{/* Charts Grid */}
291314
<div className="grid gap-4 grid-cols-1">
292315
<DauChart data={dauData} />

tinybird/pipes/auth0_daily_login_fails.pipe

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ TAGS "auth0"
55
NODE ep
66
SQL >
77
%
8-
SELECT toDate(toStartOfDay(event_time)) as day, count() as fails
8+
SELECT
9+
{% if defined(time_range) and time_range == 'hourly' %}
10+
toStartOfHour(event_time)::DateTime as day,
11+
{% elif defined(time_range) and time_range == 'monthly' %}
12+
toStartOfMonth(event_time)::Date as day,
13+
{% else %}
14+
toStartOfDay(event_time)::Date as day,
15+
{% end %}
16+
count() as fails
917
FROM auth0
1018
where event_type == 'f'
1119
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}

tinybird/pipes/auth0_daily_signups.pipe

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ TAGS "auth0"
55
NODE ep
66
SQL >
77
%
8-
SELECT toDate(toStartOfDay(event_time)) as day, count() as signups
8+
SELECT
9+
{% if defined(time_range) and time_range == 'hourly' %}
10+
toStartOfHour(event_time)::DateTime as day,
11+
{% elif defined(time_range) and time_range == 'monthly' %}
12+
toStartOfMonth(event_time)::Date as day,
13+
{% else %}
14+
toStartOfDay(event_time)::Date as day,
15+
{% end %}
16+
count() as signups
917
FROM auth0
1018
WHERE event_type = 'ss'
1119
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}

tinybird/pipes/auth0_dau_ts.pipe

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ TAGS "auth0"
55
NODE ep
66
SQL >
77
%
8-
SELECT toStartOfDay(event_time)::Date as day, count(DISTINCT event.data.user_id) as active
8+
SELECT
9+
{% if defined(time_range) and time_range == 'hourly' %}
10+
toStartOfHour(event_time)::DateTime as day,
11+
{% elif defined(time_range) and time_range == 'monthly' %}
12+
toStartOfMonth(event_time)::Date as day,
13+
{% else %}
14+
toStartOfDay(event_time)::Date as day,
15+
{% end %}
16+
count(DISTINCT event.data.user_id) as active
917
FROM auth0
1018
WHERE event_type == 's'
1119
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}

0 commit comments

Comments
 (0)