Skip to content

feat: add per-call sendFeatureFlagEvent to getFeatureFlag and isFeatureEnabled - #666

Merged
turnipdabeets merged 2 commits into
mainfrom
feat/flutter-flag-send-event-override
Oct 26, 2026
Merged

turnipdabeets merged 2 commits into
mainfrom
feat/flutter-flag-send-event-override

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Adds an optional bool? sendFeatureFlagEvent to Posthog().getFeatureFlag(key) and Posthog().isFeatureEnabled(key), matching posthog-ios getFeatureFlag(_:sendFeatureFlagEvent:) / isFeatureEnabled(_:sendFeatureFlagEvent:) and posthog-android getFeatureFlag(key, sendFeatureFlagEvent: Boolean?) / isFeatureEnabled(key, sendFeatureFlagEvent: Boolean?).

  • null (default): follows PostHogConfig.sendFeatureFlagEvent, so existing calls behave exactly as before.
  • true / false: overrides the config for that call.

No defaultValue parameter, since iOS has none. The per-platform handling of null mirrors #662 (which does the same for getFeatureFlagResult on the 6.0 branch):

Platform null true / false
iOS/macOS calls the overload without the parameter getFeatureFlag(_:sendFeatureFlagEvent:) / isFeatureEnabled(_:sendFeatureFlagEvent:) (posthog-ios 3.37.0+, floor is 3.72.0)
Android passes null passes the value (posthog-android 3.28.0+, floor is 3.61.0)
Windows/Linux Dart core falls back to the config Dart core uses the value
Web omits send_event {send_event: <value>} to posthog-js getFeatureFlag / isFeatureEnabled

No native version floor bumps needed. The method-channel argument is named sendEvent, same as getFeatureFlagResult uses.

getFeatureFlagResult keeps its existing sendEvent parameter on main; the 6.0 branch already renames it to sendFeatureFlagEvent (#647), so the new parameter uses the 6.0 name from the start.

💚 How did you test it?

  • New tests: desktop end-to-end against the local fake server (false skips $feature_flag_called for both methods; config off + null skips it, true captures it), method-channel arguments for null/true/false, web handler mapping to posthog-js options, and Posthog forwarding.
  • flutter analyze, flutter test, dart format --set-exit-if-changed lib test, scripts/check-api-dart.sh (snapshot updated), ktlint and swiftformat lint all pass.
  • flutter build apk --debug and flutter build ios --simulator --debug in example/ succeed.
  • flutter test --platform chrome on the web handler tests: the new tests pass. Three app version tests fail locally on main too (they rely on Flutter 3.47+ build defines; local Flutter is 3.44.1).
  • Not tested on a device or simulator at runtime.

📝 Checklist

  • 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 implemented this as the second of four feature-flag parity PRs. Native signatures were checked against posthog-ios and posthog-android main, and the posthog-js FeatureFlagOptions.send_event option. Note for reviewers: adding an optional named parameter to PosthogFlutterPlatformInterface.getFeatureFlag / isFeatureEnabled means any third-party subclass that overrides them must add the parameter. Commits are signed.

🤖 Generated with Claude Code

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

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 45e6615: 1 Should fix.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-10-26 17:59:48 UTC
Duration: 96732ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

✅ 29/29 tests passed

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

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 ✅ 8ms
Request Payload.Flags Request Omits Authorization Header ✅ 9ms
Request Payload.Token In Flags Body Matches Init ✅ 8ms
Request Payload.Groups Round Trip ✅ 8ms
Request Payload.Groups Default To Empty Object ✅ 9ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It ✅ 8ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 7ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 9ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 8ms
Request Lifecycle.No Flags Request On Init Alone ✅ 4ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 111ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 15ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 9ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 113ms

@turnipdabeets
turnipdabeets enabled auto-merge (squash) October 26, 2026 17:50
@turnipdabeets
turnipdabeets force-pushed the feat/flutter-flag-send-event-override branch from 451c373 to a6213ab Compare October 26, 2026 17:54
@turnipdabeets
turnipdabeets merged commit cec2fc3 into main Oct 26, 2026
29 of 30 checks passed
@turnipdabeets
turnipdabeets deleted the feat/flutter-flag-send-event-override branch October 26, 2026 18:10
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