Skip to content

Commit 33fc3e5

Browse files
committed
[MNY-196] SDK: Add SwapWidget render event (#8113)
<!-- ## 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 introduces a new query using `useQuery` from `@tanstack/react-query` in the `SwapWidget` component to track the rendering event of the swap widget. ### Detailed summary - Added `useQuery` to the `SwapWidget` component. - Implemented a query function that calls `trackPayEvent` to log the rendering of the swap widget. - The tracking event includes the `client` from `props` and an event identifier `"ub:ui:swap_widget:render"`. > ✨ 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 * **Chores** * Added background telemetry for the Swap Widget to record render events for analytics. It runs automatically when the widget is displayed, requires no configuration, and does not change the UI or user experience. This helps track usage and adoption to inform future improvements. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ed47e93 commit 33fc3e5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use client";
22

3+
import { useQuery } from "@tanstack/react-query";
34
import { useCallback, useEffect, useState } from "react";
5+
import { trackPayEvent } from "../../../../../analytics/track/pay.js";
46
import type { Buy, Sell } from "../../../../../bridge/index.js";
57
import type { TokenWithPrices } from "../../../../../bridge/types/Token.js";
68
import type { ThirdwebClient } from "../../../../../client/client.js";
@@ -241,6 +243,17 @@ export type SwapWidgetProps = {
241243
* @bridge
242244
*/
243245
export function SwapWidget(props: SwapWidgetProps) {
246+
useQuery({
247+
queryFn: () => {
248+
trackPayEvent({
249+
client: props.client,
250+
event: "ub:ui:swap_widget:render",
251+
});
252+
return true;
253+
},
254+
queryKey: ["swap_widget:render"],
255+
});
256+
244257
return (
245258
<SwapWidgetContainer
246259
theme={props.theme}

0 commit comments

Comments
 (0)