feat(error-tracking): add PHP error tracking support#109
Open
feat(error-tracking): add PHP error tracking support#109
Conversation
cat-ph
commented
Mar 27, 2026
| { | ||
| // Keep source context bounded so large local variables / generated code snippets do not push | ||
| // $exception payloads past the transport size limit. | ||
| private const MAX_CONTEXT_LINE_LENGTH = 200; |
Author
There was a problem hiding this comment.
this with the "low" default frame limit of 20 is quite an "artificial" limit to prevent #31 (the libcurl limitation of 32kb) - that might still happen, I'll try looking at that next so we can drop these afterwards, I ran into it a few times testing
hpouillot
approved these changes
Mar 27, 2026
| PostHog::init( | ||
| $_ENV['POSTHOG_PROJECT_API_KEY'], | ||
| [ | ||
| 'host' => $_ENV['POSTHOG_HOST'] ?? 'https://app.posthog.com', |
There was a problem hiding this comment.
Suggested change
| 'host' => $_ENV['POSTHOG_HOST'] ?? 'https://app.posthog.com', | |
| 'host' => $_ENV['POSTHOG_HOST'] ?? 'https://us.i.posthog.com', |
| PostHog::init('phc_xxx', [ | ||
| 'enable_error_tracking' => true, | ||
| 'capture_uncaught_exceptions' => true, | ||
| 'capture_errors' => true, |
There was a problem hiding this comment.
would it make sense to nest error tracking config into an error_tracking key ?
| */ | ||
| private function buildExceptionList(\Throwable|string $exception): ?array | ||
| { | ||
| ExceptionCapture::configure($this->options); |
There was a problem hiding this comment.
do we need to reconfigure exception capture on every call ?
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
Add PHP error tracking support to
posthog-php.This includes:
captureException(...)support forThrowable|stringChanges
$exception_listpayload buildingErrorExceptionE_USER_ERRORthrough the error handler path as wellTest Plan
php -lon changed files./vendor/bin/phpunitFull PHPUnit passes with the repo's existing non-fatal PHPUnit issues: