Skip to content

Analytics: track export_dialog_opened and export_dialog_dismissed#1773

Open
LeonardoRosaa wants to merge 2 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-data-curation-and-export-export-dialog-lifecycle
Open

Analytics: track export_dialog_opened and export_dialog_dismissed#1773
LeonardoRosaa wants to merge 2 commits into
mainfrom
leonardo-lig-10227-analytics-track-workflows-data-curation-and-export-export-dialog-lifecycle

Conversation

@LeonardoRosaa

@LeonardoRosaa LeonardoRosaa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What has changed and why?

Instruments the export-dialog lifecycle events in useExportDialog.

Events added:

  • export_dialog_opened - fires on open; captures collection_id and
    filtered_sample_count from global storage.
  • export_dialog_dismissed -fires on close; captures collection_id and the format selected at dismiss time.

How has it been tested?

Unit tests.

Did you update CHANGELOG.md?

  • Yes
  • Not needed (internal change)

Summary by CodeRabbit

  • New Features
    • The export dialog now opens with the selected collection’s context.
    • Export events are enriched with the selected collection and chosen export format.
    • Export dismissals are tracked separately from successful download actions.
  • Bug Fixes
    • Prevents redundant open/close actions when the dialog is already in the requested state.
    • Correctly resets “download clicked” state between export attempts so dismissals are tracked accurately.
  • Tests
    • Added automated coverage for export dialog open/close behavior and analytics tracking.

@LeonardoRosaa
LeonardoRosaa requested a review from a team as a code owner July 24, 2026 14:31
@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: ce20ff56-0c02-4ca0-a2a6-0d9245cc3a2f

📥 Commits

Reviewing files that changed from the base of the PR and between 4b62b92 and e46b6ed.

📒 Files selected for processing (1)
  • lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.test.ts

📝 Walkthrough

Walkthrough

The export dialog hook now accepts collection and format context, tracks open and dismissal analytics, suppresses dismissal events after downloads, and resets session state on reopening. Header and dialog integrations pass the required context, with the hook exported centrally and covered by tests.

Changes

Export dialog analytics

Layer / File(s) Summary
Parameterized dialog controller
lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.ts, lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.test.ts
The hook tracks dialog state, download activity, filtered sample counts, and contextual open or dismissal events. Tests cover idempotency and session reset behavior.
Contextual UI integration
lightly_studio_view/src/lib/hooks/index.ts, lightly_studio_view/src/lib/components/Header/Menu.svelte, lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte
The hook is exported centrally, while header and dialog handlers pass collection identifiers and export format values.

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

Sequence Diagram(s)

sequenceDiagram
  participant HeaderMenu
  participant ExportSamples
  participant useExportDialog
  participant PostHog
  HeaderMenu->>useExportDialog: openExportDialog({ collectionId })
  ExportSamples->>useExportDialog: openExportDialog({ collectionId })
  useExportDialog->>PostHog: track export_dialog_opened
  ExportSamples->>useExportDialog: closeExportDialog({ collectionId, exportFormat })
  useExportDialog->>PostHog: track export_dialog_dismissed when no download occurred
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 analytics for export dialog open and dismiss events.
Description check ✅ Passed The description matches the template with change summary, testing, and changelog status filled in.
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-lifecycle

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 167 line(s) (limit: 215).
frontend/coverage [FAIL] lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte: no test file found [FAIL] lightly_studio_view/src/lib/components/Header/Menu.svelte: no test file found [FAIL] lightly_studio_view/src/lib/hooks/index.ts: no test file found [FAIL] lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.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 e46b6ed.

@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: 4b62b921b1

ℹ️ 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".

@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

🤖 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/ExportSamples.svelte`:
- Around line 190-193: Update the export/download flow in the ExportSamples
component to retrieve and invoke markDownloadClicked for every export action
before closeExportDialog runs. Ensure the onOpenChange close path marks the
download before closing so completed exports do not emit
export_dialog_dismissed, while preserving the existing open behavior.

In `@lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.test.ts`:
- Around line 11-13: Update the useGlobalStorage mock in the export dialog tests
to provide a non-zero filteredSampleCount, then replace the permissive analytics
assertion with an exact expectation for that value. Apply the same change to the
additional assertion range so the forwarded analytics payload is verified
consistently.
🪄 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: 91606fc1-269b-4230-af4f-aefab80f6785

📥 Commits

Reviewing files that changed from the base of the PR and between 84fb15a and 4b62b92.

📒 Files selected for processing (5)
  • lightly_studio_view/src/lib/components/ExportSamples/ExportSamples.svelte
  • lightly_studio_view/src/lib/components/Header/Menu.svelte
  • lightly_studio_view/src/lib/hooks/index.ts
  • lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.test.ts
  • lightly_studio_view/src/lib/hooks/useExportDialog/useExportDialog.ts

@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

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