Skip to content

Commit a242654

Browse files
authored
docs: document public SDK APIs (#144)
* docs: document public SDK APIs * docs: mark HTTP transport classes internal * docs: simplify README
1 parent e0f9428 commit a242654

26 files changed

Lines changed: 734 additions & 226 deletions

‎CONTRIBUTING.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Thanks for your interest in improving the PostHog PHP SDK.
1111
composer install --prefer-dist --no-progress
1212
```
1313

14+
## Running the example app
15+
16+
1. Copy `.env.example` to `.env` and add your PostHog credentials.
17+
2. Run the interactive example script:
18+
19+
```bash
20+
php example.php
21+
```
22+
1423
## CI-aligned checks
1524

1625
Run the test command used in CI:

‎README.md‎

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,12 @@ Specifically, the [PHP integration](https://posthog.com/docs/integrations/php-in
1010
## Features
1111

1212
- ✅ Event capture and user identification
13-
- ✅ Error tracking with manual exception capture
14-
- ✅ Opt-in automatic PHP exception, error, and fatal shutdown capture
15-
- ✅ Feature flag local evaluation
16-
- ✅ **Feature flag dependencies** (new!) - Create conditional flags based on other flags
17-
- ✅ Multivariate flags and payloads
13+
- ✅ Feature flags, including local evaluation, multivariate flags, payloads, and flag dependencies
1814
- ✅ Group analytics
15+
- ✅ Error tracking with manual exception capture and opt-in automatic PHP exception, error, and fatal shutdown capture
16+
- ✅ Request context helpers for applying distinct IDs, session IDs, and common properties across a request
1917
- ✅ Comprehensive test coverage
2018

21-
## Quick Start
22-
23-
1. Copy `.env.example` to `.env` and add your PostHog credentials
24-
2. Run `php example.php` to see interactive examples of all features
25-
26-
## Error Tracking
27-
28-
Manual exception capture:
29-
30-
```php
31-
PostHog::captureException($exception, 'user-123', [
32-
'$current_url' => 'https://example.com/settings',
33-
]);
34-
```
35-
36-
Opt-in automatic capture from the core SDK:
37-
38-
```php
39-
PostHog::init('phc_xxx', [
40-
'error_tracking' => [
41-
'enabled' => true,
42-
'capture_errors' => true,
43-
'excluded_exceptions' => [
44-
\InvalidArgumentException::class,
45-
],
46-
'context_provider' => static function (array $payload): array {
47-
return [
48-
'distinctId' => $_SESSION['user_id'] ?? null,
49-
'properties' => [
50-
'$current_url' => $_SERVER['REQUEST_URI'] ?? null,
51-
],
52-
];
53-
},
54-
],
55-
]);
56-
```
57-
58-
Auto error tracking is off by default. When enabled, the SDK chains existing exception and error handlers instead of replacing app behavior.
59-
6019
## Questions?
6120

6221
### [Join our Slack community.](https://join.slack.com/t/posthogusers/shared_invite/enQtOTY0MzU5NjAwMDY3LTc2MWQ0OTZlNjhkODk3ZDI3NDVjMDE1YjgxY2I4ZjI4MzJhZmVmNjJkN2NmMGJmMzc2N2U3Yjc3ZjI5NGFlZDQ)

0 commit comments

Comments
 (0)