Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Buy Telemetry #1969

Merged
merged 1 commit into from
Feb 27, 2025
Merged

feat: Add Buy Telemetry #1969

merged 1 commit into from
Feb 27, 2025

Conversation

cpcramer
Copy link
Contributor

What changed? Why?

Notes to reviewers

How has it been tested?

Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 6:24pm
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 6:24pm
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 6:24pm

@cpcramer cpcramer force-pushed the paul/add-buy-telemetry branch from 3f4fd2c to fb12718 Compare February 20, 2025 18:28
Comment on lines 213 to 225
amount?: number;
token?: string;
};
[BuyEvent.BuyOptionSelected]: CommonAnalyticsData & {
option: BuyOption;
option?: BuyOption;
};
[BuyEvent.BuySuccess]: CommonAnalyticsData & {
address: string;
amount: number;
from: string;
paymaster: boolean;
to: string;
transactionHash: string;
address?: string;
amount?: number;
from?: string;
paymaster?: boolean;
to?: string;
transactionHash?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to comment above, optional seems weird on these. if BuyOptionSelected, i'd expect it to be required that there's a BuyOption, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking here: It just helps with type errors and flexibility with how we are handling analytics. Sometimes things break and I don't ever want analytics to block. While i'd prefer all parameters to be passed, I'd still rather have some information about the event then no event at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should make these value optional and not key optional. That'll ensure that you know exactly what you should pass in the ideal state.

e.g.

address: string | undefined
amount number | undefined
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great idea. I should actually refactor all event types to follow this pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

brendan-defi
brendan-defi previously approved these changes Feb 25, 2025
@@ -415,6 +451,7 @@ export function BuyProvider({
updateLifecycleStatus,
useAggregator,
walletCapabilities,
sendAnalytics,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little weird to expose out of BuyProvider, the fact that we're returning it from multiple contexts suggests there are some design flaws with useAnalytics

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update - We are not exposing sendAnalytics out of the BuyProvider here. In general, analytics could use a refactor to remain consistent across all components, reduce unnecessary memoization, minimize amount of code needed to support, etc .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep my bad, read this wrong! sorry

@cpcramer cpcramer merged commit 191ae30 into main Feb 27, 2025
16 checks passed
@cpcramer cpcramer deleted the paul/add-buy-telemetry branch February 27, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants