Skip to content

Commit

Permalink
feat(analytics): improves amplitude reporting
Browse files Browse the repository at this point in the history
- only reports connect_wallet when wallet type changes
- reports events for ~25% of users only
  • Loading branch information
ygrishajev authored Feb 26, 2025
1 parent 5a58c29 commit c8399ae
Show file tree
Hide file tree
Showing 7 changed files with 369 additions and 127 deletions.
1 change: 1 addition & 0 deletions apps/deploy-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"long": "^5.2.3",
"lucide-react": "^0.292.0",
"material-ui-popup-state": "^4.0.2",
"murmurhash": "^2.0.1",
"nanoid": "^3.3.4",
"next": "^14.2.18",
"next-nprogress-bar": "^2.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ const ModalWrapper = (props: WalletModalProps) => {
if (isWalletModalOpen && !props.isOpen && isWalletConnected) {
setSelectedWalletType("custodial");

analyticsService.track("connect_wallet", {
category: "wallet",
label: "Connect wallet"
});
analyticsService.track(
"connect_wallet",
{
category: "wallet",
label: "Connect wallet"
},
"GA"
);

analyticsService.trackSwitch("connect_wallet", "custodial", "Amplitude");
}
}, [isWalletModalOpen, props.isOpen, isWalletConnected]);

Expand Down
13 changes: 9 additions & 4 deletions apps/deploy-web/src/context/WalletProvider/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ export const WalletProvider = ({ children }) => {
}

if (selectedWalletType === "managed" && userWallet.isWalletConnected) {
analyticsService.track("connect_wallet", {
category: "wallet",
label: "Connect wallet"
});
analyticsService.track(
"connect_wallet",
{
category: "wallet",
label: "Connect wallet"
},
"GA"
);
analyticsService.trackSwitch("connect_wallet", "custodial", "Amplitude");
}

setSelectedWalletType(prev => (prev === "custodial" ? "managed" : "custodial"));
Expand Down
14 changes: 10 additions & 4 deletions apps/deploy-web/src/hooks/useManagedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ export const useManagedWallet = () => {
setSelectedWalletType("managed");
}

analyticsService.track("connect_managed_wallet", {
category: "wallet",
label: "Connect managed wallet"
});
analyticsService.track(
"connect_managed_wallet",
{
category: "wallet",
label: "Connect managed wallet"
},
"GA"
);

analyticsService.trackSwitch("connect_wallet", "managed", "Amplitude");
}
});
const { mutate: create, data: created, isLoading: isCreating, isSuccess: isCreated } = useCreateManagedWalletMutation();
Expand Down
Loading

0 comments on commit c8399ae

Please sign in to comment.