Skip to content

Commit c934102

Browse files
authored
[MNY-253] Dashboard: Add tracking for token row in /tokens page, SDK: BridgeWidget component (#8254)
1 parent 8c58c13 commit c934102

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

apps/dashboard/src/@/analytics/report.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,18 @@ export function reportBridgePageLinkClick(params: {
687687
}) {
688688
posthog.capture("bridge page link clicked", params);
689689
}
690+
691+
/**
692+
* ### Why do we need to report this event?
693+
* - To track which tokens are users are clicking on in the token list page
694+
*
695+
* ### Who is responsible for this event?
696+
* @MananTank
697+
*
698+
*/
699+
export function reportTokenRowClicked(params: {
700+
chainId: number;
701+
tokenAddress: string;
702+
}) {
703+
posthog.capture("token row clicked", params);
704+
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/tx/[txHash]/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ function GeneericTxDetails(props: {
311311
label="Burnt fees"
312312
tooltip="The amount of fees that were burnt by the transaction."
313313
>
314-
<p>{toEther(block.baseFeePerGas || 0n * receipt.gasUsed)}</p>
314+
<p>
315+
{toEther((block.baseFeePerGas || 0n) * receipt.gasUsed)}{" "}
316+
{chain.nativeCurrency?.symbol}
317+
</p>
315318
</GridItem>
316319
</section>
317320

apps/dashboard/src/app/(app)/(dashboard)/tokens/components/tokens-table.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
44
import Link from "next/link";
55
import { type Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
6+
import { reportTokenRowClicked } from "@/analytics/report";
67
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
78
import { Button } from "@/components/ui/button";
89
import { Skeleton } from "@/components/ui/skeleton";
@@ -122,6 +123,12 @@ export function TokensTable(props: {
122123
className="gap-2 rounded-full bg-card hover:border-foreground/50 text-muted-foreground hover:bg-inverted hover:text-inverted-foreground"
123124
>
124125
<Link
126+
onClick={() =>
127+
reportTokenRowClicked({
128+
chainId: token.chainId,
129+
tokenAddress: token.address,
130+
})
131+
}
125132
aria-label={`Buy ${token.symbol}`}
126133
href={
127134
token.address.toLowerCase() ===

packages/thirdweb/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { useQuery } from "@tanstack/react-query";
12
import { useState } from "react";
3+
import { trackPayEvent } from "../../../../../analytics/track/pay.js";
24
import { defineChain } from "../../../../../chains/utils.js";
35
import type { ThirdwebClient } from "../../../../../client/client.js";
46
import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js";
@@ -242,6 +244,17 @@ export type BridgeWidgetProps = {
242244
export function BridgeWidget(props: BridgeWidgetProps) {
243245
const [tab, setTab] = useState<"swap" | "buy">("swap");
244246

247+
useQuery({
248+
queryFn: () => {
249+
trackPayEvent({
250+
client: props.client,
251+
event: "ub:ui:bridge_widget:render",
252+
});
253+
return true;
254+
},
255+
queryKey: ["bridge_widget:render"],
256+
});
257+
245258
return (
246259
<CustomThemeProvider theme={props.theme}>
247260
<EmbedContainer

0 commit comments

Comments
 (0)