Skip to content

Commit 9dc54cb

Browse files
[gdpatchagent] feat: fire widget dashboard button click events (AI Credits, GoodReserve, Superfluid Rewards)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> On-Behalf-Of: gdpatchagent[onecli] (yaskkeryodtdijpv)
1 parent a42a654 commit 9dc54cb

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src/sections/Home/components/WalletSection.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,29 @@ import { postMessageToReactNative } from "@/utils/messageReactNative"
3030
import { isPwa } from "@/utils/pwa"
3131
import {
3232
coreDashboardActions,
33+
type DashboardAction,
3334
widgetDashboardActions,
3435
} from "@/widgets/registry"
3536

3637
import { Menu } from "./Menu"
3738
import { ProfileCard } from "./ProfileCard"
3839
import styles from "./WalletSection.module.css"
3940

41+
// Widget dashboard buttons that should report a click. Core actions
42+
// (Send/Receive/Swap/...) are intentionally excluded - they only track
43+
// action completion, not the click itself.
44+
type WidgetTabSelectedEventType =
45+
| AnalyticsEventTypes.AICreditsTabSelected
46+
| AnalyticsEventTypes.GoodReserveTabSelected
47+
| AnalyticsEventTypes.SuperfluidCampaignTabSelected
48+
49+
const widgetActionEventType: Record<string, WidgetTabSelectedEventType> = {
50+
"goodwidget.ai-credits": AnalyticsEventTypes.AICreditsTabSelected,
51+
"goodwidget.goodreserve": AnalyticsEventTypes.GoodReserveTabSelected,
52+
"goodwidget.superfluid-campaign":
53+
AnalyticsEventTypes.SuperfluidCampaignTabSelected,
54+
}
55+
4056
export default function WalletSection({
4157
children,
4258
}: {
@@ -199,7 +215,10 @@ export default function WalletSection({
199215
predictions: homeTranslations.predictions,
200216
walletconnect: homeTranslations.walletConnect,
201217
}
202-
const dashboardActions = [...coreDashboardActions, ...widgetDashboardActions]
218+
const dashboardActions: readonly DashboardAction[] = [
219+
...coreDashboardActions,
220+
...widgetDashboardActions,
221+
]
203222

204223
return (
205224
<>
@@ -242,13 +261,21 @@ export default function WalletSection({
242261
: action.id === "walletconnect" && sessions.length > 0
243262
? "connected"
244263
: undefined
264+
const widgetEventType = action.widgetId
265+
? widgetActionEventType[action.widgetId]
266+
: undefined
245267

246268
return (
247269
<Link
248270
key={action.id}
249271
href={`/${locale}/${action.routeSlug}`}
250272
scroll={false}
251273
prefetch={true}
274+
onClick={
275+
widgetEventType
276+
? () => captureEvent({ type: widgetEventType })
277+
: undefined
278+
}
252279
>
253280
<RoundButton
254281
icon={icon}

0 commit comments

Comments
 (0)