Error tracking source code context in stack frames#87
Conversation
posthog-elixir Compliance ReportDate: 2026-03-19 12:20:20 UTC ✅ All Tests Passed!29/29 tests passed Capture Tests✅ 29/29 tests passed View Details
|
rafaeelaudibert
left a comment
There was a problem hiding this comment.
I'm not familiar with maps but this seems to be working well! Make sure we've done extensive testing before merging this :)
@martosaur I know you're using Error Tracking in production, wondering if you're missing what's being implemented here or does this feel like extra work for no reason?
lib/posthog/sources.ex
Outdated
| @@ -0,0 +1,198 @@ | |||
| defmodule PostHog.Sources do | |||
There was a problem hiding this comment.
Sources is a very generic name. How about PostHog.ErrorTracking.Sources?
There was a problem hiding this comment.
good point, I was thinking we might use them later for other stuff, but not sure what exactly for so YAGNI, updated!
lib/posthog/sources.ex
Outdated
| # Part of this approach is inspired by getsentry/sentry-elixir by Software, Inc. dba Sentry | ||
| # Licensed under the MIT License | ||
| # - sentry-elixir/lib/sentry/sources.ex | ||
| # - sentry-elixir/lib/mix/tasks/sentry.package_source_code.ex | ||
|
|
||
| # 💖 open source (under MIT License) |
There was a problem hiding this comment.
I assume this should be a trailer comment at the top of the file instead?
There was a problem hiding this comment.
Also, confirm the base LICENSE files mention this or else we're not compliant.
There was a problem hiding this comment.
updated, ty! trailer comment in both + LICENSE mention
code source is a nice QoL addition for sure. I'm just not very familiar with how it works exactly in any other lib, so can't really tell good from bad without doing some research |
…ate LICENSE - Move PostHog.Sources → PostHog.ErrorTracking.Sources - Add Sentry-elixir attribution headers in sources.ex and mix task - Update LICENSE to note inspired portions and credit Sentry - Refactor handler.maybe_add_source_context to use with block - Fix nested module alias (credo strict) - Move test file to match new module path
|
thanks @martosaur and @rafaeelaudibert - I think there are some potential approaches, this seems like probably the most straightforward, also has its cons (since technically source code will live with the release files, and hot code upgrades could get messy / cause drift). Others we were thinking could be 1. using something like We could also in the future support uploading these custom maps with a predefined format & version and resolving them on our side instead |
ablaszkiewicz
left a comment
There was a problem hiding this comment.
Looks great!!!!! 🚀 Make sure:
- we include it in the changelog because that's pretty awesome,
- update elixir docs (I think Hugues has a PR open for something related to elixir on .com repo),
- update ET onboarding in monorepo so you can choose elixir to set it up.
SHIP IT!
| [{^file, lines}] -> lines | ||
| [] -> nil | ||
| end | ||
| rescue |
There was a problem hiding this comment.
what can throw ArgumentError here?
Adds source code context to error tracking stack frames, allowing us to display lines of code around the error location.
Changes