Skip to content

Commit a4aab5a

Browse files
committed
feat(dashboard): adds ecosystem wallet summary analytics
1 parent 4e375d3 commit a4aab5a

File tree

6 files changed

+44
-10
lines changed

6 files changed

+44
-10
lines changed

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/analytics/components/EcosystemAnalyticsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function EcosystemAnalyticsPage({
1616
}
1717

1818
const stats = await getEcosystemWalletUsage({
19-
ecosystemId: "e7f67837-6fa4-49fa-9f86-00546788e3d5",
19+
ecosystemId,
2020
from: range.from,
2121
to: range.to,
2222
period: interval,

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/analytics/components/EcosystemWalletUsersChartCard.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,17 @@ export function EcosystemWalletUsersChartCard(props: {
109109
const disableActions =
110110
props.isPending ||
111111
chartData.length === 0 ||
112-
chartData.every((data) => data.sponsoredUsd === 0);
112+
uniqueAuthMethods.every((authMethod) =>
113+
chartData.every((data) => data[authMethod] === 0),
114+
);
113115

114116
return (
115117
<div className="relative w-full rounded-lg border border-border bg-muted/50 p-4 md:p-6">
116118
<h3 className="mb-1 font-semibold text-xl tracking-tight md:text-2xl">
117119
Unique Users
118120
</h3>
119121
<p className="mb-3 text-muted-foreground text-sm">
120-
The total number of active users in your ecosystem.
122+
The total number of active users in your ecosystem for each period.
121123
</p>
122124

123125
<div className="top-6 right-6 mb-4 grid grid-cols-2 items-center gap-2 md:absolute md:mb-0 md:flex">
@@ -148,7 +150,9 @@ export function EcosystemWalletUsersChartCard(props: {
148150
{props.isPending ? (
149151
<LoadingChartState />
150152
) : chartData.length === 0 ||
151-
chartData.every((data) => data.sponsoredUsd === 0) ? (
153+
uniqueAuthMethods.every((authMethod) =>
154+
chartData.every((data) => data[authMethod] === 0),
155+
) ? (
152156
<EmptyChartState>
153157
<div className="flex flex-col items-center justify-center">
154158
<span className="mb-6 text-lg">

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/analytics/components/Summary.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { InAppWalletStats } from "@3rdweb-sdk/react/hooks/useApi";
1+
import type { EcosystemWalletStats } from "@3rdweb-sdk/react/hooks/useApi";
22
import { Stat } from "components/analytics/stat";
33
import { ActivityIcon, UserIcon } from "lucide-react";
44

5-
export function InAppWalletsSummary(props: {
6-
allTimeStats: InAppWalletStats[] | undefined;
7-
monthlyStats: InAppWalletStats[] | undefined;
5+
export function EcosystemWalletsSummary(props: {
6+
allTimeStats: EcosystemWalletStats[] | undefined;
7+
monthlyStats: EcosystemWalletStats[] | undefined;
88
}) {
99
const allTimeStats = props.allTimeStats?.reduce(
1010
(acc, curr) => {

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/EcosystemSlugLayout.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { redirect } from "next/navigation";
44
import { getAddress } from "thirdweb";
55
import { fetchEcosystem } from "../../../utils/fetchEcosystem";
66
import { EcosystemHeader } from "./ecosystem-header.client";
7+
import { getEcosystemWalletUsage } from "data/analytics/wallets/ecosystem";
78

89
export async function EcosystemLayoutSlug({
910
children,
@@ -30,11 +31,32 @@ export async function EcosystemLayoutSlug({
3031
redirect(ecosystemLayoutPath);
3132
}
3233

34+
const allTimeStatsPromise = getEcosystemWalletUsage({
35+
ecosystemId: ecosystem.id,
36+
from: new Date(2022, 0, 1),
37+
to: new Date(),
38+
period: "all",
39+
});
40+
41+
const monthlyStatsPromise = getEcosystemWalletUsage({
42+
ecosystemId: ecosystem.id,
43+
from: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
44+
to: new Date(),
45+
period: "month",
46+
});
47+
48+
const [allTimeStats, monthlyStats] = await Promise.all([
49+
allTimeStatsPromise,
50+
monthlyStatsPromise,
51+
]);
52+
3353
return (
3454
<div className="flex w-full flex-col gap-10">
3555
<EcosystemHeader
3656
ecosystem={ecosystem}
3757
ecosystemLayoutPath={ecosystemLayoutPath}
58+
allTimeStats={allTimeStats || []}
59+
monthlyStats={monthlyStats || []}
3860
/>
3961
{children}
4062
</div>

apps/dashboard/src/app/(dashboard)/dashboard/connect/ecosystem/[slug]/(active)/components/ecosystem-header.client.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { usePathname } from "next/navigation";
2727
import { useEcosystemList } from "../../../hooks/use-ecosystem-list";
2828
import type { Ecosystem } from "../../../types";
2929
import { useEcosystem } from "../hooks/use-ecosystem";
30+
import { EcosystemWalletStats } from "@3rdweb-sdk/react/hooks/useApi";
31+
import { EcosystemWalletsSummary } from "../analytics/components/Summary";
3032

3133
function EcosystemAlertBanner({ ecosystem }: { ecosystem: Ecosystem }) {
3234
switch (ecosystem.status) {
@@ -110,6 +112,8 @@ function EcosystemSelect(props: {
110112
export function EcosystemHeader(props: {
111113
ecosystem: Ecosystem;
112114
ecosystemLayoutPath: string;
115+
allTimeStats: EcosystemWalletStats[];
116+
monthlyStats: EcosystemWalletStats[];
113117
}) {
114118
const pathname = usePathname();
115119
const { data: fetchedEcosystem } = useEcosystem({
@@ -193,6 +197,10 @@ export function EcosystemHeader(props: {
193197
/>
194198
</div>
195199
</div>
200+
<EcosystemWalletsSummary
201+
allTimeStats={props.allTimeStats}
202+
monthlyStats={props.monthlyStats}
203+
/>
196204
<TabLinks
197205
links={[
198206
{

apps/dashboard/src/data/analytics/wallets/ecosystem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { InAppWalletStats } from "@3rdweb-sdk/react/hooks/useApi";
1+
import type { EcosystemWalletStats } from "@3rdweb-sdk/react/hooks/useApi";
22
import { fetchAnalytics } from "../fetch-analytics";
33

44
export async function getEcosystemWalletUsage(args: {
@@ -36,5 +36,5 @@ export async function getEcosystemWalletUsage(args: {
3636

3737
const json = await res.json();
3838

39-
return json.data as InAppWalletStats[];
39+
return json.data as EcosystemWalletStats[];
4040
}

0 commit comments

Comments
 (0)