Skip to content

Commit 556e113

Browse files
Revert "[Dashboard] Feature: Adds analytics to in-app-wallets page (#5186) (#5228)
1 parent 6e87a86 commit 556e113

File tree

26 files changed

+256
-827
lines changed

26 files changed

+256
-827
lines changed

apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,6 @@ export interface WalletStats {
235235
walletType: string;
236236
}
237237

238-
export interface InAppWalletStats {
239-
date: string;
240-
authenticationMethod: string;
241-
uniqueWalletsConnected: number;
242-
}
243-
244238
export interface UserOpStats {
245239
date: string;
246240
successful: number;

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/_components/tabs.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/_constants.tsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/analytics/page.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/config/page.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/layout.tsx

Lines changed: 0 additions & 78 deletions
This file was deleted.

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/page.tsx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { redirect } from "next/navigation";
2+
import { EmbeddedWallets } from "../../../../../../components/embedded-wallets";
3+
import { getAuthToken } from "../../../../../api/lib/getAuthToken";
4+
import { PageHeader } from "../PageHeader";
5+
import { getInAppWalletSupportedAPIKeys } from "../getInAppWalletSupportedAPIKeys";
6+
import { InAppWalletsAPIKeysMenu } from "../inAppWalletsAPIKeysMenu";
27

38
export default async function Page(props: {
49
params: {
@@ -8,7 +13,44 @@ export default async function Page(props: {
813
tab?: string;
914
};
1015
}) {
16+
const authToken = getAuthToken();
1117
const { clientId } = props.params;
1218

13-
redirect(`/dashboard/connect/in-app-wallets/${clientId}/analytics`);
19+
if (!authToken) {
20+
redirect(
21+
`/login?next=${encodeURIComponent(`/dashboard/connect/in-app-wallets/${clientId}`)}`,
22+
);
23+
}
24+
25+
const apiKeys = await getInAppWalletSupportedAPIKeys();
26+
const apiKey = apiKeys.find((key) => key.key === clientId);
27+
28+
if (!apiKey) {
29+
redirect("/dashboard/connect/in-app-wallets");
30+
}
31+
32+
return (
33+
<div>
34+
{/* header */}
35+
<div className="flex flex-col gap-4 lg:flex-row lg:justify-between">
36+
<PageHeader />
37+
<div>
38+
<InAppWalletsAPIKeysMenu
39+
apiKeys={apiKeys.map((x) => ({
40+
name: x.name,
41+
key: x.key,
42+
}))}
43+
selectedAPIKey={apiKey}
44+
/>
45+
</div>
46+
</div>
47+
48+
<div className="h-8" />
49+
<EmbeddedWallets
50+
apiKey={apiKey}
51+
trackingCategory="embedded-wallet"
52+
defaultTab={props.searchParams.tab === "1" ? 1 : 0}
53+
/>
54+
</div>
55+
);
1456
}

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/[clientId]/users/page.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/dashboard/src/app/(dashboard)/dashboard/connect/in-app-wallets/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AnalyticsCallout } from "../../../../team/[team_slug]/[project_slug]/connect/in-app-wallets/_components/AnalyticsCallout";
12
import { InAppWaletFooterSection } from "../../../../team/[team_slug]/[project_slug]/connect/in-app-wallets/_components/footer";
23

34
export default function Layout(props: {
@@ -8,6 +9,7 @@ export default function Layout(props: {
89
{props.children}
910
<div className="h-16" />
1011
{/* Footer */}
12+
<AnalyticsCallout trackingCategory="embedded-wallet" />
1113
<div className="h-5" />
1214
<InAppWaletFooterSection trackingCategory="embedded-wallet" />
1315
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { TrackedLinkTW } from "@/components/ui/tracked-link";
5+
import { useAccountUsage } from "@3rdweb-sdk/react/hooks/useApi";
6+
import { UsageCard } from "components/settings/Account/UsageCard";
7+
import { ArrowRightIcon } from "lucide-react";
8+
import { useMemo } from "react";
9+
import { toNumber, toPercent } from "utils/number";
10+
11+
type AnalyticsCalloutProps = {
12+
trackingCategory: string;
13+
};
14+
15+
export const AnalyticsCallout: React.FC<AnalyticsCalloutProps> = ({
16+
trackingCategory,
17+
}) => {
18+
const usageQuery = useAccountUsage();
19+
20+
const walletsMetrics = useMemo(() => {
21+
if (!usageQuery?.data) {
22+
return undefined;
23+
}
24+
25+
const usageData = usageQuery.data;
26+
27+
const numOfWallets = usageData.usage.embeddedWallets.countWalletAddresses;
28+
const limitWallets = usageData.limits.embeddedWallets;
29+
const percent = toPercent(numOfWallets, limitWallets);
30+
31+
return {
32+
total: `${toNumber(numOfWallets)} / ${toNumber(
33+
limitWallets,
34+
)} (${percent}%)`,
35+
progress: percent,
36+
...(usageData.billableUsd.embeddedWallets > 0
37+
? {
38+
overage: usageData.billableUsd.embeddedWallets,
39+
}
40+
: {}),
41+
};
42+
}, [usageQuery]);
43+
44+
return (
45+
<div className="flex flex-col gap-6 rounded-lg border border-border bg-muted/50 p-4 md:px-10 md:py-12 lg:flex-row lg:justify-between">
46+
{/* Left */}
47+
<div>
48+
<p className="mb-3 text-muted-foreground text-xs">Analytics</p>
49+
<h2 className="mb-5 max-w-[500px] font-semibold text-2xl tracking-tight">
50+
View more insights about how users are interacting with your
51+
application
52+
</h2>
53+
54+
<Button asChild variant="outline" size="sm">
55+
<TrackedLinkTW
56+
href="/dashboard/connect/analytics"
57+
category={trackingCategory}
58+
label="view-analytics"
59+
className="mt-auto min-w-[150px] gap-2"
60+
>
61+
View Analytics
62+
<ArrowRightIcon className="size-4" />
63+
</TrackedLinkTW>
64+
</Button>
65+
</div>
66+
67+
{/* Right */}
68+
<div className="min-w-[280px]">
69+
{walletsMetrics && (
70+
<UsageCard
71+
{...walletsMetrics}
72+
name="Monthly Active Users"
73+
tooltip="Email wallet (with managed recovery code) usage is calculated by monthly active wallets (i.e. active as defined by at least 1 user log-in via email or social within the billing period month)."
74+
/>
75+
)}
76+
</div>
77+
</div>
78+
);
79+
};

0 commit comments

Comments
 (0)