Skip to content

Commit 82d1115

Browse files
committed
[TOOL-4898] Dashboard: Replace PayEmbed with BuyWidget in asset page, add tracking
1 parent 5640d48 commit 82d1115

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/PayEmbedSection.tsx

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,47 @@
22

33
import { useTheme } from "next-themes";
44
import type { Chain, ThirdwebClient } from "thirdweb";
5-
import { PayEmbed } from "thirdweb/react";
6-
import { getSDKTheme } from "../../../../../../../../../@/utils/sdk-component-theme";
5+
import { BuyWidget } from "thirdweb/react";
6+
import {
7+
reportAssetBuyFailed,
8+
reportAssetBuySuccessful,
9+
} from "@/analytics/report";
10+
import { parseError } from "@/utils/errorParser";
11+
import { getSDKTheme } from "@/utils/sdk-component-theme";
712

813
export function BuyTokenEmbed(props: {
914
client: ThirdwebClient;
1015
chain: Chain;
11-
tokenSymbol: string;
12-
tokenName: string;
1316
tokenAddress: string;
1417
}) {
1518
const { theme } = useTheme();
1619
return (
17-
<PayEmbed
20+
<BuyWidget
21+
amount="1"
22+
chain={props.chain}
1823
className="!rounded-xl !w-full"
1924
client={props.client}
2025
connectOptions={{
2126
autoConnect: false,
2227
}}
23-
payOptions={{
24-
metadata: {
25-
name: `Buy ${props.tokenSymbol}`,
26-
},
27-
mode: "fund_wallet",
28-
prefillBuy: {
29-
allowEdits: {
30-
amount: true,
31-
chain: false,
32-
token: false,
33-
},
34-
amount: "1",
35-
chain: props.chain,
36-
token: {
37-
address: props.tokenAddress,
38-
name: props.tokenName,
39-
symbol: props.tokenSymbol,
40-
},
41-
},
28+
onError={(e) => {
29+
const errorMessage = parseError(e);
30+
reportAssetBuyFailed({
31+
assetType: "coin",
32+
chainId: props.chain.id,
33+
contractType: "DropERC20",
34+
error: errorMessage,
35+
});
36+
}}
37+
onSuccess={() => {
38+
reportAssetBuySuccessful({
39+
assetType: "coin",
40+
chainId: props.chain.id,
41+
contractType: "DropERC20",
42+
});
4243
}}
4344
theme={getSDKTheme(theme === "light" ? "light" : "dark")}
45+
tokenAddress={props.tokenAddress as `0x${string}`}
4446
/>
4547
);
4648
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/contract-analytics/contract-analytics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function ContractAnalyticsOverview(props: {
3939
</div>
4040
<ThirdwebAreaChart
4141
cardContentClassName="p-0"
42-
chartClassName="aspect-[1.5] lg:aspect-[3]"
42+
chartClassName="aspect-[1.2] lg:aspect-[2.6]"
4343
className="border-none bg-background p-0"
4444
config={{
4545
events: {

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/erc20.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ function BuyEmbed(props: {
141141
chain={props.clientContract.chain}
142142
client={props.clientContract.client}
143143
tokenAddress={props.clientContract.address}
144-
tokenName={props.tokenName}
145-
tokenSymbol={props.tokenSymbol}
146144
/>
147145
);
148146
}

0 commit comments

Comments
 (0)