posthog_flutter 5.34.0
posthog_flutter: ^5.34.0 copied to clipboard
Flutter implementation of PostHog client for iOS, Android and Web
Next #
5.34.0 #
Minor Changes #
- 0d8b279: Add session replay canvas masking on Flutter web:
maskAllTexts,maskAllImages,PostHogMaskWidget, and obscured text fields now apply to the CanvasKit canvas — enable by declaringsession_recording.canvasCapture.maskRegionsFninposthog.init, or just by mounting aPostHogMaskWidget(requires posthog-js 1.408.0+)
Patch Changes #
- 0d8b279: Fix
maskAllTexts: falsestill maskingTextwidgets whenmaskAllImagesis enabled
5.33.3 #
Patch Changes #
- e835d19: Flutter web (WebAssembly): enabling
captureIsolateErrorsno longer crashes the app at startup. The isolate error handler was selected with adart.library.htmlconditional import, which is false under dart2wasm, so wasm builds compiled thedart:isolateimplementation and threwUnsupported operation: RawReceivePortbeforerunApp— a white screen. The import now keys ondart.library.js_interop(true for both JS and wasm web builds), and the setup guard also skips isolate wiring on web explicitly. JS web builds and mobile/desktop are unaffected.
5.33.2 #
Patch Changes #
- 771e558: Flutter web:
PostHogWidgetno longer runs the mobile session replay screenshot pipeline. On web, session replay is recorded by posthog-js, and every snapshot this pipeline produced was discarded — but it still walked the whole render tree twice per second (once forPostHogMaskWidgetwrappers, once more whenmaskAllTextsormaskAllImagesis on) for as long as the app was open. Web apps that enablesessionReplayand mountPostHogWidgetno longer pay for that. Replay on web is unaffected, andPostHogWidgetstill mounts as before, so it remains safe to keep in a shared widget tree across web and mobile.
5.33.1 #
Patch Changes #
- b9471d4: Session replay: masks every element that matched a masking rule, at any depth. The rect collector only walked two levels of the matched-element tree and dropped any node that had more than one matched child, so with
maskAllTexts/maskAllImagesenabled aPostHogMaskWidgetwrapping several masked children lost its own mask rect, and whatever it wrapped that matched no rule on its own (a decorated container, a chart, a custom-painted avatar) stayed visible in the recording. More of the screen is masked as a result: aPostHogMaskWidgetnow covers its whole subtree, as documented, instead of only the children that matched.
5.33.0 #
Minor Changes #
- 34dde19: Emit Dart error-tracking stack frames in PostHog's canonical bottom-up wire order:
$exception_list[].stacktrace.frames[0]is now the outermost/entry-point frame and the last frame is the crash site (previously innermost-first). Applies to the primary exception and every cause in the chain. Raise the Android SDK floor to 3.56.0 so native Android exceptions use the same canonical order; Apple-native exceptions already do.
5.32.1 #
Patch Changes #
- bbf20fa: Android: session replay screenshots are decoded, re-encoded, and queued off the main thread. Previously each frame cost the main thread 25-75ms on midrange hardware (up to once per second while recording), a visible per-second hitch during scrolling — iOS already did this work on a background queue.
5.32.0 #
Minor Changes #
-
22dbde4: Session replay can now capture native screens that cover the Flutter app (full-screen paywalls, presented view controllers, native activities). Opt in with
captureNativeScreens = true: while a native screen is up, capture is handed to the native PostHog SDK so it becomes visible in replay (requires native SDK support). When enabled but the capture cannot be produced, a black placeholder frame is shown for that screen instead. Off by default — with the flag off nothing is captured or blanked, and replay keeps showing the covered Flutter UI as before. Captured native screens honor your app-widemaskAllTexts/maskAllImagessettings; setting them false reveals native text/images too, including native input fields.Not captured:
- Partial-height sheets (Apple Pay, share sheet,
.pageSheet/.formSheetmodals) - Content rendered by another process (Apple Pay, photo picker) — blank if the surrounding screen is captured
- Android: anything that is not a full activity in your app's process (Chrome Custom Tabs, Google Pay, dialogs, bottom sheets, permission prompts)
- iOS: covers without an opaque background (camera previews, image/blur backdrops)
Screens that are not captured keep the previous behavior: replay keeps showing the covered Flutter UI.
The flag can also be toggled at runtime. Turning it off takes effect immediately: toggling off right before presenting a sensitive native screen guarantees that screen is not captured. Enable it before presenting a screen you want captured — enabling while a native screen is already up may not capture that screen.
Requires posthog-ios >= 3.66.0 and posthog-android >= 3.55.0 (resolved automatically by the bundled dependency ranges).
- Partial-height sheets (Apple Pay, share sheet,
Patch Changes #
- 22dbde4: Android: session replay screenshots are now timestamped with the native SDK's clock instead of the system clock. The two can diverge (the SDK prefers the network-time clock on API 33+), which scrambled the replay timeline — frames appeared at a different time than touch events and native-captured screens.
5.31.0 #
Minor Changes #
- db486b0: Add a
bootstrapoption toPostHogConfigfor pre-seeding identity and feature flags before the first/flagsresponse. Setconfig.bootstrap = PostHogBootstrapConfig(...)beforesetup()so early events carry a caller-controlled distinct ID and flag reads return your values during cold start. The values are forwarded to the native iOS and Android SDKs and mirror thebootstrapoption in posthog-js. On Flutter web, configurebootstrapin yourposthog.initcall instead.
5.30.1 #
Patch Changes #
- d4c7fb8: Require posthog-android 3.54.1 or newer. Earlier 3.x versions performed replay work on every touch (a network-time Binder call, a
MotionEventcopy, and a replay-executor submission) even when session replay was disabled or sampled out, which could cause ANRs on Android. Projects with a Gradle lockfile or cached dependency resolution could stay pinned to an affected version; the raised floor guarantees the fixed SDK.
5.30.0 #
Minor Changes #
- b851632: Improve error-tracking cause handling:
captureExceptionnow walks an error's cause chain (AsyncError, all enumerableParallelWaitErrorfailures, and exceptions exposing acausegetter) into multiple$exception_listitems, outermost-first (wrapper first, root cause last), with a cycle guard and a depth cap of 10.
5.29.0 #
Minor Changes #
- de7b5e8: Platform views are now masked by default in session replay (they now appear as a black box). Use
maskAllPlatformViews = falseto disable masking globally, or wrap individual views inPostHogPlatformView(privacy: PostHogPlatformViewPrivacy.capture)to reveal them selectively.
5.28.0 #
Minor Changes #
-
3fe9ab2: Add
addExceptionStep, recording breadcrumb-style context records that attach to every captured$exceptionas$exception_steps, giving the error-tracking UI a timeline of recent activity leading up to each error.Steps accumulate in a rolling, byte-bounded buffer owned by the embedded native SDK, so they also survive native fatal crashes and attach to the crash
$exceptionreported on the next launch. The buffer rotates only by byte-budget eviction and is not cleared by a capture or an identity change. Configure it onconfig.errorTrackingConfig.exceptionSteps(enabled,maxBytes).Posthog().addExceptionStep('User tapped Checkout', properties: {'screen': 'cart'});Requires
posthog-androidandposthog-iosversions that support exception steps. On web, steps are forwarded to posthog-js, and exceptions captured viacaptureExceptionnow route through posthog-js'scaptureException(instead of a generic$exceptioncapture) so steps and other required metadata attach.
5.27.0 #
Minor Changes #
-
647d48b: Add structured logging. Send logs to PostHog from your Flutter app and see them next to your events and session replays.
Posthog().logger.info('checkout completed', {'order_id': 'ord_789'}); Posthog().logger.error('payment failed', {'error_code': 'E001'}); // Or pick the level at runtime: await Posthog().captureLog(body: 'request finished', level: PostHogLogSeverity.warn);Levels:
trace,debug,info,warn,error,fatal. Configure service identity, redaction (beforeSend), and batching/rate-cap tuning onconfig.logsConfig— all optional, with sensible native defaults. Works on iOS, Android, and web.Requires
posthog-android3.48.0or newer.See https://posthog.com/docs/logs for details.
5.26.0 #
Minor Changes #
-
4749dd4: Add
setPersonPropertiesForFlags,resetPersonPropertiesForFlags,setGroupPropertiesForFlags, andresetGroupPropertiesForFlags, bringing the Flutter SDK to parity with the native iOS/Android and JS SDKs.These set person/group properties that are sent inline with the next feature flag evaluation request, so flags targeting those properties can be evaluated immediately — without enqueuing a
$setevent or waiting for it to be ingested into the person store. By default they reload feature flags and the returnedFuturecompletes only after the reload finishes, so the nextgetFeatureFlag/getFeatureFlagResultreflects the updated properties. PassreloadFeatureFlags: falseto skip the reload.await Posthog().setPersonPropertiesForFlags({ "storefront_country": "US", "superwall_demand_score": 88, }); final result = await Posthog().getFeatureFlagResult("my_flag");
5.25.3 #
Patch Changes #
- 7077816:
reloadFeatureFlags()now resolves itsFutureonly after feature flags have finished loading, instead of returning immediately.await Posthog().reloadFeatureFlags()is now reliable, so reading a flag (or starting session recording) right after a reload sees the up-to-date result.
5.25.2 #
Patch Changes #
- 2c0925e: Fix link-type survey questions with no URL silently failing to render on Android. The deserializer now treats a missing link as an empty string instead of throwing on
null.
5.25.1 #
Patch Changes #
- 06b1569: Skip Flutter SDK setup for blank project tokens before storing config or installing Dart integrations.
5.25.0 #
Minor Changes #
- cfcab97: Support Android builds with AGP 9 built-in Kotlin while preserving compatibility with AGP 8. This release requires Android Gradle Plugin 8.0 or newer.
Patch Changes #
- f9490ed: Raise the minimum
posthog-androidversion to 3.44.0 to guarantee session replay minimum recording duration support.
5.24.2 #
Patch Changes #
- 5c60fb5: Reinstall Flutter error autocapture handlers when re-enabling data collection.
5.23.3 #
Patch Changes #
- 04535db: Trim surrounding whitespace from API keys and host config before passing them to the native SDKs.
5.23.2 #
Patch Changes #
- e9e94d1: Accept Map args in the web session recording start handler
- b55480e: Avoid retaining raw RGBA bytes for session replay diffing
- 4bbfb38: Reduce session replay frame callback overhead
- 3bc8c50: Cancel in-flight session replay screenshot capture when stopping
- 0bdb58c: Prevent overlapping session replay snapshot captures
- d4dcbbe: Dispose native session replay resources on screenshot errors
5.23.1 #
Patch Changes #
- b4532f5: fix: suppress ghost screen events when app is in background
- ac2b568: chore: bump posthog-ios dependency to 3.50.0 for error tracking GA
5.23.0 #
Minor Changes #
-
5e31246: Enable captureApplicationLifecycleEvents by default and align Android config key name.
Application lifecycle events (
Application Opened,Application Backgrounded, etc.) are now captured by default. If you don't want these events, you can disable them:- Dart (recommended): Set
config.captureApplicationLifecycleEvents = falsein your PostHog configuration. - Android (manifest): Add
<meta-data android:name="com.posthog.posthog.CAPTURE_APPLICATION_LIFECYCLE_EVENTS" android:value="false" />to yourAndroidManifest.xml. The legacy keycom.posthog.posthog.TRACK_APPLICATION_LIFECYCLE_EVENTSis still supported. - iOS/macOS (Info.plist): Set
com.posthog.posthog.CAPTURE_APPLICATION_LIFECYCLE_EVENTStoNOin yourInfo.plist.
- Dart (recommended): Set
5.22.0 #
Minor Changes #
- ca19677: Add native exception capture support for Apple platforms (iOS, macOS, tvOS)
5.21.0 #
5.18.0 #
Minor Changes #
- 12a378f: feat(surveys): support survey schedule 'always' to show every time and survey wait period filtering (seenSurveyWaitPeriodInDays)
5.17.1 #
Patch Changes #
- e4b9224: fix: bump iOS SDK minimum to 3.43.0 to fix feature flags race condition between preload and identify
5.17.0 #
Minor Changes #
- 6d13370: Breaking: Minimum Dart SDK version is now 3.6.0 and minimum Flutter version is now 3.27.0. Migrate to pub workspace structure.
5.15.3 #
Patch Changes #
- 541b280: fix: textfield masking and element transform positioning in session replay
5.15.0 #
- fix: add explicit
package:meta/meta.dartimport for@internalannotation (#286) - feat: add
setPersonPropertiesmethod to set person properties without requiringidentify(#284) - fix: add
filled: falseto survey open-text questions to prevent app theme from overriding survey customization values (#285)
5.14.0 #
- feat: add manual session recording control APIs (#256)
startSessionRecording({bool resumeCurrent = true})Start session recording, optionally starting a new sessionstopSessionRecording()Stop the current session recordingisSessionReplayActive()Check if session replay is currently active
- feat: add
getFeatureFlagResultAPI (#279)
5.13.0 #
-
chore: add support for thumbs up/down surveys (#257)
-
perf: Optimize Screenshot diff check (#271)
-
chore: improve survey color handling (#233)
-
feat: add
beforeSendcallback toPostHogConfigfor dropping or modifying events before they are sent to PostHog (#255)- Limitation:
- Does NOT intercept native-initiated events such as:
- Session replay events (
$snapshot) whenconfig.sessionReplayis enabled - Application lifecycle events (
Application Opened, etc.) whenconfig.captureApplicationLifecycleEventsis enabled - Feature flag events (
$feature_flag_called) whenconfig.sendFeatureFlagEventsis enabled - Identity events (
$set) whenidentifyis called - Survey events (
survey shown, etc.) whenconfig.surveysis enabled
- Session replay events (
- Only user-provided properties are available; system properties (like
$device_type,$session_id) are added by the native SDK at a later stage.
- Does NOT intercept native-initiated events such as:
- Limitation:
-
perf: Optimize mask widget rect collection to O(N) (#269)
5.12.0 #
5.11.1 #
- fix: RichText, SelectableText, TextField labels and hints not being masked in session replay (#251)
5.11.0 #
- chore: update languageVersion and apiVersion from 1.8 to 2.0 on Android to be compatible with Kotlin 2.3 (#245)
5.10.0 #
- feat: Add
onFeatureFlagscallback toPostHogConfigto get notified when feature flags are loaded. UsePosthog().getFeatureFlag()orPosthog().isFeatureEnabled()within the callback to access fresh flag values. (#224)
5.9.0 #
- feat: add autocapture exceptions (#214)
- Limitations:
- No Flutter web support
- No native iOS exception capture
- No native C/C++ exception capture on Android (Java/Kotlin only)
- No stacktrace demangling for obfuscated builds (--obfuscate and --split-debug-info) for Dart code and isMinifyEnabled for Java/Kotlin code
- No source code context
- No background isolate error capture
- Limitations:
5.7.0 #
- feat: add manual error capture (#212)
- Note: The following features are not yet supported:
- Automatic exception capture
- De-obfuscating stacktraces from obfuscated builds (--obfuscate and --split-debug-info)
- Source code context associated with an exception
- Flutter web support
- BREAKING: Minimum Dart SDK version bumped to 3.4.0 and Flutter to 3.22.0 (required for
stack_tracedependency compatibility)
- Note: The following features are not yet supported:
5.5.0 #
- chore: Android plugin sets compileSdkVersion to flutter.compileSdkVersion instead of hardcoded (#207)
5.4.0 #
- feat: surveys for Android (#198)
- See how to setup in Surveys docs
5.3.0 #
- chore: update languageVersion and apiVersion from 1.6 to 1.8 on Android to be compatible with Kotlin 2.2 (#193)
5.1.0 #
- feat: surveys for iOS (#188)
- See how to setup in Surveys docs
5.0.0 #
4.10.0 #
- chore: add support for session replay manual masking with the PostHogMaskWidget widget (#153)
4.8.0 #
- chore: change screenshots debouncing approach to throttling (#131)
- Added
throttleDelayconfig and deprecateddebouncerDelayconfig.
- Added
4.7.0 #
- chore: flutter session replay (Android and iOS) (#123)
- Session replay docs, PR pending review
- Thanks @thisames for the PR!
4.6.0 #
4.4.0 #
- chore: Allow overriding the route filtering using a ctor param
routeFilter(#95)
bool myRouteFilter(Route<dynamic>? route) =>
route is PageRoute || route is OverlayRoute;
final observer = PosthogObserver(routeFilter: myRouteFilter);
4.0.0 #
- Android minSdkVersion 21
- iOS min version 13.0
- Flutter min version 3.3.0
- Upgraded PostHog Android SDK to v3
- Upgraded PostHog iOS SDK to v3
- Upgraded PostHog JS SDK to the latest version
- PostHog Flutter Plugins are written in Kotlin and Swift
- Added missing features such as feature flags payloads, debug, and more
4.0.0-beta.1 #
- Record the root view as
root ('/')instead of not recording at all #74 - Do not mutate the given properties when calling capture #74
- Thanks @lukepighetti for the PR!
- Fix
CAPTURE_APPLICATION_LIFECYCLE_EVENTStypo for iOS #74 - Added iOS support for the
DEBUGconfig #74 - Upgrade iOS SDK that fixes missing
Application Openedevents #74
4.0.0-alpha.2 #
- Internal changes only
4.0.0-alpha.1 #
- Migrate to the new SDKs and latest tooling #70
- Added missing features such as feature flags payloads, debug, and more
Breaking changes #
- Android minSdkVersion 21
- iOS min version 13.0
- Flutter min version 3.3.0
- Upgraded PostHog Android SDK to v3
- Upgraded PostHog iOS SDK to v3 preview
- Upgraded PostHog JS SDK to the latest version
- PostHog Flutter Plugins are written in Kotlin and Swift
Acknowledgements #
Thanks @nehemiekoffi for the initial PR!
3.1.0 #
- Adds support for
groups - Fixes a type issue with identify so that the userId is now always a String
3.0.5 #
- Fixes a bug with the iOS implementation for feature flags that stopped the SDK from building
3.0.4 #
- Adds CI/CD for deploying to pub.dev
3.0.0 #
- Adds basic feature flags support with
isFeatureEnabledandreloadFeatureFlags
2.0.3 #
- Bugfixes with flutter web and identify call https://github.com/PostHog/posthog-flutter/pull/16
2.0.2 #
- Update to androidX for example android project
- Fix ios example app and params
- Fix web library, example, and docs
2.0.1 #
- Remove
generated_plugin_registrant.dartfrom library
2.0.0 #
- Migrate to flutter 2
1.11.2 #
- Bump and pin version for Android lib to 1.1.1 because of bug
1.11.1 #
- Bump and pin version for Android lib to 1.1.0
1.11.0 #
- Bump the version for Android lib for screen $screen_name consistency
1.10.0 #
- We will include the last screen that you set in the capture events now.
This will require users to user
Posthog().capture()instead ofPosthog.capture()
1.9.3 #
- Bug fix for android identify method
1.9.2 #
- Rename entire repo from flutter-posthog to posthog-flutter
1.9.1 #
- Some renaming for consistency
1.9.0 #
- PostHog client library for Flutter is released!