feat: add mau card

This commit is contained in:
Ephraim Atta-Duncan
2025-01-25 12:23:26 +00:00
parent 54ea96391a
commit c40e802396
2 changed files with 19 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import {
Mail,
MailOpen,
PenTool,
UserCheck,
UserPlus,
UserSquare2,
Users,
@ -20,6 +21,7 @@ import { getRecipientsStats } from '@documenso/lib/server-only/admin/get-recipie
import {
getUserWithSignedDocumentMonthlyGrowth,
getUsersCount,
getUsersWithLastSignedInCount,
getUsersWithSubscriptionsCount,
} from '@documenso/lib/server-only/admin/get-users-stats';
import { getSignerConversionMonthly } from '@documenso/lib/server-only/user/get-signer-conversion';
@ -43,6 +45,7 @@ export default async function AdminStatsPage() {
// userWithAtLeastOneDocumentPerMonth,
// userWithAtLeastOneDocumentSignedPerMonth,
MONTHLY_USERS_SIGNED,
usersWithLastSignedInCount,
] = await Promise.all([
getUsersCount(),
getUsersWithSubscriptionsCount(),
@ -52,6 +55,7 @@ export default async function AdminStatsPage() {
// getUserWithAtLeastOneDocumentPerMonth(),
// getUserWithAtLeastOneDocumentSignedPerMonth(),
getUserWithSignedDocumentMonthlyGrowth(),
getUsersWithLastSignedInCount(),
]);
return (
@ -68,7 +72,11 @@ export default async function AdminStatsPage() {
title={_(msg`Active Subscriptions`)}
value={usersWithSubscriptionsCount}
/>
<CardMetric
icon={UserCheck}
title={_(msg`MAU (signed in)`)}
value={usersWithLastSignedInCount}
/>
<CardMetric
icon={FileCog}
title={_(msg`App Version`)}

View File

@ -50,6 +50,16 @@ export const getUserWithAtLeastOneDocumentSignedPerMonth = async () => {
});
};
export const getUsersWithLastSignedInCount = async () => {
return await prisma.user.count({
where: {
lastSignedIn: {
gte: DateTime.now().minus({ months: 1 }).toJSDate(),
},
},
});
};
export type GetUserWithDocumentMonthlyGrowth = Array<{
month: string;
count: number;