Skip to content

fix(flags): surface that preloadFeatureFlags is ignored on Flutter web - #509

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/preload-feature-flags-web-parity
Draft

fix(flags): surface that preloadFeatureFlags is ignored on Flutter web#509
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/preload-feature-flags-web-parity

Conversation

@posthog

@posthog posthog Bot commented Jul 30, 2026

Copy link
Copy Markdown

💡 Motivation and Context

Customers told to set preloadFeatureFlags = false to cut feature-flag request volume see no change on Flutter web. On web, posthog-js is initialized by the host app, so the option (like bootstrap) never reaches the JS SDK — it is a silent no-op. bootstrap at least documents this; preloadFeatureFlags said nothing, so the recommended workaround reads as "the flag didn't work" on the web half of a customer's traffic.

This makes the gap visible rather than silent:

  • Web setup() now emits a debug-build warning when preloadFeatureFlags is false (pointing at advanced_disable_feature_flags_on_first_load in posthog.init) or when bootstrap is set.
  • preloadFeatureFlags docs carry the same Flutter web: not applied note bootstrap already has.
  • identify() and group() docs now say they reload feature flags, so turning preloading off alone does not remove those requests.

Scope note: this does not change request volume on iOS/Android. The bigger win the ticket describes — a cached-flags freshness window so a cold open serves persisted flags instead of refetching — lives in posthog-ios/posthog-android with a passthrough option here, and is not attempted in this PR.

💚 How did you test it?

Added posthog_flutter/test/posthog_flutter_web_setup_test.dart (browser-only) covering: warning emitted when preloadFeatureFlags is false, no warning on the default, and the bootstrap warning.

I was not able to run the test suite or the analyzer — no Flutter toolchain is available in the environment this was authored in, so the tests are unverified and CI is the first real run. Please treat the test as needing a green CI before merge. The rest of the change is doc comments plus two guarded printIfDebug calls.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • Ran pnpm changeset equivalent (changeset file added by hand)

🤖 Agent context

Autonomy: Fully autonomous

Authored by Claude (PostHog Code) from a Signals inbox report about feature-flag request volume. Checked for competing work first — the only open PRs are session replay and surveys work, and no open issue matched.

Decision made along the way: the report's headline fix (a cached-flags freshness window) cannot be implemented in this repo, so this PR deliberately covers only the Flutter-web silent no-op, and adds a runtime warning rather than docs alone so the misconfiguration is discoverable without reading dartdoc.


Created with PostHog Desktop from this inbox report.

posthog-js is initialized by the host app on web, so PostHogConfig.preloadFeatureFlags never reaches it. Setting it to false was a silent no-op.

- Warn in debug builds during web setup when preloadFeatureFlags is false (pointing at advanced_disable_feature_flags_on_first_load) or when bootstrap is set.
- Document the web gap on preloadFeatureFlags, mirroring the note bootstrap already carries.
- Document that identify() and group() reload feature flags regardless of preloadFeatureFlags.

Generated-By: PostHog Code
Task-Id: b8ef6da1-fe3d-47ac-9901-7406d300f36a
@github-actions

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-07-30 17:16:17 UTC
Duration: 96782ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 137ms
Format Validation.Event Has Uuid 118ms
Format Validation.Event Has Lib Properties 114ms
Format Validation.Distinct Id Is String 114ms
Format Validation.Token Is Present 115ms
Format Validation.Custom Properties Preserved 116ms
Format Validation.Event Has Timestamp 115ms
Retry Behavior.Retries On 503 5328ms
Retry Behavior.Does Not Retry On 400 2117ms
Retry Behavior.Does Not Retry On 401 2116ms
Retry Behavior.Respects Retry After Header 8120ms
Retry Behavior.Implements Backoff 15442ms
Retry Behavior.Retries On 500 5224ms
Retry Behavior.Retries On 502 5224ms
Retry Behavior.Retries On 504 5223ms
Retry Behavior.Max Retries Respected 15440ms
Deduplication.Generates Unique Uuids 124ms
Deduplication.Preserves Uuid On Retry 5222ms
Deduplication.Preserves Uuid And Timestamp On Retry 10334ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5229ms
Deduplication.No Duplicate Events In Batch 126ms
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 123ms
Error Handling.Does Not Retry On 403 2116ms
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 10ms
Request Payload.Flags Request Hits Flags Path Not Decide 9ms
Request Payload.Flags Request Omits Authorization Header 9ms
Request Payload.Token In Flags Body Matches Init 10ms
Request Payload.Groups Round Trip 9ms
Request Payload.Groups Default To Empty Object 10ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 9ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 9ms
Request Payload.Disable Geoip Omitted Defaults To False 9ms
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 112ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 16ms
Request Lifecycle.Mock Response Value Is Returned To Caller 9ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 115ms

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.

0 participants