feat: add captureException() for error tracking#106
Open
hnipps wants to merge 1 commit intoPostHog:masterfrom
Open
feat: add captureException() for error tracking#106hnipps wants to merge 1 commit intoPostHog:masterfrom
hnipps wants to merge 1 commit intoPostHog:masterfrom
Conversation
Add exception capture support to the PHP SDK, matching the functionality available in Python and Node SDKs. This enables PHP applications to send exceptions to PostHog's error tracking. - New ExceptionUtils class for converting Throwables to $exception_list - Client::captureException() with chained exception support - PostHog::captureException() static facade - Source context capture (configurable, default 5 lines) - Anonymous capture with UUID v4 when no distinctId provided - Comprehensive test suite (20 tests, 140 assertions) Closes PostHog/posthog#31076 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Adds
captureException()to the PHP SDK, enabling PHP applications to send exceptions to PostHog's error tracking — matching the existing Python and Node SDK implementations.ExceptionUtilsclass — converts\Throwableto$exception_listpayload with stack frames, source context, and chained exception supportClient::captureException()— captures exceptions as$exceptionevents with configurable source context linesPostHog::captureException()— static facade for the same functionalitydistinctIdis provided, generates a UUID v4 and sets$process_person_profile: falseKey design decisions
set_exception_handler) — keeping initial PR scoped to manual capture; autocapture can follow in a separate PRargsin frames — PHP trace includes function args but they can contain sensitive data and blow batch size limitsplatform: "php"— matches Python's"python"and Node's"node:javascript"conventionexception_source_context_linesoption (0 to disable)Usage
Test plan
\Errorsupport, static facade, additional properties, 3-deep chainsCloses PostHog/posthog#31076
🤖 Generated with Claude Code