-
Notifications
You must be signed in to change notification settings - Fork 432
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
chore: change to per-product usageV2 topic #6113
Conversation
🦋 Changeset detectedLatest commit: cb53011 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
/** | ||
* The source of the event. Example: "storage" | ||
*/ | ||
source: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer needed because events are sent to product-specific topics (and stored to product-specific tables).
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6113 +/- ##
==========================================
+ Coverage 56.81% 56.88% +0.06%
==========================================
Files 1152 1153 +1
Lines 63906 63896 -10
Branches 5178 5183 +5
==========================================
+ Hits 36311 36349 +38
+ Misses 26865 26819 -46
+ Partials 730 728 -2
*This pull request uses carry forward flags. Click here to find out more. |
return { | ||
...event, | ||
id: event.id ?? randomUUID(), | ||
created_at: event.created_at ?? new Date(), | ||
source: event.source, | ||
action: event.action, | ||
// Remove the "team_" prefix, if any. | ||
team_id: event.team_id.startsWith("team_") | ||
? event.team_id.slice(5) | ||
: event.team_id, | ||
project_id: event.project_id, | ||
sdk_name: event.sdk_name, | ||
sdk_platform: event.sdk_platform, | ||
sdk_version: event.sdk_version, | ||
sdk_os: event.sdk_os, | ||
product_name: event.product_name, | ||
product_version: event.product_version, | ||
data: JSON.stringify(event.data), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving ...event
after the team_id
assignment. Currently, the explicit property assignments will be overridden by the spread operator, preventing the defaults from taking effect. The intended order should be:
return {
id: event.id ?? randomUUID(),
created_at: event.created_at ?? new Date(),
team_id: event.team_id.startsWith("team_")
? event.team_id.slice(5)
: event.team_id,
...event
};
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
*/ | ||
data: Record<string, unknown>; | ||
[key: string]: boolean | number | string | Date | null | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an index signature here could cause TypeScript to miss type errors on the explicitly defined properties in UsageV2Event
. A safer approach would be to add a dedicated data
property with type Record<string, boolean | number | string | Date | null>
to handle the arbitrary key-value pairs, while keeping the explicit properties type-safe.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
size-limit report 📦
|
PR-Codex overview
This PR focuses on changing the event tracking in the
UsageV2
system to use per-product topics, enhancing the granularity of data collection.Detailed summary
sendUsageV2Events
to acceptproductName
and use it for topic naming.UsageV2Event
interface by removingsource
and changingdata
to allow more flexible types.getTopicName
function to generate topics based onproductName
.UsageV2Producer
to use a dynamic topic based onproductName
.