Skip to content

Analytics: track tag filter toggle with grid_filter_toggled PostHog event - #1769

Merged
LeonardoRosaa merged 5 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled-tags
Jul 27, 2026
Merged

Analytics: track tag filter toggle with grid_filter_toggled PostHog event#1769
LeonardoRosaa merged 5 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled-tags

Conversation

@LeonardoRosaa

@LeonardoRosaa LeonardoRosaa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

Extracts tag toggle logic into a pure toggleTagSelection function and fires a grid_filter_toggled PostHog event whenever the user selects or deselects a tag in the grid filter panel.

How has it been tested?

Unit tests

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Summary by CodeRabbit

  • New Features
    • Added PostHog analytics for tag filter selection/deselection, including the tag value and the resulting active filter count.
    • Added a fallback when the chosen tag isn’t present in the loaded tag list (uses the tag id as the tracked value).
    • Exposed the shared PostHog hook for use in tag behavior.
  • Bug Fixes
    • Improved tag selection toggling to update the selection consistently.
  • Tests
    • Added/updated tests to verify selection state changes and analytics event payloads, including fallback scenarios.

@LeonardoRosaa
LeonardoRosaa requested a review from a team as a code owner July 24, 2026 12:48
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c925e7cf-cde0-4ec7-886a-76ed09444c6c

📥 Commits

Reviewing files that changed from the base of the PR and between c8003c7 and 16f8465.

📒 Files selected for processing (1)
  • lightly_studio_view/src/lib/hooks/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • lightly_studio_view/src/lib/hooks/index.ts

📝 Walkthrough

Walkthrough

Tag selection now uses a shared toggle helper that updates selected tag IDs and emits grid_filter_toggled analytics events. useTags integrates the helper and PostHog tracking, with tests covering selection, deselection, active counts, and missing-tag fallbacks.

Changes

Tag selection analytics

Layer / File(s) Summary
Tag toggle helper and tests
lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.ts, lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.test.ts
Adds a reusable helper that updates tag selection, resolves tag names with an ID fallback, and emits grid_filter_toggled events with the resulting active count.
useTags analytics integration
lightly_studio_view/src/lib/hooks/index.ts, lightly_studio_view/src/lib/hooks/useTags/useTags.ts, lightly_studio_view/src/lib/hooks/useTags/useTags.test.ts
Exports usePostHog, wires tracking into useTags, delegates toggling to the helper, simplifies tag filtering, and tests selected, unselected, and fallback analytics payloads.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant useTags
  participant toggleTagSelection
  participant updateSelected
  participant trackEvent
  useTags->>toggleTagSelection: toggle tag selection
  toggleTagSelection->>updateSelected: persist updated Set
  toggleTagSelection->>trackEvent: emit grid_filter_toggled
Loading

Possibly related PRs

Suggested reviewers: ikondrat

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: tracking tag filter toggles with a PostHog event.
Description check ✅ Passed The description follows the template with change summary, testing note, and changelog status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled-tags

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lightly-fast-track-bot

lightly-fast-track-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

❌  Fast Track: checks did not pass

Guardrail Result Message
dummy Always passes.
frontend/complexity 4 file(s) checked, no violations.
backend/complexity 0 file(s) checked.
backend/coverage 0 file(s) checked.
diff-size PR adds 241 line(s), which exceeds the limit of 215.
frontend/coverage [FAIL] lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.ts: coverage data not found [FAIL] lightly_studio_view/src/lib/hooks/useTags/useTags.ts: coverage data not found

View the guardrail run

To run the guardrails locally, from fast_track/ run make install once, then make run-guardrails (or GUARDRAILS=<name1>,<name2> make run-guardrails for some guardrails).

Reflects 01b1e1a.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea7e986dab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.ts Outdated
Comment thread lightly_studio_view/src/lib/hooks/useTags/useTags.test.ts Outdated
Comment thread lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.test.ts Outdated
@LeonardoRosaa

Copy link
Copy Markdown
Contributor Author

/review

@IgorSusmelj IgorSusmelj left a comment

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.

LGTM

@LeonardoRosaa
LeonardoRosaa added this pull request to the merge queue Jul 24, 2026
@LeonardoRosaa
LeonardoRosaa removed this pull request from the merge queue due to a manual request Jul 24, 2026
@LeonardoRosaa
LeonardoRosaa enabled auto-merge July 27, 2026 19:04
@LeonardoRosaa
LeonardoRosaa added this pull request to the merge queue Jul 27, 2026
Merged via the queue into main with commit eef6554 Jul 27, 2026
21 checks passed
@LeonardoRosaa
LeonardoRosaa deleted the leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled-tags branch July 27, 2026 19:27
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.

2 participants