Please see the main PostHog docs.
Specifically, the Flutter docs details.
Upgrading from posthog_flutter 5.x.x? See the migration guide.
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, and for the queue's files for up to two more. Events it
could not send stay on disk and go out with the next client, or are lost when
state is kept in memory. Events are written in the background, so await
close() before calling exit(). Awaiting a capture or identify call also
keeps that call's event. Closing the app window does not call close(), but the
SDK also sends the queue whenever the app becomes inactive.