Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sentry/analytics/events/autofix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class AiAutofixPrCreatedCompletedEvent(AiAutofixPhaseEvent):
@analytics.eventclass("ai.autofix.agent_handoff")
class AiAutofixAgentHandoffEvent(AiAutofixPhaseEvent):
coding_agent: str | None
initiator: str | None = None


analytics.register(AiAutofixRootCauseStartedEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def post(self, request: Request, organization: Organization) -> Response:
trigger_source=trigger_source,
instruction=instruction,
user_id=request.user.id,
initiator="user",
)

successes = results["successes"]
Expand Down
1 change: 1 addition & 0 deletions src/sentry/seer/autofix/autofix_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ def trigger_coding_agent_handoff(
group_id=group.id,
referrer=referrer.value,
coding_agent=coding_agent_name,
initiator="automation",
)
)

Expand Down
16 changes: 15 additions & 1 deletion src/sentry/seer/autofix/coding_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from requests import HTTPError
from rest_framework.exceptions import APIException, NotFound, PermissionDenied, ValidationError

from sentry import features
from sentry import analytics, features


class IntegrationNotFound(NotFound):
Expand All @@ -30,6 +30,7 @@ class StateReposNotFound(NotFound):
pass


from sentry.analytics.events.autofix_events import AiAutofixAgentHandoffEvent
from sentry.constants import ENABLE_SEER_CODING_DEFAULT, ObjectStatus
from sentry.integrations.claude_code.integration import (
ClaudeCodeIntegrationMetadata,
Expand Down Expand Up @@ -419,6 +420,7 @@ def launch_coding_agents_for_run(
trigger_source: AutofixTriggerSource = AutofixTriggerSource.SOLUTION,
instruction: str | None = None,
user_id: int | None = None,
initiator: str | None = None,
) -> dict[str, list]:
"""
Launch coding agents for an autofix run.
Expand Down Expand Up @@ -513,6 +515,18 @@ def launch_coding_agents_for_run(
},
)

coding_agent_name = provider or (integration.provider if integration else None)
analytics.record(
AiAutofixAgentHandoffEvent(
organization_id=organization.id,
project_id=autofix_state.request.project_id,
group_id=autofix_state.request.issue["id"],
referrer=None,
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.

Hardcoded referrer=None creates inconsistent analytics data

Medium Severity

The new AiAutofixAgentHandoffEvent in launch_coding_agents_for_run hardcodes referrer=None, while the existing recording site in trigger_coding_agent_handoff populates referrer with a meaningful value (e.g., autofix.on_completion_hook). The callers already know the source — organization_coding_agents passes initiator="user" and seer_rpc passes initiator="seer_agent" — but this information isn't mapped to the referrer field. Any existing BigQuery analytics queries filtering on referrer will silently miss events from these two new code paths.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4f76483. Configure here.

coding_agent=coding_agent_name,
initiator=initiator,
)
)

return results


Expand Down
1 change: 1 addition & 0 deletions src/sentry/seer/endpoints/seer_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ def trigger_coding_agent_launch(
integration_id=integration_id,
run_id=run_id,
trigger_source=AutofixTriggerSource(trigger_source),
initiator="seer_agent",
)
return {"success": True}
except IntegrationNotFound:
Expand Down
Loading