prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  SDK Crash Detection: Store Project ID and Event ID
  Store project ID and event ID in the SDK crash detection context to find the original SDK crash event, which is only possible with admin Sentry rights.
  
  https://github.com/getsentry/sentry/blob/2c31ee009b44964f78b9e7e8282e602b7ef849b0/src/sentry/utils/sdk_crashes/sdk_crash_detection.py#L40C2-L42
  
  </issue>
  <code>
  [start of src/sentry/utils/sdk_crashes/sdk_crash_detection.py]
  1 from __future__ import annotations
  2 
  3 from typing import Any, Mapping, Optional
  4 
  5 from sentry.eventstore.models import Event
  6 from sentry.issues.grouptype import GroupCategory
  7 from sentry.utils.safe import get_path, set_path
  8 from sentry.utils.sdk_crashes.cocoa_sdk_crash_detector import CocoaSDKCrashDetector
  9 from sentry.utils.sdk_crashes.event_stripper import strip_event_data
  10 from sentry.utils.sdk_crashes.sdk_crash_detector import SDKCrashDetector
  11 
  12 
  13 class SDKCrashReporter:
  14     def report(self, event_data: Mapping[str, Any], event_project_id: int) -> Event:
  15         from sentry.event_manager import EventManager
  16 
  17         manager = EventManager(dict(event_data))
  18         manager.normalize()
  19         return manager.save(project_id=event_project_id)
  20 
  21 
  22 class SDKCrashDetection:
  23     def __init__(
  24         self,
  25         sdk_crash_reporter: SDKCrashReporter,
  26         sdk_crash_detector: SDKCrashDetector,
  27     ):
  28         self.sdk_crash_reporter = sdk_crash_reporter
  29         self.cocoa_sdk_crash_detector = sdk_crash_detector
  30 
  31     def detect_sdk_crash(self, event: Event, event_project_id: int) -> Optional[Event]:
  32         should_detect_sdk_crash = (
  33             event.group
  34             and event.group.issue_category == GroupCategory.ERROR
  35             and event.group.platform == "cocoa"
  36         )
  37         if not should_detect_sdk_crash:
  38             return None
  39 
  40         context = get_path(event.data, "contexts", "sdk_crash_detection")
  41         if context is not None and context.get("detected", False):
  42             return None
  43 
  44         # Getting the frames and checking if the event is unhandled might different per platform.
  45         # We will change this once we implement this for more platforms.
  46         is_unhandled = (
  47             get_path(event.data, "exception", "values", -1, "mechanism", "handled") is False
  48         )
  49         if is_unhandled is False:
  50             return None
  51 
  52         frames = get_path(event.data, "exception", "values", -1, "stacktrace", "frames")
  53         if not frames:
  54             return None
  55 
  56         if self.cocoa_sdk_crash_detector.is_sdk_crash(frames):
  57             sdk_crash_event_data = strip_event_data(event.data, self.cocoa_sdk_crash_detector)
  58 
  59             set_path(
  60                 sdk_crash_event_data, "contexts", "sdk_crash_detection", value={"detected": True}
  61             )
  62 
  63             return self.sdk_crash_reporter.report(sdk_crash_event_data, event_project_id)
  64 
  65         return None
  66 
  67 
  68 _crash_reporter = SDKCrashReporter()
  69 _cocoa_sdk_crash_detector = CocoaSDKCrashDetector()
  70 
  71 sdk_crash_detection = SDKCrashDetection(_crash_reporter, _cocoa_sdk_crash_detector)
  72
  [end of src/sentry/utils/sdk_crashes/sdk_crash_detection.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py
  --- a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py
  +++ b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py
  @@ -57,7 +57,14 @@
               sdk_crash_event_data = strip_event_data(event.data, self.cocoa_sdk_crash_detector)
   
               set_path(
  -                sdk_crash_event_data, "contexts", "sdk_crash_detection", value={"detected": True}
  +                sdk_crash_event_data,
  +                "contexts",
  +                "sdk_crash_detection",
  +                value={
  +                    "detected": True,
  +                    "original_project_id": event.project.id,
  +                    "original_event_id": event.event_id,
  +                },
               )
   
               return self.sdk_crash_reporter.report(sdk_crash_event_data, event_project_id)
  
verification_info: {"golden_diff": "diff --git a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py\n--- a/src/sentry/utils/sdk_crashes/sdk_crash_detection.py\n+++ b/src/sentry/utils/sdk_crashes/sdk_crash_detection.py\n@@ -57,7 +57,14 @@\n             sdk_crash_event_data = strip_event_data(event.data, self.cocoa_sdk_crash_detector)\n \n             set_path(\n-                sdk_crash_event_data, \"contexts\", \"sdk_crash_detection\", value={\"detected\": True}\n+                sdk_crash_event_data,\n+                \"contexts\",\n+                \"sdk_crash_detection\",\n+                value={\n+                    \"detected\": True,\n+                    \"original_project_id\": event.project.id,\n+                    \"original_event_id\": event.event_id,\n+                },\n             )\n \n             return self.sdk_crash_reporter.report(sdk_crash_event_data, event_project_id)\n", "issue": "SDK Crash Detection: Store Project ID and Event ID\nStore project ID and event ID in the SDK crash detection context to find the original SDK crash event, which is only possible with admin Sentry rights.\r\n\r\nhttps://github.com/getsentry/sentry/blob/2c31ee009b44964f78b9e7e8282e602b7ef849b0/src/sentry/utils/sdk_crashes/sdk_crash_detection.py#L40C2-L42\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import Any, Mapping, Optional\n\nfrom sentry.eventstore.models import Event\nfrom sentry.issues.grouptype import GroupCategory\nfrom sentry.utils.safe import get_path, set_path\nfrom sentry.utils.sdk_crashes.cocoa_sdk_crash_detector import CocoaSDKCrashDetector\nfrom sentry.utils.sdk_crashes.event_stripper import strip_event_data\nfrom sentry.utils.sdk_crashes.sdk_crash_detector import SDKCrashDetector\n\n\nclass SDKCrashReporter:\n    def report(self, event_data: Mapping[str, Any], event_project_id: int) -> Event:\n        from sentry.event_manager import EventManager\n\n        manager = EventManager(dict(event_data))\n        manager.normalize()\n        return manager.save(project_id=event_project_id)\n\n\nclass SDKCrashDetection:\n    def __init__(\n        self,\n        sdk_crash_reporter: SDKCrashReporter,\n        sdk_crash_detector: SDKCrashDetector,\n    ):\n        self.sdk_crash_reporter = sdk_crash_reporter\n        self.cocoa_sdk_crash_detector = sdk_crash_detector\n\n    def detect_sdk_crash(self, event: Event, event_project_id: int) -> Optional[Event]:\n        should_detect_sdk_crash = (\n            event.group\n            and event.group.issue_category == GroupCategory.ERROR\n            and event.group.platform == \"cocoa\"\n        )\n        if not should_detect_sdk_crash:\n            return None\n\n        context = get_path(event.data, \"contexts\", \"sdk_crash_detection\")\n        if context is not None and context.get(\"detected\", False):\n            return None\n\n        # Getting the frames and checking if the event is unhandled might different per platform.\n        # We will change this once we implement this for more platforms.\n        is_unhandled = (\n            get_path(event.data, \"exception\", \"values\", -1, \"mechanism\", \"handled\") is False\n        )\n        if is_unhandled is False:\n            return None\n\n        frames = get_path(event.data, \"exception\", \"values\", -1, \"stacktrace\", \"frames\")\n        if not frames:\n            return None\n\n        if self.cocoa_sdk_crash_detector.is_sdk_crash(frames):\n            sdk_crash_event_data = strip_event_data(event.data, self.cocoa_sdk_crash_detector)\n\n            set_path(\n                sdk_crash_event_data, \"contexts\", \"sdk_crash_detection\", value={\"detected\": True}\n            )\n\n            return self.sdk_crash_reporter.report(sdk_crash_event_data, event_project_id)\n\n        return None\n\n\n_crash_reporter = SDKCrashReporter()\n_cocoa_sdk_crash_detector = CocoaSDKCrashDetector()\n\nsdk_crash_detection = SDKCrashDetection(_crash_reporter, _cocoa_sdk_crash_detector)\n", "path": "src/sentry/utils/sdk_crashes/sdk_crash_detection.py"}]}