Skip to content

chore!: remove the didReceiveFeatureFlags notification - #965

Merged
turnipdabeets merged 3 commits into
chore/v4-remove-deprecatedfrom
chore/v4-remove-did-receive-feature-flags
Oct 27, 2026
Merged

turnipdabeets merged 3 commits into
chore/v4-remove-deprecatedfrom
chore/v4-remove-did-receive-feature-flags

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Removes PostHogSDK.didReceiveFeatureFlags in 4.0 in favor of onFeatureFlags(_:) (#897), which does the same job better:

didReceiveFeatureFlags onFeatureFlags(_:)
Scope posted with object: nil for every SDK instance the instance you subscribe on
Data none PostHogFeatureFlagsLoaded: flags, variants, errorsLoading
Stop listening NotificationCenter.removeObserver subscription.unsubscribe()
Before setup() yes yes

The test helper already avoided the notification for the instance problem (see the comment in TestPostHog.swift). The notification was never deprecated; we're skipping the deprecation cycle because 4.0 is a major.

Changes:

  • Remove the notification and the post in PostHogRemoteConfig.notifyFeatureFlags.
  • Move the iOS, SPM and CocoaPods example apps to onFeatureFlags.
  • Drop it from the public API snapshot and add a changeset.

Wrappers: posthog-flutter observed this notification on iOS/macOS; PostHog/posthog-flutter#649 already moves it to onFeatureFlags. The React Native plugin doesn't use it.

💚 How did you test it?

  • swift test --filter 'FeatureFlag|RemoteConfig|Flags' with -DTESTING: 179 tests pass.
  • swift build; PostHogExample and PostHogExampleWithSPM build for iOS. The CocoaPods example wasn't built (no CocoaPods locally); its change matches the SPM example's.
  • swiftformat and swiftlint clean on the changed files.
  • posthog-flutter's example app builds for the iOS simulator against this branch with chore!: adopt posthog-ios 4.0 and posthog-android 4.0 posthog-flutter#649's listener change.

📝 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 the duplicate while comparing the feature flag APIs across the iOS, Android, Flutter and React Native majors, checked that onFeatureFlags covers every case the notification did (it lives on the SDK, survives setup()/close(), and fires on failed loads too), and made the change. No tests were added because removing an API has no new behavior to cover; the existing listener tests cover the replacement.

🤖 Generated with Claude Code

@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 23, 2026 16:59
@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 dcd51a5: 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.

Comment thread PostHogExample/ContentView.swift Resolved
@turnipdabeets
turnipdabeets force-pushed the chore/v4-remove-deprecated branch from 0274681 to ce9e3ac Compare October 23, 2026 17:13
@turnipdabeets
turnipdabeets force-pushed the chore/v4-remove-did-receive-feature-flags branch from 4258589 to 2f19c61 Compare October 23, 2026 17:20
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

posthog-ios Compliance Report

Date: 2026-10-27T17:44:09.301543+00:00
Duration: 233870ms

⚠️ Some Tests Failed

46/47 tests passed, 1 failed


Capture Tests

⚠️ 29/30 tests passed, 1 failed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 3106ms
Format Validation.Event Has Uuid ✅ 2799ms
Format Validation.Event Has Lib Properties ✅ 2875ms
Format Validation.Distinct Id Is String ✅ 2732ms
Format Validation.Token Is Present ✅ 2761ms
Format Validation.Custom Properties Preserved ✅ 462ms
Format Validation.Event Has Timestamp ✅ 2838ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 2822ms
Retry Behavior.Retries On 503 ✅ 11736ms
Retry Behavior.Does Not Retry On 400 ✅ 4912ms
Retry Behavior.Does Not Retry On 401 ✅ 4989ms
Retry Behavior.Respects Retry After Header ✅ 7822ms
Retry Behavior.Implements Backoff ✅ 15492ms
Retry Behavior.Retries On 500 ✅ 9335ms
Retry Behavior.Retries On 502 ✅ 8863ms
Retry Behavior.Retries On 504 ✅ 9335ms
Retry Behavior.Max Retries Respected ❌ 21305ms
Deduplication.Generates Unique Uuids ✅ 2991ms
Deduplication.Preserves Uuid On Retry ✅ 8867ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 16331ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7870ms
Deduplication.No Duplicate Events In Batch ✅ 3034ms
Deduplication.Different Events Have Different Uuids ✅ 2956ms
Compression.Sends Gzip When Enabled ✅ 2970ms
Batch Format.Uses Proper Batch Structure ✅ 2761ms
Batch Format.Flush With No Events Sends Nothing ✅ 442ms
Batch Format.Multiple Events Batched Together ✅ 3120ms
Error Handling.Does Not Retry On 403 ✅ 4883ms
Error Handling.Does Not Retry On 413 ✅ 2533ms
Error Handling.Retries On 408 ✅ 9277ms

Failures

retry_behavior.max_retries_respected

Expected 4 requests, got 6

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 2865ms
Request Payload.Flags Request Uses V2 Query Param ✅ 2877ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 2874ms
Request Payload.Flags Request Omits Authorization Header ✅ 2877ms
Request Payload.Token In Flags Body Matches Init ✅ 2935ms
Request Payload.Groups Round Trip ✅ 2840ms
Request Payload.Groups Default To Empty Object ✅ 2930ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 2912ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 2789ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 2876ms
Request Lifecycle.No Flags Request On Init Alone ✅ 113ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 2865ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 5726ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 2813ms
Retry Behavior.Retries Flags On 502 ✅ 2878ms
Retry Behavior.Retries Flags On 504 ✅ 2950ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 3122ms

onFeatureFlags(_:) covers it: it reports the loaded flags and whether loading failed, is scoped to one SDK instance, and can be unsubscribed. The notification was posted with a nil object for every instance and carried no data.
@turnipdabeets
turnipdabeets force-pushed the chore/v4-remove-deprecated branch from ce9e3ac to 1fb0c40 Compare October 26, 2026 16:28
@turnipdabeets
turnipdabeets force-pushed the chore/v4-remove-did-receive-feature-flags branch from 2f19c61 to 6f99db6 Compare October 26, 2026 16:28
@turnipdabeets turnipdabeets mentioned this pull request Oct 27, 2026
2 of 15 tasks
@turnipdabeets turnipdabeets mentioned this pull request Oct 27, 2026
4 of 6 tasks
@turnipdabeets
turnipdabeets merged commit cf12d63 into chore/v4-remove-deprecated Oct 27, 2026
48 checks passed
@turnipdabeets
turnipdabeets deleted the chore/v4-remove-did-receive-feature-flags branch October 27, 2026 17:53
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