feat(analytics): add trackScreenView and trackScreenLeave public APIs#265
Open
rahul-mixpanel wants to merge 5 commits into
Open
Conversation
…ccessor Add new Autocapture class exposing trackScreenView and trackScreenLeave methods, matching the native Android/Swift SDK pattern (mixpanel.autocapture.trackScreenView/trackScreenLeave). - Dart API: new Autocapture class with lazy getter on Mixpanel - Android plugin: delegates to mixpanel.getAutocapture() - iOS plugin: delegates to instance.autocapture - Web implementation: pure JS with property merging - Bump native SDKs: Android 8.7.0→8.9.0, Swift 6.4.1→6.5.0 - Sample app: MixpanelNavigatorObserver for automatic screen tracking Ref: SDK-120
Add defensive null checks around getAutocapture() in trackScreenView and trackScreenLeave to prevent potential NPE if autocapture is not initialized.
rahul-mixpanel
marked this pull request as ready for review
July 16, 2026 13:49
…wift to 6.5.0 Replace force-unwrap (as! String) with guard let + FlutterError for trackScreenView/trackScreenLeave to prevent crashes on missing screenName. Bump mixpanel-swift SwiftPM dependency from 6.4.1 to 6.5.0 for autocapture support.
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.
Summary
mixpanel.autocapture.trackScreenView(screenName, properties?)andmixpanel.autocapture.trackScreenLeave(screenName, properties?)public APIs, mirroring the native Android/Swift SDK interfacesgetAutocapture().trackScreenView/trackScreenLeave) and iOS/macOS (autocapture.trackScreenView/trackScreenLeave)$mp_page_view/$mp_page_leavewithcurrent_page_titleand$mp_autocaptureproperties)mixpanel-android8.7.0 → 8.9.0, iOS/macOSMixpanel-swift6.4.1 → 6.5.0MixpanelNavigatorObserverfor automatic screen trackingChanges
lib/mixpanel_flutter.dart— NewAutocaptureclass with lazy getter onMixpanelandroid/.../MixpanelFlutterPlugin.java—handleTrackScreenViewandhandleTrackScreenLeavemethodsswift/Classes/SwiftMixpanelFlutterPlugin.swift— Swift handler implementationslib/mixpanel_flutter_web.dart— Web fallback implementationandroid/build.gradle— Bump mixpanel-android to 8.9.0ios/mixpanel_flutter.podspec— Bump Mixpanel-swift to 6.5.0macos/mixpanel_flutter.podspec— Bump Mixpanel-swift to 6.5.0example/lib/main.dart— NavigatorObserver-based screen trackingTest plan
$mp_page_viewand$mp_page_leaveevents fire on navigationcurrent_page_titleand$mp_autocaptureproperties are set by native SDK (not duplicated in Dart layer)Closes SDK-120