diff --git a/events/utils.py b/events/utils.py
index 47f81e2..6aa3ac5 100644
--- a/events/utils.py
+++ b/events/utils.py
@@ -129,26 +129,29 @@ def apply_sourcemaps(event_data):
source_for_filename = {}
for filename, meta in filenames_with_metas:
sm_data = json.loads(_postgres_fix(meta.file.data))
- if "sourcesContent" not in sm_data or len(sm_data["sourcesContent"]) != 1:
- # our assumption is: 1 sourcemap, 1 source. The fact that both "sources" (a list of filenames) and
- # "sourcesContent" are lists seems to indicate that this assumption does not generally hold. But it not
- # holding does not play well with the id of debug_id, I think?
- continue
- source_for_filename[filename] = sm_data["sourcesContent"][0].splitlines()
+ sources = sm_data.get("sources", [])
+ sources_content = sm_data.get("sourcesContent", [])
+
+ for (source_file_name, source_file) in zip(sources, sources_content):
+ source_for_filename[source_file_name] = source_file.splitlines()
for exception in get_values(event_data.get("exception", {})):
for frame in exception.get("stacktrace", {}).get("frames", []):
# NOTE: try/except in the loop would allow us to selectively skip frames that we fail to process
- if frame.get("filename") in sourcemap_for_filename and frame["filename"] in source_for_filename:
+ if frame.get("filename") in sourcemap_for_filename:
sm = sourcemap_for_filename[frame["filename"]]
- lines = source_for_filename[frame["filename"]]
token = sm.lookup(frame["lineno"] + FROM_DISPLAY, frame["colno"])
- frame["pre_context"] = lines[max(0, token.src_line - 5):token.src_line]
- frame["context_line"] = lines[token.src_line]
- frame["post_context"] = lines[token.src_line + 1:token.src_line + 5]
- frame["lineno"] = token.src_line + TO_DISPLAY
- # frame["colno"] = token.src_col + TO_DISPLAY not actually used
+ if token.src in source_for_filename:
+ lines = source_for_filename[token.src]
+
+ frame["pre_context"] = lines[max(0, token.src_line - 5):token.src_line]
+ frame["context_line"] = lines[token.src_line]
+ frame["post_context"] = lines[token.src_line + 1:token.src_line + 5]
+ frame["lineno"] = token.src_line + TO_DISPLAY
+ frame['filename'] = token.src
+ frame['function'] = token.name
+ # frame["colno"] = token.src_col + TO_DISPLAY not actually used
\ No newline at end of file
diff --git a/files/tests.py b/files/tests.py
index bfc222e..1cafb0e 100644
--- a/files/tests.py
+++ b/files/tests.py
@@ -126,7 +126,7 @@ class FilesTests(TransactionTestCase):
200, response.status_code, response.content if response.status_code != 302 else response.url)
# we could/should make this more general later; this is great for example nr.1:
- key_phrase = 'captureException line 15'
+ key_phrase = 'captureException.js line 7'
self.assertTrue(key_phrase in response.content.decode('utf-8'))
except Exception as e: