-
Notifications
You must be signed in to change notification settings - Fork 33
feat: SDK Compliance #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: SDK Compliance #362
Conversation
posthog-android Compliance ReportDate: 2026-01-28 11:01:29 UTC
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 2358ms |
| Format Validation.Event Has Uuid | ✅ | 2023ms |
| Format Validation.Event Has Lib Properties | ✅ | 2023ms |
| Format Validation.Distinct Id Is String | ✅ | 2020ms |
| Format Validation.Token Is Present | ✅ | 2020ms |
| Format Validation.Custom Properties Preserved | ✅ | 2020ms |
| Format Validation.Event Has Timestamp | ✅ | 2024ms |
| Retry Behavior.Retries On 503 | ❌ | 7027ms |
| Retry Behavior.Does Not Retry On 400 | ✅ | 4024ms |
| Retry Behavior.Does Not Retry On 401 | ✅ | 4022ms |
| Retry Behavior.Respects Retry After Header | ❌ | 7023ms |
| Retry Behavior.Implements Backoff | ❌ | 17022ms |
| Retry Behavior.Retries On 500 | ❌ | 7026ms |
| Retry Behavior.Retries On 502 | ❌ | 7023ms |
| Retry Behavior.Retries On 504 | ❌ | 7027ms |
| Retry Behavior.Max Retries Respected | ❌ | 17023ms |
| Deduplication.Generates Unique Uuids | ✅ | 2041ms |
| Deduplication.Preserves Uuid On Retry | ❌ | 7023ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ❌ | 12032ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ❌ | 7032ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 2029ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 2020ms |
| Compression.Sends Gzip When Enabled | ✅ | 2016ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 2017ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 2012ms |
| Batch Format.Multiple Events Batched Together | ✅ | 2027ms |
| Error Handling.Does Not Retry On 403 | ✅ | 4021ms |
| Error Handling.Does Not Retry On 413 | ❌ | 4020ms |
| Error Handling.Retries On 408 | ✅ | 7019ms |
Failures
retry_behavior.retries_on_503
Expected at least 3 requests, got 1
retry_behavior.respects_retry_after_header
Expected at least 2 requests, got 1
retry_behavior.implements_backoff
Expected at least 3 requests, got 1
retry_behavior.retries_on_500
Expected at least 2 requests, got 1
retry_behavior.retries_on_502
Expected at least 2 requests, got 1
retry_behavior.retries_on_504
Expected at least 2 requests, got 1
retry_behavior.max_retries_respected
Expected 4 requests, got 1
deduplication.preserves_uuid_on_retry
Need at least 2 requests to check retry
deduplication.preserves_uuid_and_timestamp_on_retry
Expected at least 3 requests, got 1
deduplication.preserves_uuid_and_timestamp_on_batch_retry
Expected at least 2 requests, got 1
error_handling.does_not_retry_on_413
Expected 1 requests, got 2
| branches: [ main, master ] | ||
| paths: | ||
| - 'posthog/**' | ||
| - 'sdk_compliance_adapter/**' | ||
| - '.github/workflows/sdk-compliance-tests.yml' | ||
| pull_request: | ||
| branches: [ main, master ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| branches: [ main, master ] | |
| paths: | |
| - 'posthog/**' | |
| - 'sdk_compliance_adapter/**' | |
| - '.github/workflows/sdk-compliance-tests.yml' | |
| pull_request: | |
| branches: [ main, master ] | |
| branches: [ main ] | |
| paths: | |
| - 'posthog/**' | |
| - 'sdk_compliance_adapter/**' | |
| - '.github/workflows/sdk-compliance-tests.yml' | |
| pull_request: | |
| branches: [ main ] |
we dont have master
| * Default: `null` (SDK creates its own client). | ||
| */ | ||
| @PostHogInternal | ||
| public var httpClient: okhttp3.OkHttpClient? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public var httpClient: okhttp3.OkHttpClient? = null | |
| public var httpClient: OkHttpClient? = null |
then just import okhttp3.OkHttpClient
| * @property config The Config | ||
| */ | ||
| internal class GzipRequestInterceptor(private val config: PostHogConfig) : Interceptor { | ||
| public class GzipRequestInterceptor(private val config: PostHogConfig) : Interceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public class GzipRequestInterceptor(private val config: PostHogConfig) : Interceptor { | |
| internal class GzipRequestInterceptor(private val config: PostHogConfig) : Interceptor { |
we can revert this i assume? and run make api again
| println("[ADAPTER] Error parsing request body: ${e.message}") | ||
| e.printStackTrace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can clear all println and printStackTrace?
|
i can see the tests:
but CI didnt fail, is that expected @jose-sequeira ? |
💡 Motivation and Context
We need a language-agnostic way to verify that all PostHog SDKs implement the capture API correctly. The SDK Test Harness provides a shared contract and test runner. This PR integrates it into this SDK.
This adds:
The test harness runs a mock PostHog server, exercises the SDK through the adapter, and verifies behavior matches the contract defined in CONTRACT.yaml (event format, retries, compression, deduplication, etc.).
#skip-changelog
💚 How did you test it?
The compliance tests run as part of this PR's CI. The adapter was also tested locally via
docker-compose.📝 Checklist