processing.py 840 B

12345678910111213141516171819202122232425262728293031
  1. import logging
  2. from datetime import datetime
  3. import six
  4. from sentry.utils.safe import get_path
  5. def get_crash_frame_from_event_data(data, frame_filter=None):
  6. frames = get_path(
  7. data, "exception", "values", -1, "stacktrace", "frames"
  8. ) or get_path(data, "stacktrace", "frames")
  9. if not frames:
  10. threads = get_path(data, "threads", "values")
  11. if threads and len(threads) == 1:
  12. frames = get_path(threads, 0, "stacktrace", "frames")
  13. default = None
  14. for frame in reversed(frames or ()):
  15. if frame is None:
  16. continue
  17. if frame_filter is not None:
  18. if not frame_filter(frame):
  19. continue
  20. if frame.get("in_app"):
  21. return frame
  22. if default is None:
  23. default = frame
  24. if default:
  25. return default