Skip to content

ref(assisted-query): add new analytics events segmented by area#112029

Merged
aliu39 merged 8 commits into
masterfrom
andrewliu/generic-ai-query-analytics
Apr 2, 2026
Merged

ref(assisted-query): add new analytics events segmented by area#112029
aliu39 merged 8 commits into
masterfrom
andrewliu/generic-ai-query-analytics

Conversation

@aliu39
Copy link
Copy Markdown
Member

@aliu39 aliu39 commented Apr 1, 2026

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 more AskSeerComboBox. 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/area param - achieves this by wrapping top-level components with AnalyticArea context, a pattern we already use for replays/feedback.

  • issue_list
  • discover
  • explorer.logs/spans/metrics

Also adds ai_query.error to track failed translate requests. Note the useAnalyticsArea hook is safe even if not called from inside an AnalyticsArea.

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
Screenshot 2026-04-01 at 6 48 55 PM

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 1, 2026
@aliu39 aliu39 marked this pull request as ready for review April 1, 2026 20:48
@aliu39 aliu39 requested review from a team as code owners April 1, 2026 20:48
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 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Metrics AnalyticsArea wraps 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.

Create PR

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.

Comment thread static/app/views/explore/metrics/content.tsx Outdated
Comment thread static/app/views/discover/homepage.tsx Outdated
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 1 potential issue.

Fix All in Cursor

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,
});
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.

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.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fine cuz we want the query that was submitted before the error

@aliu39 aliu39 merged commit 04c8c9f into master Apr 2, 2026
74 checks passed
@aliu39 aliu39 deleted the andrewliu/generic-ai-query-analytics branch April 2, 2026 17:42
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants