Track workflow search context#972
Conversation
📝 WalkthroughWalkthroughSearch badge changes now recompute a normalized ChangesSearch tracking update
Sequence Diagram(s)sequenceDiagram
participant SearchPopover
participant trackSearchPerformed
participant posthog as posthog-js
SearchPopover->>trackSearchPerformed: query, resultCount, filtersApplied
trackSearchPerformed->>posthog: capture hub:search_performed
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
🧹 Lint & Format Results
Generated by Site CI workflow |
🔍 SEO Audit Results
📊 SEO Audit DetailsCould not parse SEO output 🔗 Link Check Detailsbroken internal links out of checked Generated by Site CI workflow |
adf6ec1 to
45abb64
Compare
45abb64 to
919dcf3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@site/src/components/hub/SearchPopover.vue`:
- Around line 201-212: The search completion handling in SearchPopover is
vulnerable to stale async results overriding newer queries. Add a per-request
token/snapshot around the search flow in the search handler that calls
searchIndex, and before assigning searchResults or calling trackSearchPerformed,
verify the response still matches the latest request. Use the existing search
state in SearchPopover to ignore older completions so only the newest
query/filter combination updates results and result_count.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 91935dd2-cdda-4088-83ff-b3e261c62fe0
📒 Files selected for processing (3)
site/src/components/hub/SearchPopover.vuesite/src/lib/posthog.tssite/tests/unit/posthog.test.ts
| const filtersApplied = [...activeFilters.value]; | ||
| try { | ||
| searchResults.value = await searchIndex(trimmed, { | ||
| const results = await searchIndex(trimmed, { | ||
| allowedNames: badgeFilteredNames.value ?? undefined, | ||
| }); | ||
| trackSearchPerformed(trimmed); | ||
| searchResults.value = results; | ||
| const resultCount = results.workflows.length + matchedCreators.value.length; | ||
| trackSearchPerformed({ | ||
| query: trimmed, | ||
| resultCount, | ||
| filtersApplied, | ||
| }); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Guard against stale search completions.
Line 207 reads matchedCreators.value.length after await searchIndex(...), and this block also writes searchResults.value after the await. If an older debounced search resolves after a newer one, the popover can show stale workflows and the emitted result_count can belong to the wrong query/filter set — old results win the race and muddy the trace. Capture a request token/snapshot and ignore stale completions before assigning or tracking.
🤖 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 `@site/src/components/hub/SearchPopover.vue` around lines 201 - 212, The search
completion handling in SearchPopover is vulnerable to stale async results
overriding newer queries. Add a per-request token/snapshot around the search
flow in the search handler that calls searchIndex, and before assigning
searchResults or calling trackSearchPerformed, verify the response still matches
the latest request. Use the existing search state in SearchPopover to ignore
older completions so only the newest query/filter combination updates results
and result_count.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60144103ae
ℹ️ 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".
| }); | ||
| trackSearchPerformed(trimmed); | ||
| searchResults.value = results; | ||
| const resultCount = results.workflows.length + matchedCreators.value.length; |
There was a problem hiding this comment.
Count creators from the searched query
When the first search is still loading /workflows/search-index.json (or any search resolves slowly) and the user edits or clears the query before it resolves, matchedCreators.value has already recomputed from the current searchQuery, not the trimmed query being reported. That sends hub:search_performed with workflow results for one query plus a creator count for another, so the new result_count telemetry is inaccurate for common fast-typing/clear-search flows; capture the creator count for trimmed before the await or derive it from the same search results.
Useful? React with 👍 / 👎.
Summary:
Tests:
Notes:
Fixes GTM-139