You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This compliance adapter wraps the PostHog Android SDK and exposes a standardized HTTP API for automated compliance testing using the [PostHog SDK Test Harness](https://github.com/PostHog/posthog-sdk-test-harness).
4
+
5
+
## Quick Start
6
+
7
+
### Running Tests in CI (Recommended)
8
+
9
+
Tests run automatically in GitHub Actions on:
10
+
- Push to `main`/`master` branch
11
+
- Pull requests
12
+
- Manual trigger via `workflow_dispatch`
13
+
14
+
See `.github/workflows/sdk-compliance-tests.yml`
15
+
16
+
### Running Tests Locally
17
+
18
+
**Note:** Requires x86_64 architecture due to Java 8 dependency. On Apple Silicon, Docker will use emulation (slower but works).
19
+
20
+
```bash
21
+
cd sdk_compliance_adapter
22
+
docker-compose up --build --abort-on-container-exit
23
+
```
24
+
25
+
## Architecture
26
+
27
+
-**adapter.kt** - Ktor HTTP server implementing the compliance adapter API
28
+
-**TrackingInterceptor** - OkHttp interceptor for monitoring SDK HTTP requests
29
+
-**Dockerfile** - Multi-stage Docker build (requires x86_64 for Java 8)
30
+
-**docker-compose.yml** - Local test orchestration
31
+
32
+
## SDK Modifications
33
+
34
+
To enable request tracking, we added an optional `httpClient` parameter to `PostHogConfig`:
35
+
36
+
```kotlin
37
+
// PostHogConfig.kt
38
+
publicvar httpClient: okhttp3.OkHttpClient?=null
39
+
```
40
+
41
+
This allows the test adapter to inject a custom OkHttpClient with tracking interceptors. **This change is fully backward compatible** - existing code works unchanged.
42
+
43
+
## Implementation Details
44
+
45
+
### HTTP Request Tracking
46
+
47
+
The adapter injects a custom OkHttpClient that:
48
+
- Intercepts all `/batch/` requests
49
+
- Extracts event UUIDs from request bodies
50
+
- Tracks status codes, retry attempts, and event counts
51
+
52
+
### Event Tracking
53
+
54
+
Events are tracked via:
55
+
1.`beforeSend` hook - Captures UUIDs as events are queued
56
+
2. HTTP interceptor - Verifies UUIDs in outgoing requests
0 commit comments