Skip to content

feat(metrics): Enable AI searchbar on metrics explorer filter#111546

Open
isaacwang-sentry wants to merge 1 commit intomasterfrom
isaac/feat/metrics-ai-searchbar
Open

feat(metrics): Enable AI searchbar on metrics explorer filter#111546
isaacwang-sentry wants to merge 1 commit intomasterfrom
isaac/feat/metrics-ai-searchbar

Conversation

@isaacwang-sentry
Copy link
Copy Markdown
Member

Summary

  • Add MetricsTabSeerComboBox component for AI-powered natural language query translation on the metrics filter bar
  • Enable enableAISearch in the metrics SearchQueryBuilderProvider, gated behind gen-ai-features and gen-ai-search-agent-translate feature flags
  • Follows the same pattern as Logs (LogsTabSeerComboBox) and Traces (SpansTabSeerComboBox)

How it works

  • The AI search is per-metric-query (each metric panel has its own filter bar)
  • When the user types a natural language query, it sends strategy: 'Metrics' to Seer
  • Seer translates the query and returns a filter string
  • The filter is applied to the current metric panel via useSetQueryParamsQuery()

Dependencies

Test plan

  • Verify AI search icon appears on metrics filter bar when feature flags are enabled
  • Verify natural language queries are translated and applied to the filter
  • Verify feature flag gating works (no AI search without flags)
  • Verify it works per-metric-panel (each filter bar is independent)

🤖 Generated with Claude Code

Add MetricsTabSeerComboBox component for AI-powered natural language
query translation on the metrics page. Enable the AI search feature
in the existing SearchQueryBuilderProvider in the metrics filter
toolbar, gated behind gen-ai-features and gen-ai-search-agent-translate
feature flags.

The AI search applies the translated query to the per-metric filter
bar, matching the pattern used by Logs and Traces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@isaacwang-sentry isaacwang-sentry requested a review from a team as a code owner March 25, 2026 19:04
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 25, 2026
return (
<AskSeerPollingComboBox<AskSeerSearchQuery>
initialQuery={initialSeerQuery}
onApplySearchQuery={applySeerSearchQuery}
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.

Bug: Incorrect prop names are passed to AskSeerComboBox and AskSeerPollingComboBox, such as onApplySearchQuery instead of applySeerSearchQuery, which will break the AI search feature.
Severity: CRITICAL

Suggested Fix

In MetricsTabSeerComboBox, rename the props passed to AskSeerComboBox and AskSeerPollingComboBox to match their required interface. Specifically, change onApplySearchQuery to applySeerSearchQuery and mutationOptions to askSeerMutationOptions. Also, add the required analyticsSource and feedbackSource props to both components, referencing other implementations for appropriate values.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/explore/metrics/metricsTabSeerComboBox.tsx#L176

Potential issue: The `MetricsTabSeerComboBox` component passes incorrect props to its
child components. `AskSeerPollingComboBox` receives `onApplySearchQuery` instead of the
required `applySeerSearchQuery`. `AskSeerComboBox` receives `onApplySearchQuery` instead
of `applySeerSearchQuery` and `mutationOptions` instead of `askSeerMutationOptions`.
This will cause a runtime `TypeError` when a user selects an AI search suggestion
because the expected callback function `props.applySeerSearchQuery` will be undefined.
This breaks the AI search functionality. Additionally, both child components are missing
the required `analyticsSource` and `feedbackSource` props.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

initialQuery={initialSeerQuery}
onApplySearchQuery={applySeerSearchQuery}
mutationOptions={metricsTabAskSeerMutationOptions}
/>
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.

Wrong prop names passed to ComboBox components

High Severity

The AskSeerComboBox component expects props named applySeerSearchQuery and askSeerMutationOptions, but this code passes onApplySearchQuery and mutationOptions instead. Similarly, AskSeerPollingComboBox expects applySeerSearchQuery but receives onApplySearchQuery. At runtime, the components will destructure undefined for the expected prop names, causing a TypeError when a user selects a query result (props.applySeerSearchQuery(item) is called on undefined). The Logs and Spans implementations correctly use applySeerSearchQuery and askSeerMutationOptions.

Additional Locations (1)
Fix in Cursor Fix in Web

onApplySearchQuery={applySeerSearchQuery}
mutationOptions={metricsTabAskSeerMutationOptions}
/>
);
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.

Missing required analyticsSource and feedbackSource props

Medium Severity

Both AskSeerPollingComboBox and AskSeerComboBox require analyticsSource and feedbackSource string props (used for analytics tracking and feedback form attribution), but the metrics implementation doesn't provide either. The Logs variant passes analyticsSource="logs" and feedbackSource="logs_ai_query", and Spans passes analyticsSource="trace.explorer" and feedbackSource="trace_explorer_ai_query". Without these, analytics events will fire with undefined sources and feedback forms won't have proper attribution.

Fix in Cursor Fix in Web

const {projects} = useProjects();
const pageFilters = usePageFilters();
const organization = useOrganization();
const currentQuery = useQueryParamsQuery();
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.

Unused currentQuery variable from hook call

Low Severity

currentQuery is assigned from useQueryParamsQuery() but never referenced anywhere in the component. This appears to be a leftover from development. The hook call itself may trigger unnecessary subscriptions or re-renders.

Fix in Cursor Fix in Web

@getsantry
Copy link
Copy Markdown
Contributor

getsantry bot commented Apr 16, 2026

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant