-
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(prop-defs): add hidden option to property definitions #29085
base: master
Are you sure you want to change the base?
Conversation
Random review request from you @Twixes because I feel like you've touched all these things in the past, and you were a suggested reviewer 😏 |
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
Based on the provided files, I'll summarize the key changes in this PR:
This PR adds a hidden property status feature to property definitions in PostHog, enabling better property management. Here are the key points:
- Added
hidden
boolean field to EnterprisePropertyDefinition model with default=False, allowing properties to be marked as hidden from property selectors - Introduced new PropertyStatusControl component replacing VerifiedDefinitionCheckbox, offering three states: Verified, Standard (visible), or Hidden
- Added validation ensuring properties cannot be both hidden and verified simultaneously - hiding a verified property unverifies it and vice versa
- Implemented
exclude_hidden
parameter in API endpoints to filter out hidden properties when enterprise taxonomy feature is enabled - Added visual indicators in UI (definition view, popovers) to clearly show property verification status with appropriate icons and tooltips
The changes help organizations better manage their properties by allowing them to hide deprecated or unwanted properties while keeping them accessible in the Data Management area.
13 file(s) reviewed, 12 comment(s)
Edit PR Review Bot Settings | Greptile
migrations.AddField( | ||
model_name="enterprisepropertydefinition", | ||
name="hidden", | ||
field=models.BooleanField(blank=True, default=False, null=True), |
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 making null=False since default=False is provided. Having both nullable and a default value can lead to ambiguous states.
@@ -19,6 +19,7 @@ class EnterprisePropertyDefinition(PropertyDefinition): | |||
blank=True, | |||
related_name="property_verifying_user", | |||
) | |||
hidden = models.BooleanField(blank=True, null=True, default=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: Consider making hidden field non-nullable since it has a default value. This would simplify logic and prevent potential null checks.
hidden = models.BooleanField(blank=True, null=True, default=False) | |
hidden = models.BooleanField(blank=True, default=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.
This is a good suggestion, same as verified
above
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.
We have to allow null I think so that the existing rows don't all have to be updated, if anything I would remove the default. Thoughts?
frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx
Outdated
Show resolved
Hide resolved
frontend/src/scenes/data-management/definition/DefinitionView.tsx
Outdated
Show resolved
Hide resolved
frontend/src/types.ts
Outdated
|
||
export type PropertyDefinitionVerificationStatus = 'verified' | 'hidden' | 'standard' |
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 using an enum instead of a union type for better type safety and IDE support
Size Change: +1.63 kB (+0.02%) Total Size: 9.72 MB
|
@@ -19,6 +19,7 @@ class EnterprisePropertyDefinition(PropertyDefinition): | |||
blank=True, | |||
related_name="property_verifying_user", | |||
) | |||
hidden = models.BooleanField(blank=True, null=True, default=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.
This is a good suggestion, same as verified
above
@@ -19,6 +19,7 @@ class EnterprisePropertyDefinition(PropertyDefinition): | |||
blank=True, | |||
related_name="property_verifying_user", | |||
) |
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.
hidden_at
, hidden_by
(following the verified patter) could be helpful, esp if we don't have audit logs on prop defs (which I'm not sure whether or not we do)
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.
I think I'd rather this go into the activity log tbh... and I don't feel like doing that now 😬 Is that cool with you or do you really think it should be included?
|
||
def update(self, property_definition: EnterprisePropertyDefinition, validated_data: dict): | ||
# If setting hidden=True, ensure verified becomes false | ||
if validated_data.get("hidden", 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.
Why is this logic duplicated here? validate
should be called before update
so if it was all in validate
then should be covered?
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.
I don't know 🙈
@Twixes how are the multiple API endpoints used - there is one for ee and one for non-ee. My ee tests didn't pass without the ee api changes so I just copied them over...
def update(self, property_definition: PropertyDefinition, validated_data: dict): | ||
# If setting hidden=True, ensure verified becomes false | ||
if validated_data.get("hidden", False): | ||
validated_data["verified"] = 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.
I don't fully understand why there are two view sets for updating prop defs, but maybe we should update the logic here to be the same, where you also clear the verified at and verified by.
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.
Very vaguely involved with definitions, but I'm always in favor of great UX, and I think we're pretty close here! However, some things to smooth out before we merge
frontend/src/scenes/data-management/definition/DefinitionView.tsx
Outdated
Show resolved
Hide resolved
frontend/src/scenes/data-management/definition/definitionLogic.ts
Outdated
Show resolved
Hide resolved
exclude_hidden = serializers.BooleanField( | ||
help_text="Whether to exclude properties marked as hidden", | ||
required=False, | ||
default=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.
It seems it should be the inverse, hidden properties should be hidden unless you opt into including them (we only want to include in the property definitions scene)
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.
I kind of disagree - I feel like it's better to include everything by default in the endpoint and use filters to narrow it down, not broaden the scope.
Hidden can make you think it shouldn't be automatically included because of the field name, but in reality the hiding is a UI thing, it's not like it's archived (if it was an archive or delete option I'd agree with you that it should be excluded by default).
Problem
PostHog ingests a lot of properties, and sometimes it can be confusing for posthog users of certain orgs to know which properties they should be using. For example, do they use the "Country" person property, or the "Latest country" person property? They might not even realize that "Latest country" is an option if they just scroll and see "Country" - even if that is the preferred prop that their org wants them to use.
We have a way to mark properties as "Verified" - ie someone at the org says "this is a good one, use it." But we have no way of saying "this is not a good one, don't use it."
Changes
Adds a "hidden" field to the property definition model. Allows someone to select between Verified / Visible / Hidden for any property - except "core" PostHog properties can't be "Verified" (why? because that's how it originally was so I didn't change it 🤷♀️ - they can still be hidden though)
If a property is hidden it still shows up in the Data Management area, but not in the filter property selector thing.
Bunch o screenshots:
apparently the prop dev view page didn't say if it was verified so.... added that:

Neither did the popover, how is someone supposed to know if it's verified / preferred if it doesn't show up?!? 😆

Popover edit (ignore that it says "standard" - i've changed to "visible"):

No screenshots for API changes and validation but it should all be there..
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
N/A - cloud only, teams plan only!
How did you test this code?
Tests, 👀