-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(experiments): Tag support for shared metrics #28061
base: master
Are you sure you want to change the base?
Conversation
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.
PR Summary
This PR adds tag support for shared metrics in experiments, allowing users to organize and quickly filter metrics using tags in the UI.
Key changes:
- Added
experiment_saved_metric
foreign key toTaggedItem
model with corresponding database constraints and migrations - Integrated
TaggedItemSerializerMixin
intoExperimentSavedMetricSerializer
to handle tag operations - Added tag UI components in
SharedMetric.tsx
for managing tags on individual metrics - Implemented quick-select functionality in
SharedMetricModal.tsx
to filter metrics by clicking tags - Added conditional tag column in shared metrics table based on
TAGGING
feature flag
The implementation follows existing patterns for tag management in PostHog and includes proper database constraints to maintain data integrity.
8 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
const availableTags = Array.from( | ||
new Set( | ||
availableSharedMetrics | ||
.filter((metric: SharedMetric) => metric.tags) | ||
.flatMap((metric: SharedMetric) => metric.tags) | ||
.filter(Boolean) | ||
) | ||
).sort() |
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.
style: Consider memoizing availableTags with useMemo to prevent recalculation on every render
tags: newTags, | ||
}) | ||
}} | ||
saving={false} |
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.
style: saving prop is hardcoded to false - should reflect actual saving state from sharedMetricLogic to show proper loading state
Size Change: +756 B (+0.06%) Total Size: 1.16 MB ℹ️ View Unchanged
|
Nice love the speed on this! TY ❤️ I think there's opportunity for better UX for this, as this feels kinda "slapped on." An example I thought of was Google Drive's folder thing to move a document - but instead of moving you are selecting the tag (which shouldn't be so obviously a tag, maybe?) So...
Thoughts? |
Could, not strongly against. However, Google Docs doesn't let you select some docs from folder A and some docs from folder B: CleanShot.2025-01-29.at.13.44.06.mp4If we implemented such an ability, it would be difficult to see what's selected in folder A when you're in folder B. We could then add some UI that shows the selected metrics, but I think that's veering into overly complex territory.
To help me better understand your perspective, what makes you feel like it's "slapped on"? Are there small things we could do to make it feel more polished? To help inform the decision: there's currently one team with 28 metrics. Everyone else has 10 or less.
|
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
Yeah I think selecting metrics from a single collection for now is fine. If they want metrics from another collection they just go through the flow again.
I think it's that in my mental model a "tag" is just metadata on the thing - it's a lower or secondary level of importance. Whereas with a folder structure, you're making a primary decision about where something belongs and what it means. I think it's good that we use our server implementation of tags for this, as it's existing and allows us to assign metrics to multiple "collections." But the folder mental model is better for this IMO.
I think it could be as simple as renaming "tag" to "collection", giving the names more space (tags feel like they should just be a single word, but I assume a collection will be multiple words). Like if you were designing this from scratch, how would you do it? Probably more of the folder structure like google drive. And then we say "what existing tech do we have to make this work?" These are all just my opinions, and getting something out soon is better than fussing about the ideal solution forever 😄 So feel free to move forward with what you think is best here! |
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
487e8c9
to
889f548
Compare
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
I'm quite happy with how this works, with the caveat that we should call it Collections, as Raquel suggested. Another thing to consider is that tagging is a Teams/Enterprise feature, which means it will trigger a paywall if you don’t have access to it. That seems fine to me, as I’d expect larger customers to need this - just wanted to surface it here. |
Tell me more? How is this "Collections" concept different than tags?
Yep, this is consistent with dashboards, feature flags, actions, insights, event definitions, and property definitions. |
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.
Tell me more? How is this "Collections" concept different than tags?
I was thinking of renaming it in the UI to make it clearer that this is for grouping metrics into collections. But I realize that would make it inconsistent with the rest of the app, where tags are used.
Good to go as is 👍
@@ -0,0 +1,92 @@ | |||
# Generated by Django 4.2.18 on 2025-01-30 17:45 |
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.
From https://posthog.slack.com/archives/C07PXH2GTGV/p1738179059221599
Changes
One or more tags can be added to a shared metric:
The tags are listed in the shared metrics table:
When your shared metrics have some tags, you can click on the tag to quickly select all matching metrics:
How did you test this code?
Manual review.