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(api): track api calls for analytics #3191

Merged
merged 1 commit into from
Mar 10, 2025
Merged

feat(api): track api calls for analytics #3191

merged 1 commit into from
Mar 10, 2025

Conversation

IcaroG
Copy link
Contributor

@IcaroG IcaroG commented Mar 7, 2025

Closes #2224

@IcaroG IcaroG requested a review from ryscheng March 7, 2025 19:34
@IcaroG IcaroG self-assigned this Mar 7, 2025
Copy link

vercel bot commented Mar 7, 2025

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

Name Status Preview Comments Updated (UTC)
kariba-network ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 8:54pm
oso-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 8:54pm

Copy link

@oso-prs oso-prs bot left a comment

Choose a reason for hiding this comment

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

Auto-approved! please merge responsibly 😄

@IcaroG
Copy link
Contributor Author

IcaroG commented Mar 7, 2025

The package @segment/analytics-node actually works in the browser as well, but I decided to keep both next and node library because the next one has some functionalities to automatically get the correct data in the browser like userId/anonymousId, path, searchParams, etc

const trackParams = {
event: "api_call",
properties: {
path: request.nextUrl.pathname,
Copy link
Member

Choose a reason for hiding this comment

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

Sweet! This is all a great start, worth moving forward assuming you've tested this.

Minor note for a future PR:
I think the graphql query is stored in the body of a POST request, so we won't know what models are touched unless we parse a bit more.

@IcaroG IcaroG added this pull request to the merge queue Mar 10, 2025
Merged via the queue into main with commit 70cf124 Mar 10, 2025
8 of 9 checks passed
@IcaroG IcaroG deleted the icaro/analytics branch March 10, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API analytics
2 participants