Skip to content

chore!: make getFeatureFlagResult follow config.sendFeatureFlagEvent by default - #662

Merged
turnipdabeets merged 1 commit into
chore/v6-posthog-ios-4from
chore/v6-flag-result-send-event-config
Oct 27, 2026
Merged

turnipdabeets merged 1 commit into
chore/v6-posthog-ios-4from
chore/v6-flag-result-send-event-config

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

getFeatureFlagResult() defaulted sendFeatureFlagEvent to true and always passed it to the platform. So an app that set PostHogConfig.sendFeatureFlagEvent = false still captured $feature_flag_called from every getFeatureFlagResult() call, while getFeatureFlag() and isFeatureEnabled() followed the config. On iOS and Android, getFeatureFlagResult(key) follows the config too.

sendFeatureFlagEvent is now bool? and defaults to null, which follows the config on every platform:

  • iOS/macOS: calls getFeatureFlagResult(_:) without the override when sendEvent is missing.
  • Android: passes null to getFeatureFlagResult(key, sendFeatureFlagEvent), which falls back to the config.
  • Web: leaves send_event out, so posthog-js applies its own default.
  • Desktop: the Dart core uses config.sendFeatureFlagEvent.

Pass true or false to override per call, as before. This is breaking only for apps with the config off that relied on getFeatureFlagResult() capturing the event anyway, so it targets 6.0 (#637) alongside #647's rename of this parameter.

💚 How did you test it?

  • flutter analyze, flutter test (1259 pass), dart format --set-exit-if-changed, scripts/check-api-dart.sh (snapshot updated: three bool → bool?).
  • New desktop test: with sendFeatureFlagEvent = false, getFeatureFlagResult() captures nothing, and sendFeatureFlagEvent: true still captures. It fails when the core falls back to true instead of the config.
  • flutter build apk --debug and flutter build ios --simulator --debug for the example app.
  • Not tested on a device.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Claude Opus 5.5) found this while comparing the feature flag APIs across the iOS, Android, Flutter and React Native majors, and made the change. It's one of the flag-parity changes for 6.0. Web keeps posthog-js's default, because the Flutter config isn't applied to the JS SDK there.

🤖 Generated with Claude Code

@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 23, 2026 16:40
@turnipdabeets turnipdabeets self-assigned this Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-10-26 18:44:18 UTC
Duration: 96838ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 149ms
Format Validation.Event Has Uuid ✅ 121ms
Format Validation.Event Has Lib Properties ✅ 117ms
Format Validation.Distinct Id Is String ✅ 115ms
Format Validation.Token Is Present ✅ 117ms
Format Validation.Custom Properties Preserved ✅ 116ms
Format Validation.Event Has Timestamp ✅ 118ms
Retry Behavior.Retries On 503 ✅ 5329ms
Retry Behavior.Does Not Retry On 400 ✅ 2117ms
Retry Behavior.Does Not Retry On 401 ✅ 2117ms
Retry Behavior.Respects Retry After Header ✅ 8126ms
Retry Behavior.Implements Backoff ✅ 15446ms
Retry Behavior.Retries On 500 ✅ 5227ms
Retry Behavior.Retries On 502 ✅ 5224ms
Retry Behavior.Retries On 504 ✅ 5220ms
Retry Behavior.Max Retries Respected ✅ 15435ms
Deduplication.Generates Unique Uuids ✅ 126ms
Deduplication.Preserves Uuid On Retry ✅ 5225ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10336ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5230ms
Deduplication.No Duplicate Events In Batch ✅ 124ms
Deduplication.Different Events Have Different Uuids ✅ 116ms
Compression.Sends Gzip When Enabled ✅ 117ms
Batch Format.Uses Proper Batch Structure ✅ 114ms
Batch Format.Flush With No Events Sends Nothing ✅ 108ms
Batch Format.Multiple Events Batched Together ✅ 125ms
Error Handling.Does Not Retry On 403 ✅ 2117ms
Error Handling.Does Not Retry On 413 ✅ 2118ms
Error Handling.Retries On 408 ✅ 5225ms

Feature_Flags Tests

✅ 16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 13ms
Request Payload.Flags Request Uses V2 Query Param ✅ 9ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 9ms
Request Payload.Flags Request Omits Authorization Header ✅ 10ms
Request Payload.Token In Flags Body Matches Init ✅ 10ms
Request Payload.Groups Round Trip ✅ 10ms
Request Payload.Groups Default To Empty Object ✅ 13ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It ✅ 10ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 9ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 10ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 10ms
Request Lifecycle.No Flags Request On Init Alone ✅ 4ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 113ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 17ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 10ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 116ms

…by default

sendFeatureFlagEvent defaulted to true, so getFeatureFlagResult() captured $feature_flag_called even when PostHogConfig.sendFeatureFlagEvent was false, unlike getFeatureFlag(), isFeatureEnabled() and the native SDKs. It's now nullable, and null follows the config on every platform.
@turnipdabeets
turnipdabeets force-pushed the chore/v6-flag-result-send-event-config branch from 00c9684 to 8cc312b Compare October 26, 2026 18:37

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good; no qualifying findings. Verdict: correct.

@turnipdabeets
turnipdabeets merged commit ef96460 into chore/v6-posthog-ios-4 Oct 27, 2026
25 checks passed
@turnipdabeets
turnipdabeets deleted the chore/v6-flag-result-send-event-config branch October 27, 2026 13:56
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