Skip to content

feat(error-tracking): add PHP error tracking support#109

Merged
cat-ph merged 8 commits intomasterfrom
feat/php-errortracking
Apr 6, 2026
Merged

feat(error-tracking): add PHP error tracking support#109
cat-ph merged 8 commits intomasterfrom
feat/php-errortracking

Conversation

@cat-ph
Copy link
Copy Markdown
Contributor

@cat-ph cat-ph commented Mar 26, 2026

Summary

Add PHP error tracking support to posthog-php.

This includes:

  • manual captureException(...) support for Throwable|string
  • opt-in automatic capture for uncaught exceptions, PHP errors, and fatal shutdown errors

Changes

  • add manual exception capture and $exception_list payload building
  • add opt-in auto registration for exception, error, and shutdown handlers
  • preserve default crash behavior when no prior exception handler exists
  • preserve first installed client as the owner of global auto-capture handlers
  • avoid double capture when warnings are promoted to ErrorException
  • capture E_USER_ERROR through the error handler path as well

Test Plan

  • php -l on changed files
  • ./vendor/bin/phpunit

Full PHPUnit passes with the repo's existing non-fatal PHPUnit issues:

  • no coverage driver
  • existing warnings/deprecations

@cat-ph cat-ph requested review from a team, ablaszkiewicz and hpouillot March 26, 2026 23:56
Comment thread lib/ExceptionCapture.php Outdated
Copy link
Copy Markdown

@hpouillot hpouillot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, but looks good to my rusty PHP eyes 👴🏻

Comment thread example.php
Comment thread README.md Outdated
Comment thread lib/Client.php Outdated
@cat-ph cat-ph force-pushed the feat/php-errortracking branch 2 times, most recently from bba49b8 to 2afd589 Compare April 1, 2026 14:39
@cat-ph cat-ph force-pushed the feat/php-errortracking branch from 2afd589 to 5880152 Compare April 1, 2026 16:07
Comment thread README.md

```php
PostHog::init('phc_xxx', [
'error_tracking' => [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:chef-kiss:

@cat-ph cat-ph requested a review from a team April 1, 2026 22:46
@cat-ph cat-ph added the release label Apr 6, 2026
@cat-ph cat-ph merged commit 9b72b25 into master Apr 6, 2026
16 checks passed
@cat-ph cat-ph deleted the feat/php-errortracking branch April 6, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants