Skip to content

Analytics: track export format selection, annotation downloads, and export triggered - #1774

Merged
LeonardoRosaa merged 5 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-data-curation-and-export-export-dialog-interactions
Jul 28, 2026
Merged

Analytics: track export format selection, annotation downloads, and export triggered#1774
LeonardoRosaa merged 5 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-data-curation-and-export-export-dialog-interactions

Conversation

@LeonardoRosaa

@LeonardoRosaa LeonardoRosaa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

Instruments all export-dialog events via a new useExportTracking hook.

Events added:

  • export_dialog_default_format_set - fires in the $effect that resets exportType when the dialog opens; captures the auto-selected format.
  • export_format_select_opened - fires when the format dropdown opens; captures the current format so intent vs. commit can be measured.
  • export_format_selected - fires in onValueChange; captures the chosen format.
  • export_download_clicked - fires for all six annotation (href) download buttons; also calls markDownloadClicked to suppress export_dialog_dismissed.
  • export_download_clicked + export_triggered - fire around the async handleExport call for samples export; success is snapshotted before the await so they are stable regardless of state changes during the request.

How has it been tested?

Unit tests + manual tests

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Summary by CodeRabbit

Summary by CodeRabbit

  • Improvements

    • Enhanced export dialog analytics across supported formats, including default format initialization and export format selection.
    • Added tracking for export download clicks and export completion, including export type, tag name (when applicable), sample count, and success status.
  • Tests

    • Added a new test suite to validate emitted analytics events and payload shapes for the export tracking behavior.

@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: 5ae41c3c-7c30-412a-8e5e-4159309ca62f

📥 Commits

Reviewing files that changed from the base of the PR and between 24f6cdd and be79fe9.

📒 Files selected for processing (3)
  • lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte
  • lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts
  • lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte

📝 Walkthrough

Walkthrough

The export dialog now uses a useExportTracking hook to emit PostHog events for initialization, format selection, downloads, and export outcomes. The hook reads sample counts, marks downloads, and is covered by Vitest tests.

Changes

Export tracking

Layer / File(s) Summary
Tracking hook contract and implementation
lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.ts
Defines callbacks for export lifecycle, format selection, download, and success/error events with collection-scoped payloads.
Export dialog tracking integration
lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte
Wires tracking into dialog opening, tag selection, format changes, export execution, and annotation download buttons.
Tracking behavior tests
lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts
Tests event names and payloads for format, download, and export-triggered analytics.

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

Sequence Diagram(s)

sequenceDiagram
  participant ExportSamples
  participant useExportTracking
  participant ExportDialog
  participant PostHog
  ExportSamples->>useExportTracking: invoke tracking callback
  useExportTracking->>ExportDialog: mark download clicked
  useExportTracking->>PostHog: emit export event and properties
Loading

Possibly related PRs

Suggested reviewers: igorsusmelj

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the export analytics changes.
Description check ✅ Passed The description follows the template and includes the change summary, testing notes, 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-data-curation-and-export-export-dialog-interactions

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.

…-data-curation-and-export-export-dialog-interactions
@LeonardoRosaa
LeonardoRosaa marked this pull request as ready for review July 27, 2026 19:54
@LeonardoRosaa
LeonardoRosaa requested a review from a team as a code owner July 27, 2026 19:54
@lightly-fast-track-bot

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

Copy link
Copy Markdown

❌  Fast Track: checks did not pass

Guardrail Result Message
dummy Always passes.
frontend/complexity 3 file(s) checked, no violations.
backend/complexity 0 file(s) checked.
backend/coverage 0 file(s) checked.
diff-size PR adds 287 line(s), which exceeds the limit of 215.
frontend/coverage [FAIL] lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte: no test file found [FAIL] lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.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 be79fe9.

@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: 3340471b8e

ℹ️ 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/components/ExportSamples/ExportSamples.svelte Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts (1)

121-139: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the Error object normalization path.

The failure test only passes a string. Add a case using new Error('network timeout') and assert that error_message contains the error’s message.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts`
around lines 121 - 139, Extend the failure coverage for useExportTracking’s
trackExportTriggered to pass new Error('network timeout') instead of only a
string, and assert the emitted export_triggered payload normalizes error_message
to the Error message. Preserve the existing collection, format, sample count,
tag, and success assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts`:
- Around line 3-12: Update the mock setup in the useExportTracking test so
mockTrackEvent and mockMarkDownloadClicked are created through vi.hoisted rather
than top-level const bindings, then reference the hoisted values inside the
vi.mock factory and rerun the workspace checks.

In
`@lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.ts`:
- Around line 84-98: Update trackExportTriggered so error_message never contains
the raw error value sent to PostHog. Map export failures to an allowlisted error
category or code before populating the telemetry payload, while preserving
success reporting and null when no error exists.

---

Nitpick comments:
In
`@lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts`:
- Around line 121-139: Extend the failure coverage for useExportTracking’s
trackExportTriggered to pass new Error('network timeout') instead of only a
string, and assert the emitted export_triggered payload normalizes error_message
to the Error message. Preserve the existing collection, format, sample count,
tag, and success assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6538ef2e-838b-4b91-8703-0b27958acaf4

📥 Commits

Reviewing files that changed from the base of the PR and between eef6554 and 24f6cdd.

📒 Files selected for processing (3)
  • lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte
  • lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.test.ts
  • lightly_studio_view/src/lib/components/ExportSamples/useExportTracking/useExportTracking.ts

@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 28, 2026
Merged via the queue into main with commit e2398a1 Jul 28, 2026
22 checks passed
@LeonardoRosaa
LeonardoRosaa deleted the leonardo-lig-10227-analytics-track-workflows-data-curation-and-export-export-dialog-interactions branch July 28, 2026 15:54
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