Repository: getsentry/sentry

Issue:
Check culprit of cocoa reported events
<img width="1698" alt="screenshot_2016-12-02_13_27_16_png_and_screenshot_2016-12-02_13_27_07_png" src="https://cloud.githubusercontent.com/assets/363802/20834958/35ec775a-b898-11e6-9ddc-156b76a9ce1b.png">



Discussion:

Resolving patch:
diff --git a/src/sentry/interfaces/stacktrace.py b/src/sentry/interfaces/stacktrace.py
--- a/src/sentry/interfaces/stacktrace.py
+++ b/src/sentry/interfaces/stacktrace.py
@@ -507,10 +507,7 @@ def get_culprit_string(self, platform=None):
         if self.platform is not None:
             platform = self.platform
         if platform in ('objc', 'cocoa'):
-            return '%s (%s)' % (
-                self.function or '?',
-                trim_package(self.package),
-            )
+            return self.function or '?'
         fileloc = self.module or self.filename
         if not fileloc:
             return ''
@@ -816,7 +813,9 @@ def get_culprit_string(self, platform=None):
         default = None
         for frame in reversed(self.frames):
             if frame.in_app:
-                return frame.get_culprit_string(platform=platform)
+                culprit = frame.get_culprit_string(platform=platform)
+                if culprit:
+                    return culprit
             elif default is None:
                 default = frame.get_culprit_string(platform=platform)
         return default


Test patch:
diff --git a/tests/sentry/interfaces/test_stacktrace.py b/tests/sentry/interfaces/test_stacktrace.py
--- a/tests/sentry/interfaces/test_stacktrace.py
+++ b/tests/sentry/interfaces/test_stacktrace.py
@@ -383,10 +383,45 @@ def test_cocoa_culprit(self):
                 'package': '/foo/bar/baz.dylib',
                 'lineno': 1,
                 'in_app': True,
+                'function': '-[CRLCrashAsyncSafeThread crash]',
+            }
+        ]))
+        assert stacktrace.get_culprit_string(platform='cocoa') == '-[CRLCrashAsyncSafeThread crash]'
+
+    def test_exclude_libswiftCore_from_in_app(self):
+        stacktrace = Stacktrace.to_python(dict(frames=[
+            {
+                'filename': 'foo/baz.c',
+                'package': '/foo/bar/libswiftCore.dylib',
+                'lineno': 1,
+                'in_app': True,
+                'function': 'fooBar',
+            }
+        ]))
+        assert stacktrace.frames[0].in_app is False
+
+    def test_cocoa_strict_stacktrace(self):
+        stacktrace = Stacktrace.to_python(dict(frames=[
+            {
+                'filename': 'foo/baz.c',
+                'package': '/foo/bar/libswiftCore.dylib',
+                'lineno': 1,
+                'in_app': False,
                 'function': 'fooBar',
+            },
+            {
+                'package': '/foo/bar/MyApp',
+                'in_app': True,
+                'function': 'fooBar2',
+            },
+            {
+                'filename': 'Mycontroller.swift',
+                'package': '/foo/bar/MyApp',
+                'in_app': True,
+                'function': '-[CRLCrashAsyncSafeThread crash]',
             }
         ]))
-        assert stacktrace.get_culprit_string(platform='cocoa') == 'fooBar (baz)'
+        assert stacktrace.get_culprit_string(platform='cocoa') == '-[CRLCrashAsyncSafeThread crash]'
 
     def test_get_hash_does_not_group_different_js_errors(self):
         interface = Stacktrace.to_python({