posthog_flutter 5.55.0 copy "posthog_flutter: ^5.55.0" to clipboard
posthog_flutter: ^5.55.0 copied to clipboard

Flutter implementation of PostHog client for iOS, Android, macOS, Windows, Linux and Web

Package on pub.dev

PostHog Flutter #

Please see the main PostHog docs.

Specifically, the Flutter docs details.

Desktop support #

Windows and Linux support is experimental and enabled by default. They support the core analytics SDK. Session replay, surveys, logs, push notifications, and native crash capture are not supported.

Apps that call Posthog().setup(config) will start tracking on Windows and Linux. To disable the SDK on these platforms without changing behavior on other platforms, set config.enableWindowsAndLinux = false before setup. Close the SDK before changing this setting and setting up again.

Desktop state is stored under posthog/<project token> in the application support directory returned by Flutter's Windows/Linux path_provider implementations. Keep the application's storage identity stable across releases: Windows uses the company/product metadata, and Linux uses the application ID, with executable-name fallbacks when that metadata is unavailable. On Linux, path_provider also reuses an existing executable-name directory if the application-ID directory does not exist.

Await Posthog().setup(config) to finish initialization. If the application support directory is unavailable, desktop state stays in memory and is lost when the SDK closes or the app exits. If an I/O error prevents reading an existing state file, that client keeps state changes in memory and leaves the file untouched. A new client can try reading the file again. Corrupt file contents reset the state to defaults; the next state write replaces the file.

Posthog().close() makes one attempt to send the queued events and waits for it for up to two seconds. Events it could not send stay on disk and go out with the next client, or are lost when state is kept in memory. Closing the app window does not call close(), but the SDK also sends the queue whenever the app becomes inactive.

Questions? #

Check out our community page. #