Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e7c2d09
✨ [feat] add windows and linux support
SnowLukin Sep 29, 2026
7a1510f
🐛 [fix] recover desktop delivery after failures
SnowLukin Sep 29, 2026
43940ba
🐛 [fix] isolate temporary desktop storage
SnowLukin Sep 29, 2026
8fb9bed
🐛 [fix] keep desktop fallback state in memory
SnowLukin Sep 29, 2026
792dd9c
🔧 [chore] sync upstream lifecycle fixes
SnowLukin Oct 2, 2026
bb080a5
🐛 [fix] isolate pending desktop events
SnowLukin Oct 2, 2026
5818b20
🐛 [fix] use platform application support directories
SnowLukin Oct 2, 2026
36ae4d3
📝 [docs] remove unrelated license notice
SnowLukin Oct 2, 2026
177d576
🐛 [fix]: preserve identity after read failures
SnowLukin Oct 2, 2026
4a72018
🐛 [fix]: retain original exception step context
SnowLukin Oct 2, 2026
53e8d33
📝 [docs]: correct desktop storage documentation
SnowLukin Oct 2, 2026
6380774
🐛 [fix]: keep storage contents out of logs
SnowLukin Oct 2, 2026
562e881
📝 [docs]: clarify corrupt storage recovery
SnowLukin Oct 2, 2026
5ae540f
✨ [feat]: send the queue on desktop close
StarProxima Oct 2, 2026
1c84969
🐛 [fix]: keep unawaited captures on desktop before identity changes
StarProxima Oct 2, 2026
35ba860
✨ [feat]: read the Linux time zone from /etc/timezone
StarProxima Oct 2, 2026
70a66d2
📝 [docs]: document close() on Windows and Linux
StarProxima Oct 2, 2026
d1ca23a
🐛 [fix]: deliver events whose callbacks finish during desktop setup
StarProxima Oct 2, 2026
523f0e7
♻️ [refactor]: wait for setup inside the desktop beforeSend helper
StarProxima Oct 2, 2026
c27c586
📝 [docs]: explain the legacy flags response fallback
StarProxima Oct 2, 2026
b8e20eb
✅ [test]: close the desktop platform before deleting its directory
StarProxima Oct 3, 2026
daa5b8b
✅ [test]: run the desktop SDK inside the example app on Windows and L…
StarProxima Oct 3, 2026
266a0f5
🐛 [fix]: drop group flag properties when the group key changes
StarProxima Oct 5, 2026
d1bf679
Merge remote-tracking branch 'upstream/main' into feat/desktop-platfo…
StarProxima Oct 5, 2026
7f1721e
Merge remote-tracking branch 'upstream/main' into feat/desktop-platfo…
StarProxima Oct 5, 2026
ab483d9
chore: merge main into desktop platform support
dustinbyrne Oct 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/desktop-dart-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"posthog_flutter": minor
---

Add Windows and Linux support, set up with the same `Posthog().setup(config)` as the other platforms. Event and screen capture, exception capture (including autocapture of Flutter and Dart errors, and exception steps), identify, alias, groups, super properties, feature flags, bootstrap, opt-out and application lifecycle events work on both. App metadata comes from the executable's `ProductName` and `ProductVersion` on Windows and the bundled `version.json` on Linux. State is stored under `posthog/<project token>` in the application support directory returned by the official Windows/Linux `path_provider` implementations. If the directory is unavailable, state stays in memory and is lost when the SDK closes or the app exits. Events include `$timezone` when the SDK can determine a local IANA time zone; on Windows, this uses the system ICU data on a best-effort basis. Session replay, surveys, logs, push notifications and native crash capture are not supported on Windows and Linux.
93 changes: 92 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
timeout-minutes: 5
working-directory: ./posthog_flutter
run: flutter test --platform chrome test/posthog_flutter_web_handler_test.dart test/posthog_flutter_web_setup_test.dart test/posthog_widget_web_test.dart test/posthog_widget_test.dart test/web_before_send_test.dart test/web_canvas_mask_provider_test.dart
run: flutter test --platform chrome test/posthog_flutter_web_handler_test.dart test/posthog_flutter_web_setup_test.dart test/posthog_widget_web_test.dart test/posthog_widget_test.dart test/web_before_send_test.dart test/web_canvas_mask_provider_test.dart test/posthog_error_tracking_web_test.dart

# dart2js resolves the isolate-handler conditional import differently;
# only a wasm compile exercises the dart2wasm selection this test guards.
Expand All @@ -184,6 +184,97 @@ jobs:
working-directory: ./posthog_flutter
run: flutter test --platform chrome --wasm test/posthog_isolate_error_handler_web_test.dart

test-build-windows:
needs: detect-markdown-only
name: Windows test and build
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'

