Skip to content

Commit

Permalink
feat(issue-summary): Send more data to be tracked (#76613)
Browse files Browse the repository at this point in the history
Send org slug, id, and project id to be tracked in issue summary
langfuse
  • Loading branch information
jennmueng authored Aug 27, 2024
1 parent a25149e commit 9941c4b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sentry/api/endpoints/group_ai_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def _call_seer(
"short_id": group.qualified_short_id,
"events": [serialized_event],
},
"organization_slug": group.organization.slug,
"organization_id": group.organization.id,
"project_id": group.project.id,
},
option=orjson.OPT_NON_STR_KEYS,
)
Expand Down
48 changes: 48 additions & 0 deletions tests/sentry/api/endpoints/test_group_ai_summary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from unittest.mock import ANY, Mock, patch

import orjson

from sentry.api.endpoints.group_ai_summary import SummarizeIssueResponse
from sentry.api.serializers.rest_framework.base import convert_dict_key_case, snake_to_camel_case
from sentry.testutils.cases import APITestCase, SnubaTestCase
Expand Down Expand Up @@ -143,3 +145,49 @@ def test_ai_summary_cache_write_read(self):
# Verify that _get_event and _call_seer were not called for the second request
mock_get_event.assert_not_called()
mock_call_seer.assert_not_called()

def test_call_seer_payload(self):
with (
patch(
"sentry.api.endpoints.group_ai_summary.GroupAiSummaryEndpoint._get_event"
) as mock_get_event,
patch("sentry.api.endpoints.group_ai_summary.requests.post") as mock_post,
patch("sentry.api.endpoints.group_ai_summary.sign_with_seer_secret") as mock_sign,
):
mock_event = {
"id": "test_event_id",
"data": "test_event_data",
"project_id": self.project.id,
}
mock_get_event.return_value = mock_event
mock_sign.return_value = {"Authorization": "Bearer test_token"}
mock_post.return_value.json.return_value = {
"group_id": str(self.group.id),
"summary": "Test summary",
"impact": "Test impact",
"headline": "Test headline",
}

self.client.post(self.url, format="json")

expected_payload = {
"group_id": self.group.id,
"issue": {
"id": self.group.id,
"title": self.group.title,
"short_id": self.group.qualified_short_id,
"events": [mock_event],
},
"organization_slug": self.group.organization.slug,
"organization_id": self.group.organization.id,
"project_id": self.project.id,
}

mock_post.assert_called_once()
actual_payload = orjson.loads(mock_post.call_args[1]["data"])
assert actual_payload == expected_payload

# Check headers
headers = mock_post.call_args[1]["headers"]
assert headers["content-type"] == "application/json;charset=utf-8"
assert headers["Authorization"] == "Bearer test_token"

0 comments on commit 9941c4b

Please sign in to comment.