fix: accept kwargs in capture_exception so $exception_fingerprint is preserved#139
Draft
posthog[bot] wants to merge 1 commit intomainfrom
Draft
fix: accept kwargs in capture_exception so $exception_fingerprint is preserved#139posthog[bot] wants to merge 1 commit intomainfrom
posthog[bot] wants to merge 1 commit intomainfrom
Conversation
…preserved The positional-only signature silently dropped custom properties when users called capture_exception with the kwargs convention used elsewhere in the SDK (distinct_id:, properties:). This broke documented Error Tracking features like custom exception grouping via $exception_fingerprint. Now accepts both forms; existing positional callers are unaffected. Generated-By: PostHog Code Task-Id: 6a34588b-65e0-4139-80eb-913a2d82829a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostHog::Client#capture_exceptionused a positional-only signature, while the rest of the SDK (e.g.capture(attrs)) takes a kwargs Hash. When users naturally followed the kwargs convention:…Ruby coerced
{distinct_id:, properties:}into the second positional parameter, so:distinct_idbecame a Hash (truthy, so the||= SecureRandom.uuidfallback didn't fire)additional_propertiesstayed{}and the merge silently dropped every custom property — including$exception_fingerprint, breaking documented Error Tracking custom grouping.Fix
capture_exceptionnow accepts both forms:capture_exception(e, 'user-123', { 'foo' => 'bar' })capture_exception(e, distinct_id: 'user-123', properties: { 'foo' => 'bar' })Internal callers in
posthog-rails(active_job.rb,error_subscriber.rb,capture_exceptions.rb) all use the positional form and are unaffected.The
posthog-railsREADME example is updated to the kwargs form, with$exception_fingerprintshown explicitly.Test plan
$exception_fingerprintpassesPostHog.capture_exception(e, distinct_id: 'u', properties: { '$exception_fingerprint' => 'g' })and confirm the property reaches the backendposthog-railsauto-capture (still uses positional form)Created with PostHog Code