Skip to content

chore!: remove serialization helpers from the public API - #646

Merged
turnipdabeets merged 1 commit into
chore/v6-posthog-ios-4from
chore/v6-hide-serialization
Oct 7, 2026
Merged

turnipdabeets merged 1 commit into
chore/v6-posthog-ios-4from
chore/v6-hide-serialization

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #637 (v6).

toMap() on PostHogConfig, PostHogBootstrapConfig, PostHogLogsConfig, PostHogRageClickConfig, PostHogSessionReplayConfig, PostHogErrorTrackingConfig and PostHogExceptionStepsConfig, plus PostHogFeatureFlagResult.fromMap(), are the platform-channel wire format, not a data shape for app code. For example, toMap() writes sendFeatureFlagEvents for the sendFeatureFlagEvent field. Because they're public, they're in the API snapshot and we'd have to keep them stable. A GitHub code search turned up no external callers. v6 is the place to drop them.

What changed:

  • The seven toMap() methods are now extensions, and fromMap is now a top-level featureFlagResultFromMap(). Both live in lib/src/utils/channel_serialization.dart, which lib/posthog_flutter.dart doesn't export. The map bodies are unchanged.
  • posthog_flutter_io.dart, posthog_flutter_web.dart and the tests import that file.
  • The PostHogFeatureFlagResult constructor stays public.
  • Added a v6 changeset entry, and regenerated api/posthog_flutter.api.json. The only removals are the seven toMap entries and fromMap.

Judgment calls:

  • Why not @internal? The snapshot tool keeps @internal members (Posthog.config and currentScreen are still listed). Making the methods _private doesn't work either, because they're called from other libraries. Extensions in a file that isn't exported take them out of the API surface.
  • Private access: only PostHogLogsConfig.toMap() used a private member, the static helper _wholeSeconds. It moved into the extension with it. Every other field it reads, such as host, screenshotScale and screenshotCompressionQuality, has a public getter. posthog_config.dart no longer needs its util/logging.dart import. That import was only there for the bootstrap flag-type warning, which moved too.
  • fromMap as a top-level function: a Dart extension can't add a static member that callers reach as PostHogFeatureFlagResult.fromMap. I also removed the redundant result == null check, since result is! Map already covers null.
  • I added a new changeset file rather than editing v6-remove-5x-deprecations.md, so this doesn't conflict with the parallel platform opt-in/opt-out PR. That PR also regenerates the API snapshot, so whichever PR lands second needs to regenerate it again.

💚 How did you test it?

  • flutter analyze: no issues. This covers posthog_flutter_web.dart.
  • flutter test: all 781 tests passed. The existing toMap/fromMap tests now run against the internal versions.
  • dart format --set-exit-if-changed ./: clean.
  • scripts/check-api-dart.sh --update: grepping the snapshot for toMap, fromMap, Serialization and featureFlagResultFromMap returns 0 matches.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Made with Claude Code. Anna chose the approach (unexported extensions instead of @internal) after checking that the API snapshot keeps @internal members.

🤖 Generated with Claude Code

toMap() on the config classes and PostHogFeatureFlagResult.fromMap()
are the platform-channel wire format, not a user-facing data shape.
Move them to extensions and a top-level function in an unexported
src/utils/channel_serialization.dart so they drop out of the public API.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@turnipdabeets turnipdabeets self-assigned this Oct 7, 2026
@turnipdabeets
turnipdabeets marked this pull request as ready for review October 7, 2026 15:51
@turnipdabeets
turnipdabeets requested a review from a team as a code owner October 7, 2026 15:51
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-10-07 15:53:28 UTC
Duration: 96850ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 144ms
Format Validation.Event Has Uuid ✅ 119ms
Format Validation.Event Has Lib Properties ✅ 117ms
Format Validation.Distinct Id Is String ✅ 114ms
Format Validation.Token Is Present ✅ 114ms
Format Validation.Custom Properties Preserved ✅ 117ms
Format Validation.Event Has Timestamp ✅ 117ms
Retry Behavior.Retries On 503 ✅ 5334ms
Retry Behavior.Does Not Retry On 400 ✅ 2117ms
Retry Behavior.Does Not Retry On 401 ✅ 2117ms
Retry Behavior.Respects Retry After Header ✅ 8126ms
Retry Behavior.Implements Backoff ✅ 15446ms
Retry Behavior.Retries On 500 ✅ 5228ms
Retry Behavior.Retries On 502 ✅ 5226ms
Retry Behavior.Retries On 504 ✅ 5226ms
Retry Behavior.Max Retries Respected ✅ 15446ms
Deduplication.Generates Unique Uuids ✅ 125ms
Deduplication.Preserves Uuid On Retry ✅ 5226ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10333ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5229ms
Deduplication.No Duplicate Events In Batch ✅ 125ms
Deduplication.Different Events Have Different Uuids ✅ 116ms
Compression.Sends Gzip When Enabled ✅ 116ms
Batch Format.Uses Proper Batch Structure ✅ 113ms
Batch Format.Flush With No Events Sends Nothing ✅ 109ms
Batch Format.Multiple Events Batched Together ✅ 125ms
Error Handling.Does Not Retry On 403 ✅ 2117ms
Error Handling.Does Not Retry On 413 ✅ 2117ms
Error Handling.Retries On 408 ✅ 5224ms

Feature_Flags Tests

✅ 16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 14ms
Request Payload.Flags Request Uses V2 Query Param ✅ 9ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 10ms
Request Payload.Flags Request Omits Authorization Header ✅ 10ms
Request Payload.Token In Flags Body Matches Init ✅ 10ms
Request Payload.Groups Round Trip ✅ 11ms
Request Payload.Groups Default To Empty Object ✅ 9ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It ✅ 10ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 9ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 10ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 10ms
Request Lifecycle.No Flags Request On Init Alone ✅ 5ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 113ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 16ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 9ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 115ms

@turnipdabeets
turnipdabeets merged commit 5fced53 into chore/v6-posthog-ios-4 Oct 7, 2026
19 of 23 checks passed
@turnipdabeets
turnipdabeets deleted the chore/v6-hide-serialization branch October 7, 2026 18:49
turnipdabeets added a commit that referenced this pull request Oct 7, 2026
toMap() on the config classes and PostHogFeatureFlagResult.fromMap()
are the platform-channel wire format, not a user-facing data shape.
Move them to extensions and a top-level function in an unexported
src/utils/channel_serialization.dart so they drop out of the public API.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@turnipdabeets turnipdabeets mentioned this pull request Oct 7, 2026
5 tasks done
turnipdabeets added a commit that referenced this pull request Oct 8, 2026
toMap() on the config classes and PostHogFeatureFlagResult.fromMap()
are the platform-channel wire format, not a user-facing data shape.
Move them to extensions and a top-level function in an unexported
src/utils/channel_serialization.dart so they drop out of the public API.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants