Skip to content

feat(flags): implement SDK compliance adapter for posthog-elixir#105

Merged
marandaneto merged 4 commits intomainfrom
flags/sdk-compliance-adapter
Apr 29, 2026
Merged

feat(flags): implement SDK compliance adapter for posthog-elixir#105
marandaneto merged 4 commits intomainfrom
flags/sdk-compliance-adapter

Conversation

@andehen
Copy link
Copy Markdown
Contributor

@andehen andehen commented Apr 28, 2026

Summary

Extend the existing sdk_compliance_adapter/ so the PostHog SDK Test Harness can exercise the feature flag and capture suites against posthog-elixir.

  • Declare the capture_v0 and encoding_gzip capabilities on /health. The SDK already supports gzip via the default Req-based API client and the existing adapter passes the full capture contract — we just hadn't told the harness about it.
  • Add POST /get_feature_flag, which constructs the /flags body the harness contract expects and forwards it through PostHog.FeatureFlags.flags/2.
    • distinct_id is mirrored into person_properties (the auto-added value the contract asserts on).
    • groups and group_properties default to empty maps.
    • flag_keys_to_evaluate is scoped to the requested key.
    • geoip_disable is forwarded when set.
    • api_key is auto-injected by the SDK's API client; gzip compression follows the value passed to /init.

Test plan

Locally with docker compose up --build --abort-on-container-exit against ghcr.io/posthog/sdk-test-harness:latest (digest sha256:a04e04…):

CAPTURE Tests:        29 passed | 0 failed
FEATURE_FLAGS Tests:   1 passed | 0 failed
Total: 30 | 30 passed | 0 failed

The single feature flag test currently in the suite — request_payload.request_with_person_properties_device_id — passes, including the person_properties.distinct_id auto-add assertion.

Notes

  • The SDK doesn't currently surface the per-event UUID returned from bare_capture, so /capture still responds with %{success: true} only. The harness validates UUIDs via the tracked requests_made list (intercepted by SdkComplianceAdapter.TrackedClient), so all UUID-related capture tests still pass.
  • force_remote is accepted but has no effect: the SDK has no local-evaluation path yet, so every /get_feature_flag already issues a fresh remote /flags request.

andehen added 3 commits April 28, 2026 16:45
The endpoint constructs the /flags request body the harness contract
expects: distinct_id at the top level, distinct_id mirrored into
person_properties (the auto-added value the contract asserts on),
groups/group_properties defaulting to empty maps, geoip_disable, and
flag_keys_to_evaluate scoped to the requested key. The body is then
sent through PostHog.FeatureFlags.flags/2 so the SDK's API client
auto-injects api_key and (when enabled) gzip-compresses the request.

Returns the resolved variant string, the boolean enabled state for
boolean flags, or null when the flag is missing from the response.

This satisfies request_payload.request_with_person_properties_device_id
in the feature_flags suite of the SDK Test Harness.
@andehen andehen requested review from a team and rafaeelaudibert as code owners April 28, 2026 14:49
@andehen andehen enabled auto-merge (squash) April 28, 2026 15:00
auto-merge was automatically disabled April 29, 2026 07:39

Pull request was closed

@marandaneto marandaneto reopened this Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

posthog-elixir Compliance Report

Date: 2026-04-29 09:45:29 UTC
Duration: 105972ms

✅ All Tests Passed!

30/30 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 608ms
Format Validation.Event Has Uuid 609ms
Format Validation.Event Has Lib Properties 609ms
Format Validation.Distinct Id Is String 609ms
Format Validation.Token Is Present 609ms
Format Validation.Custom Properties Preserved 609ms
Format Validation.Event Has Timestamp 609ms
Retry Behavior.Retries On 503 5614ms
Retry Behavior.Does Not Retry On 400 2612ms
Retry Behavior.Does Not Retry On 401 2612ms
Retry Behavior.Respects Retry After Header 5616ms
Retry Behavior.Implements Backoff 15612ms
Retry Behavior.Retries On 500 5610ms
Retry Behavior.Retries On 502 5614ms
Retry Behavior.Retries On 504 5615ms
Retry Behavior.Max Retries Respected 15625ms
Deduplication.Generates Unique Uuids 621ms
Deduplication.Preserves Uuid On Retry 5615ms
Deduplication.Preserves Uuid And Timestamp On Retry 10620ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5618ms
Deduplication.No Duplicate Events In Batch 615ms
Deduplication.Different Events Have Different Uuids 613ms
Compression.Sends Gzip When Enabled 610ms
Batch Format.Uses Proper Batch Structure 610ms
Batch Format.Flush With No Events Sends Nothing 607ms
Batch Format.Multiple Events Batched Together 615ms
Error Handling.Does Not Retry On 403 2624ms
Error Handling.Does Not Retry On 413 2612ms
Error Handling.Retries On 408 5616ms

Feature_Flags Tests

1/1 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 8ms

@marandaneto
Copy link
Copy Markdown
Member

i think codeql is having issues

The job was not acquired by Runner of type hosted even after multiple attempts

@marandaneto marandaneto mentioned this pull request Apr 29, 2026
6 tasks
@marandaneto marandaneto merged commit 5fef84f into main Apr 29, 2026
21 checks passed
@marandaneto marandaneto deleted the flags/sdk-compliance-adapter branch April 29, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants