Skip to content

feat(surveys): Add group property filtering to survey responses#34946

Merged
lucasheriques merged 7 commits intoPostHog:masterfrom
nehaaprasad:feat/filtering-survey-answers
Jul 16, 2025
Merged

feat(surveys): Add group property filtering to survey responses#34946
lucasheriques merged 7 commits intoPostHog:masterfrom
nehaaprasad:feat/filtering-survey-answers

Conversation

@nehaaprasad
Copy link
Copy Markdown
Contributor

@nehaaprasad nehaaprasad commented Jul 13, 2025

Hi, I just made a Pull Request!

Problem:

Allow filtering survey answers with group properties, similar to how it works in feature flags and insights. This enhances survey analysis by letting users segment responses based on organizational/company attributes.

#34937

changes

  • Added group property filtering support to survey response filters
  • Extended PropertyFilters component to include group taxonomic types
  • Integrated with existing survey filter infrastructure
  • Added comprehensive tests for group property filtering

Before:

  • Survey responses could only be filtered by person properties and event properties

After:

  • Survey responses can now be filtered by group properties (e.g. company_name, industry)
  • Uses the same familiar UI as feature flags and insights
  • Fully integrated with existing filter system

How did you test this code?

  • Added unit tests in surveyLogic.test.ts covering:

  • Single group property filters

  • Multiple group property filters

  • Mixed person and group property filters

  • Preserving existing survey ID filters

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds group property filtering capabilities to survey responses, allowing users to filter survey answers based on organizational attributes like company name and industry. The implementation extends the existing PropertyFilters component to support group taxonomic types and integrates seamlessly with the current survey filter infrastructure. The changes follow established patterns from feature flags and insights, ensuring a consistent user experience.

The key technical changes include:

  1. Integration of groupsModel to access groupsTaxonomicTypes
  2. Extension of PropertyFilters to include group-related filter types
  3. Addition of test coverage for various group property filtering scenarios

Confidence score: 4 /5

  1. This PR is safe to merge as it's an additive feature with comprehensive test coverage
  2. The score is 4 because while the implementation is solid and well-tested, any filtering changes require careful monitoring in production to ensure query performance
  3. Files needing attention:
    • surveyLogic.test.ts: Verify test coverage for edge cases
    • SurveyResponseFilters.tsx: Check if all group property types are correctly handled

2 files reviewed, 1 comment
Edit PR Review Bot Settings | Greptile

Comment on lines +218 to +226
taxonomicGroupTypes={[
TaxonomicFilterGroupType.EventProperties,
TaxonomicFilterGroupType.PersonProperties,
TaxonomicFilterGroupType.EventFeatureFlags,
TaxonomicFilterGroupType.Cohorts,
TaxonomicFilterGroupType.Elements,
TaxonomicFilterGroupType.HogQLExpression,
...groupsTaxonomicTypes,
]}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: Consider moving taxonomic group types to a constant to maintain consistency across components

@Twixes Twixes requested a review from a team July 14, 2025 09:05
@marandaneto
Copy link
Copy Markdown
Member

@lucasheriques can you test this, please, since you have more context? thanks

@marandaneto
Copy link
Copy Markdown
Member

Thanks for the PR @naaa760

Copy link
Copy Markdown
Contributor

@lucasheriques lucasheriques left a comment

Choose a reason for hiding this comment

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

hey @naaa760 again appreciate the PR ❤️

code-wise it looks good, however, have one comment about the new filters.

CleanShot 2025-07-16 at 02 10 57@2x

This is now the full list of categories we have in the filters for Surveys.

However, a few of them are not relevant. Survey events are always captured via posthog.capture, and the event is always one of ['survey show', 'survey sent', 'survey dismissed']. So a couple of those do not make sense here like:

  • autocapture elements (those are for $autocapture events)
  • instance properties (since we only care about the answers / event properties)
  • account properties

can you remove them? 🙏

@nehaaprasad
Copy link
Copy Markdown
Contributor Author

@lucasheriques ! fixed! Removed autocapture elements, instance properties, and account properties from survey filters.
Now only shows relevant categories (event/person properties, feature flags, cohorts, HogQL, and group properties) for survey analysis.

Copy link
Copy Markdown
Contributor

@lucasheriques lucasheriques left a comment

Choose a reason for hiding this comment

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

looks great! thanks for the PR. send me an email at lucas at posthog.com so I can also give you some merch as a reward 🙏

@nehaaprasad
Copy link
Copy Markdown
Contributor Author

looks great! thanks for the PR. send me an email at lucas at posthog.com so I can also give you some merch as a reward 🙏

Thank you so much, I sent it! :)

@lucasheriques lucasheriques enabled auto-merge (squash) July 16, 2025 21:16
@lucasheriques
Copy link
Copy Markdown
Contributor

@naaa760 just sent it! no need to re-merge master again. I enabled automerge, so once the CI finishes we'll get this in!

@nehaaprasad
Copy link
Copy Markdown
Contributor Author

@naaa760 just sent it! no need to re-merge master again. I enabled automerge, so once the CI finishes we'll get this in!

Sure!

@lucasheriques lucasheriques merged commit 2318c67 into PostHog:master Jul 16, 2025
154 checks passed
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.

3 participants