# axi92/flutter-action is a fork of subosito/flutter-action that SHA-pins its internal
# actions/cache calls; subosito itself uses tag refs which conflicts with our org-wide
# "Require actions to be pinned to a full-length commit SHA" policy. Tracks upstream.
- uses: axi92/flutter-action@36d2c2625bac6ea011cd7808d2a01bd8a7e5c766 # feature/pin-action-sha @ 2026-04-30
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
with:
channel: 'stable'
cache: true

- name: Install dependencies
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: flutter pub get

- name: Test on Windows
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./posthog_flutter
run: flutter test

- name: Build Windows example
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./example
run: flutter build windows --release --build-name=1.2.3 --build-number=456

- name: Test Windows version resource
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./posthog_flutter
run: flutter test --dart-define=POSTHOG_TEST_EXECUTABLE=../example/build/windows/x64/runner/Release/posthog_flutter_example.exe test/posthog_windows_version_resource_test.dart

- name: Integration test on Windows
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./example
run: flutter test integration_test/desktop_test.dart -d windows

test-build-linux:
needs: detect-markdown-only
name: Linux test and build
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Complete markdown-only PR check
if: needs.detect-markdown-only.outputs.markdown_only == 'true'
run: echo "Only Markdown files changed; no additional work is required for this check."
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: needs.detect-markdown-only.outputs.markdown_only != 'true'

- name: Install Linux build dependencies
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: |
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev

# axi92/flutter-action is a fork of subosito/flutter-action that SHA-pins its internal
# actions/cache calls; subosito itself uses tag refs which conflicts with our org-wide
# "Require actions to be pinned to a full-length commit SHA" policy. Tracks upstream.
- uses: axi92/flutter-action@36d2c2625bac6ea011cd7808d2a01bd8a7e5c766 # feature/pin-action-sha @ 2026-04-30
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
with:
channel: 'stable'
cache: true

- name: Install dependencies
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
run: flutter pub get

- name: Test on Linux
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./posthog_flutter
run: flutter test

- name: Build Linux example
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./example
run: flutter build linux --release

- name: Integration test on Linux
if: needs.detect-markdown-only.outputs.markdown_only != 'true'
working-directory: ./example
run: xvfb-run -a flutter test integration_test/desktop_test.dart -d linux

publish-dry-run:
needs: detect-markdown-only
name: Pub publish dry run
Expand Down
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,27 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

The desktop core in posthog_flutter/lib/src/core is derived from PostHog/posthog-js-lite (posthog-core).

Copyright (c) 2022 PostHog (part of Hiberly Inc)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@ Please see the main [PostHog docs](https://posthog.com/docs).

Specifically, the [Flutter docs](https://posthog.com/docs/libraries/flutter) details.

## Desktop support

Windows and Linux support the core analytics SDK. Session replay, surveys,
logs, push notifications, and native crash capture are not supported.

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.](https://posthog.com/posts)
Expand Down
42 changes: 42 additions & 0 deletions api/posthog_flutter.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@
],
"fieldDeclarations": [],
"interfaceDeclarations": [
{
"entryPoints": [
"posthog_flutter_dart.dart"
],
"executableDeclarations": [
{
"entryPoints": [],
"isDeprecated": false,
"isExperimental": false,
"isStatic": true,
"name": "registerWith",
"parameters": [],
"relativePath": "lib/posthog_flutter_dart.dart",
"returnTypeName": "void",
"type": "method",
"typeParameterNames": []
}
],
"fieldDeclarations": [],
"isDeprecated": false,
"isExperimental": false,
"isRequired": false,
"isSealed": false,
"name": "PosthogFlutterDart",
"relativePath": "lib/posthog_flutter_dart.dart",
"superTypeNames": [
"Object"
],
"typeParameterNames": []
},
{
"entryPoints": [
"posthog_flutter_web.dart"
Expand Down Expand Up @@ -5952,6 +5982,18 @@
"iosPlatformConstraints": null,
"minSdkVersion": "3.6.0",
"packageDependencies": [
{
"packageName": "path_provider_linux",
"packageVersion": "^2.2.1"
},
{
"packageName": "path_provider_platform_interface",
"packageVersion": "^2.1.2"
},
{
"packageName": "path_provider_windows",
"packageVersion": "^2.3.0"
},
{
"packageName": "plugin_platform_interface",
"packageVersion": "^2.0.2"
Expand Down
6 changes: 6 additions & 0 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ migration:
- platform: macos
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: windows
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: linux
create_revision: 4cf24164269a5ebf0c16a028a00727d0e77bbb05
base_revision: 4cf24164269a5ebf0c16a028a00727d0e77bbb05

# User provided section

Expand Down
Loading
Loading