feat: add posthog_dart package and restructure to multi-package monorepo#313
Draft
marandaneto wants to merge 20 commits intomainfrom
Draft
feat: add posthog_dart package and restructure to multi-package monorepo#313marandaneto wants to merge 20 commits intomainfrom
marandaneto wants to merge 20 commits intomainfrom
Conversation
- Move posthog-dart SDK into workspace as posthog_dart package - Add Dart-based platform implementation for Linux/Windows (PosthogFlutterDart) - Move PostHogFeatureFlagResult to posthog_dart as shared type - Restructure examples: example/ → examples/flutter_example/ + examples/dart_example/ - Adapt release process, CI, and changeset config for multi-package
posthog_dart doesn't use any features beyond Dart 3.6 (sealed classes are from Dart 3.0). The ^3.11.0 constraint was just whatever the original author had installed.
All platforms are supported: iOS/Android/macOS via method channels, web via JS interop, Linux/Windows via posthog_dart. The function was always returning true, making every check dead code. Replaced the two web-specific guards in error tracking with kIsWeb.
…ndows example support - Run dart format on all posthog_dart files - Fix dartPluginClass registration: export PosthogFlutterDart from main library with conditional import (stub on web, real on dart:io platforms) - Add Linux and Windows desktop support to flutter example app - Remove isSupportedPlatform checks (already done) cleanup
The path dependency on posthog_dart is expected during development and is converted to a versioned dependency before publishing by the bump-version script.
The Dart workspace resolution automatically resolves posthog_dart: ^0.1.0 to the local workspace copy. This removes the invalid_dependency warning and the bump-version.sh hack to convert path→version before publishing.
…share PostHogPersonProfiles - posthog_dart: PostHogCoreOptions → PostHogConfig, PersonProfiles → PostHogPersonProfiles - posthog_flutter: class renamed to PostHogFlutterConfig with typedef PostHogConfig = PostHogFlutterConfig for backwards compat - PostHogPersonProfiles re-exported from posthog_dart (single source of truth) - PostHogFlutterConfig.toCoreConfig() converts Flutter config to core config - Removed _mapPersonProfiles() mapping function from dart platform impl
- Replace disabled/defaultOptIn with optOut in PostHogConfig (dart) - Add debug field to PostHogConfig (dart) - auto-enables debug logging - PostHogFlutterConfig.toCoreConfig() now maps optOut and debug directly - Update examples and tests for new field names
- Move BeforeSendCallback (FutureOr-based) and PostHogEvent to posthog_dart - Remove CaptureEvent and BeforeSendFn from posthog_dart (replaced by unified types) - Remove duplicate PostHogEvent class from posthog_flutter (re-export from dart) - PostHogEvent now has: uuid, event, properties, userProperties, userPropertiesSetOnce, timestamp (superset of both old types) - posthog_dart beforeSend now supports async callbacks (FutureOr) - Sync callbacks still execute synchronously (no unnecessary Future wrapping) - posthog_flutter re-exports BeforeSendCallback and PostHogEvent from posthog_dart
…vent PostHogConfig changes: - flushInterval: int (ms) → Duration (default: 10s) - requestTimeout: int (ms) → Duration (default: 10s) - featureFlagsRequestTimeoutMs: int? → featureFlagsRequestTimeout: Duration? - remoteConfigRequestTimeoutMs: int → remoteConfigRequestTimeout: Duration (default: 3s) - sessionExpirationTimeSeconds: int → sessionExpiration: Duration (default: 30min) - fetchRetryDelay: int (ms) → Duration (default: 3s) - sendFeatureFlagEvent → sendFeatureFlagEvents (matches Flutter naming) - shutdown(timeoutMs:) → shutdown(timeout:) Duration param Internal changes: - All internal int ms fields converted to Duration - retriable() retryDelay changed from int to Duration - Timer/timeout calls use Duration directly instead of wrapping ints
- featureFlagsRequestTimeout: Duration? → Duration (default: 10s) - disableGeoip: bool? → bool (default: false) - Remove withDefaults() from PostHogConfig (no longer needed) - Remove ?? fallbacks in PostHogCore and PostHogCoreStateless
- flushInterval: 10s → 30s (match Flutter) - maxBatchSize: 100 → 50 (match Flutter)
uuid is now a non-nullable String that auto-generates a UUIDv7 if not explicitly provided. Callers no longer need to handle null uuids.
…stHogEvent properties Non-nullable values are the correct contract — property values should always be non-null. Also removed now-redundant .cast<String, Object>() calls in Flutter platform implementations.
- Copy LICENSE to posthog_dart/ and posthog_flutter/ - Copy README.md to posthog_flutter/ - Add .pubignore to both packages to exclude test/, package.json, etc. - Both packages now pass pub publish --dry-run
1961a41 to
adea3c0
Compare
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.
💡 Motivation and Context
Adds the
posthog_dartpure Dart SDK as a new package within this workspace, enabling PostHog support on Linux and Windows platforms via Flutter.What this PR does:
depends on #312
PosthogFlutterDartclass that wrapsposthog_dartfor Linux/Windows, registered as adartPluginClassin pubspec.yamlPostHogFeatureFlagResulttoposthog_dartas the single source of truth, re-exported fromposthog_flutterFeatureFlagResult→PostHogFeatureFlagResultandFeatureFlagResultOptions→PostHogFeatureFlagResultOptions** for consistent namingexample/→examples/flutter_example/+examples/dart_example/RELEASING.mdto handle independent versioning and publishing of both packagesNew platform support:
posthog_dartSDK directly (no native method channels)💚 How did you test it?
posthog_fluttertests passposthog_darttests passdart analyzeclean (only pre-existing example app infos and expected path dependency warning)flutter pub getresolves successfully across the full workspace📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset filereleaselabel to the PR