Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .changeset/v6-major-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
- **Breaking:** remove `Posthog().getFeatureFlagPayload()` — use `getFeatureFlagResult(key, sendFeatureFlagEvent: false)` and read `payload`
- **Breaking:** remove the `PostHogSessionReplayConfig.debouncerDelay` setter — use `throttleDelay`
- **Breaking:** remove `PostHogDataMode.cellular` — use `PostHogDataMode.any`
- **Breaking:** make `beforeSend` and `logsConfig.beforeSend` callbacks synchronous — load what they need ahead of time instead of using `await`
- Keep a `reset()`, `identify()` or `optOut()` made right after an un-awaited `capture()`, `screen()` or `captureException()` from applying to that event first, and stop dropping that event on Windows and Linux
- **Breaking:** remove `toMap()` from the config classes and `PostHogFeatureFlagResult.fromMap()` from the public API
- **Breaking:** rename `enable()` and `disable()` to `optIn()` and `optOut()` on `PosthogFlutterPlatformInterface`, `PosthogFlutterIO` and `PosthogFlutterWeb`
- Declare Android `minSdkVersion` 23 to match `posthog-android`
10 changes: 5 additions & 5 deletions api/posthog_flutter.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@
"isRequired": false,
"name": "beforeSend",
"relativePath": "lib/src/posthog_config.dart",
"typeName": "List<FutureOr<PostHogEvent?> Function(PostHogEvent)>?"
"typeName": "List<PostHogEvent? Function(PostHogEvent)>?"
}
],
"relativePath": "lib/src/posthog_config.dart",
Expand Down Expand Up @@ -2626,7 +2626,7 @@
"isWriteable": true,
"name": "beforeSend",
"relativePath": "lib/src/posthog_config.dart",
"typeName": "List<FutureOr<PostHogEvent?> Function(PostHogEvent)>"
"typeName": "List<PostHogEvent? Function(PostHogEvent)>"
}
],
"isDeprecated": false,
Expand Down Expand Up @@ -3440,7 +3440,7 @@
"isWriteable": true,
"name": "beforeSend",
"relativePath": "lib/src/posthog_config.dart",
"typeName": "List<FutureOr<PostHogLogRecord?> Function(PostHogLogRecord)>"
"typeName": "List<PostHogLogRecord? Function(PostHogLogRecord)>"
}
],
"isDeprecated": false,
Expand Down Expand Up @@ -6118,7 +6118,7 @@
],
"typeAliasDeclarations": [
{
"aliasedTypeName": "FutureOr<PostHogEvent?> Function(PostHogEvent)",
"aliasedTypeName": "PostHogEvent? Function(PostHogEvent)",
"entryPoints": [
"posthog_flutter.dart"
],
Expand All @@ -6128,7 +6128,7 @@
"relativePath": "lib/src/posthog_config.dart"
},
{
"aliasedTypeName": "FutureOr<PostHogLogRecord?> Function(PostHogLogRecord)",
"aliasedTypeName": "PostHogLogRecord? Function(PostHogLogRecord)",
"entryPoints": [
"posthog_flutter.dart"
],
Expand Down
20 changes: 20 additions & 0 deletions posthog_flutter/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ config.dataMode = PostHogDataMode.any;

They serialized the internal platform-channel format and have no replacement. `toMap()` is gone from `PostHogConfig`, `PostHogBootstrapConfig`, `PostHogLogsConfig`, `PostHogRageClickConfig`, `PostHogSessionReplayConfig`, `PostHogErrorTrackingConfig` and `PostHogExceptionStepsConfig`. To build a result, for example in a test, call the `PostHogFeatureFlagResult` constructor, which stays public.

### `beforeSend` callbacks are synchronous

`BeforeSendCallback` is now `PostHogEvent? Function(PostHogEvent)`, and `BeforeSendLogCallback` is `PostHogLogRecord? Function(PostHogLogRecord)`. An `async` callback is a compile error. Load what it needs ahead of time and read it synchronously.

```dart
// Before
config.beforeSend = [
(event) async {
final allowed = await loadAllowList();
return allowed.contains(event.event) ? event : null;
},
];

// After
final allowed = await loadAllowList();
config.beforeSend = [
(event) => allowed.contains(event.event) ? event : null,
];
```

### Platform interface changes

These affect only code that calls, extends or fakes `PosthogFlutterPlatformInterface`, `PosthogFlutterIO` or `PosthogFlutterWeb` directly, such as test mocks. `Posthog().optIn()` and `optOut()` are unaffected.
Expand Down
Loading
Loading