Skip to content

Commit e866565

Browse files
authored
Merge pull request #33 from tinybirdco/fixes01
add axis
2 parents 187975c + 0d179c8 commit e866565

File tree

4 files changed

+56
-32
lines changed

4 files changed

+56
-32
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
.venv
33
.tinyb
4+
.tmp

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ interface AuthMechData {
1717
logins: number
1818
}
1919

20+
interface ConversionData {
21+
new_signups: number
22+
active_new_users: number
23+
conversion_rate: number
24+
}
25+
2026
export default function Auth0Dashboard() {
2127
const [token] = useQueryState('token')
2228
const [monthlySignUps, setMonthlySignUps] = useState<number>(0)
@@ -30,16 +36,17 @@ export default function Auth0Dashboard() {
3036
if (!token) return
3137

3238
try {
33-
const [monthlySignUpsResult, monthlyMauResult, dauResult, authMechResult] = await Promise.all([
39+
const [monthlySignUpsResult, monthlyMauResult, dauResult, authMechResult, conversionResult] = await Promise.all([
3440
pipe(token, 'auth0_signups'),
3541
pipe(token, 'auth0_mau'),
3642
pipe<{ data: DauDataPoint[] }>(token, 'auth0_dau_ts'),
37-
pipe<{ data: AuthMechData[] }>(token, 'auth0_mech_usage')
43+
pipe<{ data: AuthMechData[] }>(token, 'auth0_mech_usage'),
44+
pipe<{ data: ConversionData[] }>(token, 'auth0_conversion_rate')
3845
])
3946

4047
setMonthlySignUps(monthlySignUpsResult.data[0]?.total || 0)
4148
setMonthlyMau(monthlyMauResult.data[0]?.active || 0)
42-
setConversionRate(0)
49+
setConversionRate(conversionResult.data[0]?.conversion_rate || 0)
4350
setDauData(dauResult.data)
4451
setAuthMechData(authMechResult.data)
4552
} catch (error) {
@@ -67,7 +74,7 @@ export default function Auth0Dashboard() {
6774
<MetricCard
6875
title="Conversion Rate"
6976
value={`${conversionRate}%`}
70-
description="Active users / Total users"
77+
description="New users who became active in the last 30 days"
7178
/>
7279
</div>
7380

apps/web/src/components/tools/auth0/dau-chart.tsx

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ChartConfig,
1313
ChartTooltipContent
1414
} from "@/components/ui/chart"
15-
import { Line, LineChart, XAxis } from "recharts"
15+
import { Line, LineChart, XAxis, YAxis } from "recharts"
1616

1717
interface DauDataPoint {
1818
day: string
@@ -41,8 +41,10 @@ export function DauChart({ data }: DauChartData) {
4141
<LineChart
4242
data={data}
4343
margin={{
44-
left: 12,
44+
left: 48,
4545
right: 12,
46+
top: 12,
47+
bottom: 32
4648
}}
4749
>
4850
<XAxis
@@ -52,37 +54,27 @@ export function DauChart({ data }: DauChartData) {
5254
tickMargin={8}
5355
interval="equidistantPreserveStart"
5456
tickFormatter={(value) => value.split('-')[2]}
57+
label={{
58+
value: "Day of Month",
59+
position: "bottom",
60+
offset: 20
61+
}}
62+
/>
63+
<YAxis
64+
tickLine={false}
65+
axisLine={false}
66+
tickMargin={8}
67+
label={{
68+
value: "Active Users",
69+
angle: -90,
70+
position: "left",
71+
offset: 32
72+
}}
5573
/>
5674
<ChartTooltip
5775
cursor={false}
5876
content={<ChartTooltipContent indicator="dot" />}
5977
/>
60-
{/* <ChartTooltip content={({ payload }) => {
61-
if (!payload?.length) return null
62-
63-
return (
64-
<div className="rounded-lg border bg-background p-2 shadow-sm">
65-
<div className="grid grid-cols-2 gap-2">
66-
<div className="flex flex-col">
67-
<span className="text-[0.70rem] uppercase text-muted-foreground">
68-
Date
69-
</span>
70-
<span className="font-bold text-muted-foreground">
71-
{payload[0].payload.day}
72-
</span>
73-
</div>
74-
<div className="flex flex-col">
75-
<span className="text-[0.70rem] uppercase text-muted-foreground">
76-
Active Users
77-
</span>
78-
<span className="font-bold">
79-
{payload[0].value}
80-
</span>
81-
</div>
82-
</div>
83-
</div>
84-
)
85-
}} /> */}
8678
<Line
8779
type="monotone"
8880
dataKey="active"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
TOKEN "read" READ
2+
3+
NODE get_conversion
4+
SQL >
5+
6+
SELECT
7+
count(DISTINCT signups.user_id) as new_signups,
8+
count(DISTINCT logins.user_id) as active_new_users,
9+
ROUND(
10+
count(DISTINCT logins.user_id) / count(DISTINCT signups.user_id) * 100, 1
11+
) as conversion_rate
12+
FROM
13+
(
14+
SELECT event.data.user_id as user_id
15+
FROM auth0
16+
WHERE event_type = 'ss' AND event_time >= now() - interval 30 days
17+
) signups
18+
LEFT JOIN
19+
(
20+
SELECT event.data.user_id as user_id
21+
FROM auth0
22+
WHERE event_type = 'sl' AND event_time >= now() - interval 30 days
23+
) logins
24+
ON signups.user_id = logins.user_id

0 commit comments

Comments
 (0)