diff --git a/src/analytics/types.ts b/src/analytics/types.ts index 59b6751..d69c5a9 100644 --- a/src/analytics/types.ts +++ b/src/analytics/types.ts @@ -48,6 +48,9 @@ export enum AnalyticsEventTypes { GoodDollarNewsTabSelected = "GoodDollar_News_Tab_Selected", WalletSignedMessageConfirmed = "Wallet_Message_Signed_Confirmed", WalletSignedMessageCancelled = "Wallet_Message_Signed_Cancelled", + AICreditsTabSelected = "AICredits_Tab_Selected", + GoodReserveTabSelected = "GoodReserve_Tab_Selected", + SuperfluidCampaignTabSelected = "SuperfluidCampaign_Tab_Selected", } export enum AvailableMethodsNames { @@ -261,3 +264,12 @@ export type AnalyticsEvent = chainName: string methodName: AvailableMethods } + | { + type: AnalyticsEventTypes.AICreditsTabSelected + } + | { + type: AnalyticsEventTypes.GoodReserveTabSelected + } + | { + type: AnalyticsEventTypes.SuperfluidCampaignTabSelected + } diff --git a/src/sections/Home/components/WalletSection.tsx b/src/sections/Home/components/WalletSection.tsx index 688dc47..a5834b9 100644 --- a/src/sections/Home/components/WalletSection.tsx +++ b/src/sections/Home/components/WalletSection.tsx @@ -30,6 +30,7 @@ import { postMessageToReactNative } from "@/utils/messageReactNative" import { isPwa } from "@/utils/pwa" import { coreDashboardActions, + type DashboardAction, widgetDashboardActions, } from "@/widgets/registry" @@ -37,6 +38,21 @@ import { Menu } from "./Menu" import { ProfileCard } from "./ProfileCard" import styles from "./WalletSection.module.css" +// Widget dashboard buttons that should report a click. Core actions +// (Send/Receive/Swap/...) are intentionally excluded - they only track +// action completion, not the click itself. +type WidgetTabSelectedEventType = + | AnalyticsEventTypes.AICreditsTabSelected + | AnalyticsEventTypes.GoodReserveTabSelected + | AnalyticsEventTypes.SuperfluidCampaignTabSelected + +const widgetActionEventType: Record = { + "goodwidget.ai-credits": AnalyticsEventTypes.AICreditsTabSelected, + "goodwidget.goodreserve": AnalyticsEventTypes.GoodReserveTabSelected, + "goodwidget.superfluid-campaign": + AnalyticsEventTypes.SuperfluidCampaignTabSelected, +} + export default function WalletSection({ children, }: { @@ -198,7 +214,10 @@ export default function WalletSection({ swap: homeTranslations.swap, walletconnect: homeTranslations.walletConnect, } - const dashboardActions = [...coreDashboardActions, ...widgetDashboardActions] + const dashboardActions: readonly DashboardAction[] = [ + ...coreDashboardActions, + ...widgetDashboardActions, + ] return ( <> @@ -241,6 +260,9 @@ export default function WalletSection({ : action.id === "walletconnect" && sessions.length > 0 ? "connected" : undefined + const widgetEventType = action.widgetId + ? widgetActionEventType[action.widgetId] + : undefined return ( captureEvent({ type: widgetEventType }) + : undefined + } >