feat: Add get_feature_flag_result, get_feature_flag_result! API#82
feat: Add get_feature_flag_result, get_feature_flag_result! API#82rafaeelaudibert merged 6 commits intomasterfrom
get_feature_flag_result, get_feature_flag_result! API#82Conversation
get_feature_flag_result, get_feature_flag_result! API
posthog-elixir Compliance ReportDate: 2026-02-12 02:59:49 UTC
|
| Test | Status | Duration |
|---|---|---|
| Format Validation.Event Has Required Fields | ✅ | 609ms |
| 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 | ✅ | 608ms |
| 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 | ✅ | 2610ms |
| Retry Behavior.Respects Retry After Header | ❌ | 5614ms |
| Retry Behavior.Implements Backoff | ❌ | 15624ms |
| Retry Behavior.Retries On 500 | ❌ | 5614ms |
| Retry Behavior.Retries On 502 | ❌ | 5615ms |
| Retry Behavior.Retries On 504 | ❌ | 5615ms |
| Retry Behavior.Max Retries Respected | ❌ | 15623ms |
| Deduplication.Generates Unique Uuids | ✅ | 618ms |
| Deduplication.Preserves Uuid On Retry | ❌ | 5614ms |
| Deduplication.Preserves Uuid And Timestamp On Retry | ❌ | 10619ms |
| Deduplication.Preserves Uuid And Timestamp On Batch Retry | ❌ | 5616ms |
| Deduplication.No Duplicate Events In Batch | ✅ | 614ms |
| Deduplication.Different Events Have Different Uuids | ✅ | 611ms |
| Compression.Sends Gzip When Enabled | ❌ | 609ms |
| Batch Format.Uses Proper Batch Structure | ✅ | 609ms |
| Batch Format.Flush With No Events Sends Nothing | ✅ | 606ms |
| Batch Format.Multiple Events Batched Together | ✅ | 614ms |
| Error Handling.Does Not Retry On 403 | ✅ | 2611ms |
| Error Handling.Does Not Retry On 413 | ✅ | 2611ms |
| Error Handling.Retries On 408 | ❌ | 5615ms |
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
compression.sends_gzip_when_enabled
Header 'Content-Encoding' with value 'gzip' not found in requests
error_handling.retries_on_408
Expected at least 2 requests, got 1
rafaeelaudibert
left a comment
There was a problem hiding this comment.
Pushed a couple changes to make this slightly nicer + also added a changesets entry. Make sure you read the CONTRIBUTING section to know how we're handling this here in Elixir. My goal was to move all of the SDKs to this new sampo tooling. Would love if I could get buy-in from the new SDK team btw :)
Problem
When using PostHog feature flags, customers often need both the flag value and its payload. The current Elixir SDK has no way to retrieve payloads at all —
checkonly returns the boolean/variant value. Other SDKs have separategetFeatureFlagPayload()methods that don't fire$feature_flag_calledevents, leading to missing analytics when customers skip callinggetFeatureFlag()first.Per PostHog/posthog#43520, all SDKs are normalizing around a single
get_feature_flag_resultmethod that returns the full flag evaluation (enabled, variant, and payload) and fires the$feature_flag_calledevent in one call.Changes
PostHog.FeatureFlagResultstruct withkey,enabled,variant,payloadfields and avalue/1helper that returns the variant (if present) or the enabled booleanget_feature_flag_resultwhich returns{:ok, %FeatureFlagResult{}},{:ok, nil}(flag not found), or{:error, reason}get_feature_flag_result!, a bang variant that returns the struct directly or raisessend_event: falseoption to suppress the$feature_flag_calledevent and context side-effectsevaluate_flaghelper used by bothcheckandget_feature_flag_resultto eliminate duplicationsend_eventoption