ref(assisted-query): add new analytics events segmented by area#112029
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Metrics
AnalyticsAreawraps only header, not content- Moved AnalyticsArea from inside MetricsHeader to wrap the entire content in MetricsContent, matching the pattern used in logs and spans views.
Or push these changes by commenting:
@cursor push 04eb6c887b
Preview (04eb6c887b)
diff --git a/static/app/views/explore/metrics/content.tsx b/static/app/views/explore/metrics/content.tsx
--- a/static/app/views/explore/metrics/content.tsx
+++ b/static/app/views/explore/metrics/content.tsx
@@ -50,18 +50,20 @@
: undefined
}
>
- <Stack flex={1}>
- <MetricsHeader />
- {defined(onboardingProject) ? (
- <MetricsTabOnboarding
- organization={organization}
- project={onboardingProject}
- datePageFilterProps={datePageFilterProps}
- />
- ) : (
- <MetricsTabContent datePageFilterProps={datePageFilterProps} />
- )}
- </Stack>
+ <AnalyticsArea name="explore.metrics">
+ <Stack flex={1}>
+ <MetricsHeader />
+ {defined(onboardingProject) ? (
+ <MetricsTabOnboarding
+ organization={organization}
+ project={onboardingProject}
+ datePageFilterProps={datePageFilterProps}
+ />
+ ) : (
+ <MetricsTabContent datePageFilterProps={datePageFilterProps} />
+ )}
+ </Stack>
+ </AnalyticsArea>
</PageFiltersContainer>
</SentryDocumentTitle>
);
@@ -79,34 +81,32 @@
return (
<Layout.Header unified>
- <AnalyticsArea name="explore.metrics">
- <Layout.HeaderContent unified>
- {hasSavedQueryTitle ? (
- <SentryDocumentTitle
- title={`${savedQuery.name} — ${t('Metrics')}`}
- orgSlug={organization?.slug}
- />
- ) : null}
- {title && defined(pageId) ? (
- <ExploreBreadcrumb traceItemDataset={TraceItemDataset.TRACEMETRICS} />
- ) : null}
- <Layout.Title>
- {title ? title : t('Metrics')}
- <FeatureBadge type="beta" />
- </Layout.Title>
- </Layout.HeaderContent>
- <Layout.HeaderActions>
- <FeedbackButton
- feedbackOptions={{
- messagePlaceholder: t('How can we make metrics work better for you?'),
- tags: {
- ['feedback.source']: 'metrics-listing',
- ['feedback.owner']: 'performance',
- },
- }}
+ <Layout.HeaderContent unified>
+ {hasSavedQueryTitle ? (
+ <SentryDocumentTitle
+ title={`${savedQuery.name} — ${t('Metrics')}`}
+ orgSlug={organization?.slug}
/>
- </Layout.HeaderActions>
- </AnalyticsArea>
+ ) : null}
+ {title && defined(pageId) ? (
+ <ExploreBreadcrumb traceItemDataset={TraceItemDataset.TRACEMETRICS} />
+ ) : null}
+ <Layout.Title>
+ {title ? title : t('Metrics')}
+ <FeatureBadge type="beta" />
+ </Layout.Title>
+ </Layout.HeaderContent>
+ <Layout.HeaderActions>
+ <FeedbackButton
+ feedbackOptions={{
+ messagePlaceholder: t('How can we make metrics work better for you?'),
+ tags: {
+ ['feedback.source']: 'metrics-listing',
+ ['feedback.owner']: 'performance',
+ },
+ }}
+ />
+ </Layout.HeaderActions>
</Layout.Header>
);
}This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| organization, | ||
| area: analyticsArea, | ||
| natural_language_query: searchQuery, | ||
| }); |
There was a problem hiding this comment.
Error handler uses stale state instead of mutation variables
Low Severity
The new ai_query.error analytics event in the onError callback uses searchQuery (current component state) for natural_language_query, but variables (the actual submitted query string) is available as the second parameter of the callback. Since onError fires asynchronously after a failed request, searchQuery may have changed if the user edited the input while waiting. The other analytics calls in the file use searchQuery in synchronous event handlers where it's the current value being acted on, but here variables would more accurately reflect the query that actually failed.
There was a problem hiding this comment.
Fine cuz we want the query that was submitted before the error



For the natural language query assistants ("Ask Seer") in issues/discover/logs/spans search bars. Previous analytics events were prefixed, e.g.
logs.ai_query.*, which is tedious to register event defns and make dashboards for, or maintain long-term as we add moreAskSeerComboBox. AFAIK there's no active dashboards using these events and I plan to clean them up in a followup.This PR adds new events w/
areaparam - achieves this by wrapping top-level components withAnalyticAreacontext, a pattern we already use for replays/feedback.Also adds
ai_query.errorto track failed translate requests. Note theuseAnalyticsAreahook is safe even if not called from inside anAnalyticsArea.breaking migration for trace.explorer.ai_query_feedback - these are incorrectly always prefixed with traces when it's for all datasets. Migrate to ai_query.feedback w/area param
