Skip to content

Analytics: track annotation source and label filter toggles with grid_filter_toggled#1766

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

Analytics: track annotation source and label filter toggles with grid_filter_toggled#1766
LeonardoRosaa wants to merge 2 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled

Conversation

@LeonardoRosaa

@LeonardoRosaa LeonardoRosaa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

Fires a grid_filter_toggled PostHog event when the user selects or deselects an annotation source or annotation label 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 annotation source and label filter selection toggles, including selected value, action, active count, and collection context.
    • Centralized annotation source selection-change handling to ensure tracking is consistently applied.
    • Updated label filter toggle wiring to supply the current collection ID.
  • Bug Fixes

    • Avoids firing tracking when a toggled ID/label can’t be resolved to a known item, preventing incomplete analytics events.
  • Tests

    • Expanded unit and interaction tests to validate analytics event payloads and edge cases.

@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: 898a55ed-3a35-49d5-8cc6-7aff0eca110e

📥 Commits

Reviewing files that changed from the base of the PR and between 33cc3b3 and fb704b3.

📒 Files selected for processing (4)
  • lightly_studio_view/src/lib/components/AnnotationCollectionsMenu/AnnotationCollectionsMenu.test.ts
  • lightly_studio_view/src/lib/hooks/useAnnotationsFilter/useAnnotationsFilter.test.ts
  • lightly_studio_view/src/lib/hooks/useAnnotationsFilter/useAnnotationsFilter.ts
  • lightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/+layout.svelte
🚧 Files skipped from review as they are similar to previous changes (3)
  • lightly_studio_view/src/lib/components/AnnotationCollectionsMenu/AnnotationCollectionsMenu.test.ts
  • lightly_studio_view/src/lib/hooks/useAnnotationsFilter/useAnnotationsFilter.ts
  • lightly_studio_view/src/lib/hooks/useAnnotationsFilter/useAnnotationsFilter.test.ts

📝 Walkthrough

Walkthrough

Annotation label and annotation source filter toggles now emit grid_filter_toggled PostHog events with collection context, filter values, actions, and active counts. Selection persistence remains covered by dedicated handler and component tests.

Changes

Grid filter analytics

Layer / File(s) Summary
Annotation label tracking
lightly_studio_view/src/lib/hooks/useAnnotationsFilter/*, lightly_studio_view/src/routes/datasets/.../+layout.svelte
Label selection toggles now update selection state and emit grid_filter_toggled events with action, filter value, collection ID, and active count.
Annotation source tracking
lightly_studio_view/src/lib/components/AnnotationCollectionsMenu/*
Annotation source selection changes now use a shared handler that persists IDs and emits tracking events when the source name is resolved, with component and handler coverage.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FilterControls
  participant SelectionHandler
  participant PostHog
  User->>FilterControls: Toggle annotation label or source
  FilterControls->>SelectionHandler: Provide new selection IDs
  SelectionHandler->>SelectionHandler: Persist selection and compute action
  SelectionHandler->>PostHog: Track grid_filter_toggled event
Loading

Possibly related PRs

Suggested reviewers: ikondrat

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding grid filter toggle analytics for annotation sources and labels.
Description check ✅ Passed The description includes the required sections and states the change, testing, and changelog status.
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

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.

@LeonardoRosaa
LeonardoRosaa force-pushed the leonardo-lig-10227-analytics-track-workflows-filter-grid-view-toggled branch from 5f51731 to 33cc3b3 Compare July 24, 2026 12:49
@LeonardoRosaa LeonardoRosaa changed the title Track grid_filter_toggled for annotation label, tag, and annotation source filters Track annotation source and label filter toggles with grid_filter_toggled Jul 24, 2026
@LeonardoRosaa
LeonardoRosaa marked this pull request as ready for review July 24, 2026 12:51
@LeonardoRosaa
LeonardoRosaa requested a review from a team as a code owner July 24, 2026 12:51
@LeonardoRosaa LeonardoRosaa changed the title Track annotation source and label filter toggles with grid_filter_toggled Analytics: track annotation source and label filter toggles with grid_filter_toggled Jul 24, 2026
@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 lightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/+layout.svelte:147 — Function 'handleSelectAllKeydown' has a complexity of 11. Maximum allowed is 10. lightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/+layout.svelte:371 — Arrow function has a complexity of 11. Maximum allowed is 10.
backend/complexity 0 file(s) checked.
backend/coverage 0 file(s) checked.
diff-size PR adds 296 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/components/AnnotationCollectionsMenu/AnnotationCollectionsMenu.svelte: coverage data not found [FAIL] lightly_studio_view/src/lib/components/AnnotationCollectionsMenu/handleAnnotationSourceFilterChange.ts: coverage data not found [FAIL] lightly_studio_view/src/lib/hooks/useAnnotationsFilter/useAnnotationsFilter.ts: coverage data not found [FAIL] lightly_studio_view/src/routes/datasets/[dataset_id]/[collection_type]/[collection_id]/+layout.svelte: 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 fb704b3.

@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: 33cc3b3d10

ℹ️ 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/useAnnotationsFilter/useAnnotationsFilter.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
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 24, 2026
@LeonardoRosaa
LeonardoRosaa added this pull request to the merge queue Jul 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks 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