Skip to content

Commit d10436d

Browse files
committed
Dashboard: Add tracking for fund wallet modal (#7800)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the analytics tracking for the `FundWalletModal` component by adding new reporting functions and integrating them into the wallet funding process. ### Detailed summary - Added `reportFundWalletOpened` function to track when the fund wallet modal is opened. - Integrated `reportFundWalletOpened` call in `BackendWalletsTable` when the fund wallet button is clicked. - Added `reportFundWalletSuccessful` and `reportFundWalletFailed` functions to track successful and failed fund wallet transactions. - Integrated success and error reporting in the `FundWalletModal` component. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added analytics tracking for opening the fund wallet modal, successful wallet funding, and failed wallet funding attempts, including error reporting. * Enhanced the fund wallet experience with event reporting on user actions for improved insights. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 56b12c6 commit d10436d

File tree

3 files changed

+50
-0
lines changed
  • apps/dashboard/src

3 files changed

+50
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,3 +467,39 @@ export function reportAssetPageview(properties: {
467467
}) {
468468
posthog.capture("asset pageview", properties);
469469
}
470+
471+
/**
472+
* ### Why do we need to report this event?
473+
* - To track the usage of fund wallet modal
474+
* - To create a funnel "fund wallet modal opened" -> "fund wallet buy successful" to understand the conversion rate
475+
*
476+
* ### Who is responsible for this event?
477+
* @MananTank
478+
*/
479+
export function reportFundWalletOpened() {
480+
posthog.capture("fund wallet opened");
481+
}
482+
483+
/**
484+
* ### Why do we need to report this event?
485+
* - To track the number of successful fund wallet buys
486+
* - To create a funnel "fund wallet modal opened" -> "fund wallet buy successful" to understand the conversion rate
487+
*
488+
* ### Who is responsible for this event?
489+
* @MananTank
490+
*/
491+
export function reportFundWalletSuccessful() {
492+
posthog.capture("fund wallet successful");
493+
}
494+
495+
/**
496+
* ### Why do we need to report this event?
497+
* - To track the number of failed fund wallet buys
498+
* - To track the errors that users encounter when trying to buy from a fund wallet modal
499+
*
500+
* ### Who is responsible for this event?
501+
* @MananTank
502+
*/
503+
export function reportFundWalletFailed(params: { errorMessage: string }) {
504+
posthog.capture("fund wallet failed", params);
505+
}

apps/dashboard/src/@/components/blocks/fund-wallets-modal/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import type { ThirdwebClient } from "thirdweb";
99
import { defineChain } from "thirdweb/chains";
1010
import { CheckoutWidget, useActiveWalletChain } from "thirdweb/react";
1111
import { z } from "zod";
12+
import {
13+
reportFundWalletFailed,
14+
reportFundWalletSuccessful,
15+
} from "@/analytics/report";
1216
import { SingleNetworkSelector } from "@/components/blocks/NetworkSelectors";
1317
import { TokenSelector } from "@/components/blocks/TokenSelector";
1418
import { Button } from "@/components/ui/button";
@@ -252,6 +256,14 @@ function FundWalletModalContent(props: FundWalletModalProps) {
252256
className="!w-full !max-w-full !min-w-0 !rounded-b-none !border-none"
253257
theme={getSDKTheme(theme === "dark" ? "dark" : "light")}
254258
name={props.checkoutWidgetTitle}
259+
onSuccess={() => {
260+
reportFundWalletSuccessful();
261+
}}
262+
onError={(error) => {
263+
reportFundWalletFailed({
264+
errorMessage: error.message,
265+
});
266+
}}
255267
/>
256268
</div>
257269

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/overview/components/backend-wallets-table.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { toast } from "sonner";
1717
import { getAddress, type ThirdwebClient } from "thirdweb";
1818
import { isAddress, shortenAddress } from "thirdweb/utils";
1919
import { z } from "zod";
20+
import { reportFundWalletOpened } from "@/analytics/report";
2021
import { FundWalletModal } from "@/components/blocks/fund-wallets-modal";
2122
import { TWTable } from "@/components/blocks/TWTable";
2223
import { WalletAddress } from "@/components/blocks/wallet-address";
@@ -268,6 +269,7 @@ export const BackendWalletsTable: React.FC<BackendWalletsTableProps> = ({
268269
onClick: (wallet) => {
269270
setSelectedBackendWallet(wallet);
270271
setReceiveOpen(true);
272+
reportFundWalletOpened();
271273
},
272274
text: "Fund wallet",
273275
},

0 commit comments

Comments
 (0)