feat(inbox): show report tags on cards and filter the list by tag, behind a flag

Open
#135,276 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python, react, typescript
Domain
full-stack

Research direction

Start with the backend filter: read _apply_signal_report_source_product_filter in products/signals/backend/views.py and the report list viewset actions that call it, then mirror that shape for tags using normalize_report_tags and MAX_TAGS. On the frontend, read products/signals/frontend/inbox/logics/inboxFiltersLogic.ts and follow the Source filter pattern end to end (reportListLogic.ts, InboxReportFilters.tsx, ReportCard.tsx) plus the flag entry in frontend/src/lib/constants.tsx. Done means the flag-gated chips and Tags menu work, the backend tests for the tags filter pass, the OpenAPI schema and MCP tool are regenerated, and the new stories render. Expect to check the query plan for a rare tag and add a concurrent GIN index on SignalReport.tags if it is slow.

Written by the indexing model from the issue text.

Description

self-driving

Problem

Inbox reports carry tags: free-form lowercase kebab-case slugs such as tracking-gap or silent-failure, at most 10 per report. Scouts and the report pipeline write them, and the report API already returns them in tags.

The inbox does not use them. A user cannot see a report's tags on its card, and cannot narrow the report list to one kind of report, for example every docs-gap report.

We want users to see tags on report cards and filter the report list by tag. The change ships behind a new feature flag so it can be tried on a few accounts first.

Mockup (PostHog staff only): https://us.posthog.com/code/canvas/b3c84ed2-6999-4b81-beff-30350198f9ad/01a1d417-8c7a-74ae-8fcf-76704fefd2bc. This issue builds display option A and filter option 2 from the mockup.

Replaces #120483. The earlier attempt, #120549, was closed without merging and had no feature flag. Reuse what still applies from it.

Scope

  • Redesigned inbox layout only (ReportsTab, InboxReportFilters, ReportCard).
  • One new frontend feature flag, inbox-tag-filter, gates both the tags on cards and the filter. With the flag off the inbox looks and behaves as it does today.
  • The backend tags list parameter is not flag-gated. It is a plain filter on data the API already returns.
  • No change to how tags are written, normalized, or merged (products/signals/backend/report_tags.py).
  • Out of scope: a "match all tags" mode, a top-tags bar above the list, per-tag report counts, editing tags from the inbox, and the report detail view.

Changes

1. Backend: tags filter on the report list

In products/signals/backend/views.py:

  • Add a tags query parameter to the report list, next to source_product and scout: a comma-separated list of tag slugs. A report is kept when it has at least one of the tags (array overlap). It combines with every other filter as AND.
  • Add _apply_signal_report_tags_filter beside _apply_signal_report_source_product_filter and call it in the same places, so list counts and sections respect it the same way.
  • Normalize the incoming values with normalize_report_tags so Docs Gap and docs-gap match the same reports. Ignore empty values. Cap the number of tags a request may pass at MAX_TAGS.
  • Write the OpenApiParameter description, then run hogli build:openapi.
  • Expose the same tags filter on the inbox-reports-list MCP tool, following /implementing-mcp-tools.

Query cost: team_tag_vocabulary already notes that a SQL filter on tags can walk a team's whole history when few reports match. Check the plan for a rare tag on a large team with /profiling-slow-api-endpoints. If it needs one, add a GIN index on SignalReport.tags, created concurrently, following /django-migrations.

2. Backend: tag options for the filter

Add a read-only list-level action on the report viewset that returns the team's most-used tags, most-used first, from team_tag_vocabulary(team.id). Response: { "tags": string[] }. Give it a response serializer so the generated types are exact.

3. Frontend: flag and filter state
  • Add INBOX_TAG_FILTER: 'inbox-tag-filter' to FEATURE_FLAGS in frontend/src/lib/constants.tsx, with the same owner comment style as INBOX_SOURCE_FILTER.
  • In products/signals/frontend/inbox/logics/inboxFiltersLogic.ts, follow the Source filter pattern:
    • tagFilter: string[] with toggleTag(tag) and clearTagFilter().
    • tagFilterAvailable reads the flag. activeTagFilter returns [] while the flag is off, so a stored or shared selection cannot narrow a list that has no control for it.
    • Sync to the URL as tags=a,b, parsed like the scout param.
    • Capture the change through captureQueryChange('tags'). Add 'tags' to InboxQueryChange in inboxAnalytics.ts.
  • In reportListLogic.ts, send tags: activeTagFilter.join(',') with the list request when it is not empty, and reload when it changes.
  • Load the tag options from the new action only when the flag is on.
4. Frontend: Tags filter control

Add InboxTagFilter.tsx in components/shell/ and render it in InboxReportFilters.tsx after the Source filter, only when tagFilterAvailable.

  • Trigger: a button labelled "Tags", or "Tags · {n}" when n tags are selected.
  • Menu: a search field, then a checkbox row per tag from the options, most-used first. Search narrows the rows. Selected tags that are not in the options still show as checked rows, so a tag picked from a card can always be cleared.
  • Empty state when the team has no tags: "No tags yet".
  • Clearing all inbox filters also clears the tag filter.
5. Frontend: tags on the report card

In components/cards/ReportCard.tsx, when tagFilterAvailable and the report has tags:

  • Show the tags as small neutral chips in a row under the title line. Show at most 3, then a +{n} chip that reveals the rest on hover.
  • Tags in the active filter render in the highlighted style and sort to the front, so the matching tag is never hidden in the overflow.
  • Selecting a chip toggles that tag in the filter. It must not open the report or select the card. Chips are real buttons: focusable, with aria-pressed.
  • A report with no tags shows no row, so cards without tags keep their current height.
6. Tests
  • Backend: the tags filter keeps reports with any of the given tags, combines with status as AND, normalizes input, and ignores an empty value.
  • Frontend logic: activeTagFilter is empty with the flag off, and the tags URL param round-trips.
  • Add a story for a card with more than 3 tags and one for the open Tags menu.

Rollout

Create the inbox-tag-filter flag at 0% and target individual users first. Rollback is turning the flag off.

Dominant language
Python
Stars
40.8k
Forks
3.6k
Avg merge
6h 43m
Merged PRs (30d)
254

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PostHog/posthog

All issues in PostHog/posthog

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.