Skip to content

fix: drop session debug keys from Windows and Linux events - #733

Open
ioannisj wants to merge 3 commits into
mainfrom
fix/drop-replay-debug-keys-when-off
Open

ioannisj wants to merge 3 commits into
mainfrom
fix/drop-replay-debug-keys-when-off

Conversation

@ioannisj

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

On Windows and Linux the Dart core adds $sdk_debug_session_start and $sdk_debug_current_session_duration to every event (posthog_flutter/lib/src/core/posthog_core.dart). Those platforms have no session replay, so replay is always off there. The spec says an SDK with replay intentionally off sends only $recording_status: disabled from the replay debug keys, and no SDK sends the duration key at all. posthog-js does the same: with replay off it sends only $recording_status.

Spec: PostHog/sdk-specs#232 (posthog-flutter compliance note n28).

Removes both keys from the Dart core. $sdk_debug_pending_queue_size stays, and it still wins over a registered super property. iOS, macOS, Android and web are unchanged.

💚 How did you test it?

  • posthog_flutter/test/core/posthog_core_test.dart: both keys are absent on custom events, and the queue size is still 0, then 1 over a registered value.
  • posthog_flutter/test/posthog_flutter_desktop_test.dart: $identify and a custom event carry $recording_status: disabled and neither key.
  • flutter test in posthog_flutter passes, and dart analyze and dart format are clean.

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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

DRI: @ioannisj
Autonomy: Human-driven (agent-assisted)

@ioannisj ioannisj self-assigned this Nov 18, 2026
@posthog

posthog Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PostHog Review · Deep · reviewed adc06a6

Nothing to post.

Step Status Result
Prepare the diff done 2 files, 1 chunk
Pick perspectives done 1 perspective
Run review passes done 0 issues
Merge overlapping findings done 0 → 0
Validate findings done
Publish done Nothing to post

Salad Fingers holds a rusty spoon

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-11-20 20:21:55 UTC
Duration: 96581ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 133ms
Format Validation.Event Has Uuid ✅ 115ms
Format Validation.Event Has Lib Properties ✅ 112ms
Format Validation.Distinct Id Is String ✅ 113ms
Format Validation.Token Is Present ✅ 112ms
Format Validation.Custom Properties Preserved ✅ 113ms
Format Validation.Event Has Timestamp ✅ 114ms
Retry Behavior.Retries On 503 ✅ 5327ms
Retry Behavior.Does Not Retry On 400 ✅ 2115ms
Retry Behavior.Does Not Retry On 401 ✅ 2114ms
Retry Behavior.Respects Retry After Header ✅ 8122ms
Retry Behavior.Implements Backoff ✅ 15428ms
Retry Behavior.Retries On 500 ✅ 5222ms
Retry Behavior.Retries On 502 ✅ 5222ms
Retry Behavior.Retries On 504 ✅ 5218ms
Retry Behavior.Max Retries Respected ✅ 15440ms
Deduplication.Generates Unique Uuids ✅ 118ms
Deduplication.Preserves Uuid On Retry ✅ 5220ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10330ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5226ms
Deduplication.No Duplicate Events In Batch ✅ 118ms
Deduplication.Different Events Have Different Uuids ✅ 113ms
Compression.Sends Gzip When Enabled ✅ 113ms
Batch Format.Uses Proper Batch Structure ✅ 111ms
Batch Format.Flush With No Events Sends Nothing ✅ 107ms
Batch Format.Multiple Events Batched Together ✅ 122ms
Error Handling.Does Not Retry On 403 ✅ 2114ms
Error Handling.Does Not Retry On 413 ✅ 2114ms
Error Handling.Retries On 408 ✅ 5221ms

Feature_Flags Tests

✅ 16/16 tests passed

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

@ioannisj
ioannisj marked this pull request as ready for review November 18, 2026 17:49
@ioannisj
ioannisj requested a review from a team as a code owner November 18, 2026 17:49
@veria-ai

veria-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@turnipdabeets turnipdabeets left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this matches the spec: the duration key is banned everywhere, and Windows/Linux don't ship replay so session start isn't owed either. Queue size staying is right too.

[nit] posthog_core.dart:147-148: the comment "it may start a new session, which the debug properties below then describe" is stale now that no debug property describes the session. Fine to just drop those two lines.

}
expect(queuedProps(storage, 0)[r'$sdk_debug_pending_queue_size'], 0);
expect(queuedProps(storage, 1)[r'$sdk_debug_pending_queue_size'], 1,
reason: 'SDK debug values win over a registered super property');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] Not from this PR, but the spec says it the other way round: a registered super property overrides the SDK's $sdk_debug_* value, and a caller-supplied one overrides both (session-replay-debug-properties/spec.md, "Caller-supplied event properties take precedence"). _enrichProperties writes the queue size after ...props, so ours wins. Moving it ahead of ...props and flipping this assertion would line it up. Happy for that to be a follow-up if you'd rather keep this one small.

@ioannisj ioannisj Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right, _enrichProperties writes $sdk_debug_pending_queue_size last so it beats both super and caller props. posthog-js does the same today, and so do posthog-ios and posthog-android 3.x. The reorder (PostHog/sdk-specs#143 and #155) ships with the capture v1 majors, and v6 already has it in the Dart core (#637), so I'll leave 5.x as is rather than have desktop diverge from the native SDKs.

@ioannisj

Copy link
Copy Markdown
Contributor Author

Dropped the stale comment in 243a9c4.

…-keys-when-off

# Conflicts:
#	posthog_flutter/lib/src/core/posthog_core.dart
#	posthog_flutter/test/core/posthog_core_test.dart

This branch has not been deployed

No deployments
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.

3 participants