Skip to content

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

Open
LeonardoRosaa wants to merge 2 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled-tags
Open

Analytics: track tag filter toggle with grid_filter_toggled PostHog event#1769
LeonardoRosaa wants to merge 2 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 analytics tracking for tag filter selection and deselection, including the tag value and resulting active filter count.
    • Added a fallback analytics value when the selected tag isn’t present in the loaded tag list.
    • Introduced the usePostHog hook entry point for sharing PostHog tracking in tags behavior.
  • Bug Fixes
    • Improved tag selection toggling to reliably update the current selection state.
  • Tests
    • Added/updated coverage to verify selection updates 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: 0234dc6e-def6-4bc1-bdaf-c59cb2a1cb1f

📥 Commits

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

📒 Files selected for processing (3)
  • lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.test.ts
  • lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.ts
  • lightly_studio_view/src/lib/hooks/useTags/useTags.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • lightly_studio_view/src/lib/hooks/useTags/useTags.test.ts
  • lightly_studio_view/src/lib/hooks/useTags/toggleTagSelection.test.ts

📝 Walkthrough

Walkthrough

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: adding PostHog analytics for tag filter toggles.
Description check ✅ Passed The description covers what changed, why, testing, and changelog status, matching the template well enough.
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 5 file(s) checked, no violations.
backend/complexity 0 file(s) checked.
backend/coverage 0 file(s) checked.
diff-size PR adds 242 line(s), which exceeds the limit of 215.
frontend/coverage [FAIL] lightly_studio_view/src/lib/hooks/index.ts: no test file found [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 c8003c7.

@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
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