Repository navigation
feat: add captureFeatureView and captureFeatureInteraction - #667
Merged
turnipdabeets merged 4 commits intoOct 26, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 0e7ffd8: 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.
Contributor
posthog-flutter Compliance ReportDate: 2026-10-26 17:39:50 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
ioannisj
approved these changes
Oct 26, 2026
Look up the flag and start the capture in one guard callback, so an un-awaited captureFeatureView/captureFeatureInteraction followed by reset() can't send the event and $set to the next user.
posthog-js has no current screen and these events skip Posthog.capture(), the only place the Dart side adds $screen_name, so on web they were the one platform without it. The web plugin now remembers the last screen() until close(), like the facade, and adds it to both events. The event shape moves to a helper shared with desktop; the platform interface default goes back to UnimplementedError since every platform now overrides it.
6 tasks done
Feature events took the raw screen() name even when beforeSend renamed or dropped the $screen event. Store the final name of an accepted screen event instead, as desktop's registerForSession does.
turnipdabeets
deleted the
feat/flutter-capture-feature-view-interaction
branch
October 26, 2026 17:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Adds
Posthog().captureFeatureView(flag, {flagVariant})andPosthog().captureFeatureInteraction(flag, {flagVariant}), matching posthog-ioscaptureFeatureView(flag:flagVariant:)/captureFeatureInteraction(flag:flagVariant:)and the posthog-android equivalents.Event shape (same on every platform):
$feature_view/$feature_interactionfeature_flag: <flag>, plusfeature_flag_variant: <variant>when the variant is a string$set: {"$feature_view/<flag>": <variant>}(or$feature_interaction/<flag>)When
flagVariantis omitted, the variant is the flag's current value (variant ?? enabled), read without capturing$feature_flag_called.PostHogSDK.shared.captureFeatureView/Interaction(flag:flagVariant:)(posthog-ios 3.47.0+, floor is 3.72.0)PostHog.captureFeatureView/Interaction(flag, flagVariant)(posthog-android 3.32.1+, floor is 3.61.0)PosthogFlutterPlatformInterface:getFeatureFlagResult(sendEvent: false), thencapture()with the shape above. posthog-js has no such API in the browser SDK (only the@posthog/reactPostHogFeaturehelper, which builds the same shape)No native version floor bumps needed.
🤔 Open questions for review
@posthog/reactfall back totrue. Mobile keeps each native SDK's behavior. Desktop and web follow iOS and skip. The dartdoc spells out the difference. If we'd rather follow Android/React, it's a one-line change.beforeSend: on desktop and web the event goes throughcapture(), so DartbeforeSendcallbacks see it. On iOS/Android the native SDK captures it directly, so DartbeforeSenddoesn't, the same as other native-generated events like$feature_flag_called.💚 How did you test it?
$feature_flag_called), method-channel arguments, web mapping to posthog-jsgetFeatureFlagResult+capturewith$set, andPosthogforwarding.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 --debugandflutter build ios --simulator --debuginexample/succeed.flutter test --platform chromeon the web handler tests: the new test passes. Threeapp versiontests fail locally onmaintoo (they rely on Flutter 3.47+ build defines; local Flutter is 3.44.1).📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code implemented this as the third of four feature-flag parity PRs. The event shape was taken from posthog-ios
captureFeatureEvent, posthog-androidPostHog.kt, and@posthog/reactPostHogFeature.tsx. Commits are signed.🤖 Generated with Claude Code