Skip to content

fix: only move the current screen for wrapper events built as $screen - #1012

Merged
turnipdabeets merged 1 commit into
feat/v4-capture-v1from
fix/wrapper-screen-built-name
Nov 3, 2026
Merged

turnipdabeets merged 1 commit into
feat/v4-capture-v1from
fix/wrapper-screen-built-name

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Flutter builds a plain capture(eventName: r'$screen') under another name, because native applies screen() rules to $screen builds, and restores the real name before sending. sendBuiltEventForWrapper only looked at the name at send, so with beforeSend callbacks set, a plain capture moved the current screen and later events got its $screen_name. Without callbacks it doesn't.

Now the current screen only moves when the event was built and sent as $screen. The event itself is still sent as before.

Raised in review: PostHog/posthog-flutter#682 (comment)

💚 How did you test it?

Added a regression test to PostHogWrapperEventTest. It failed before the fix and passes now, with the wrapper suite (20 tests), using swift test --no-parallel -Xswiftc -DTESTING --filter PostHogWrapperEventTest on macOS, not a simulator or device. swiftformat --lint is clean. I didn't run the full suite for this change.

📝 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.

No changeset: sendBuiltEventForWrapper is unreleased, wrapper-only API on this branch.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Claude Code. A wrapper that renames a plain event to $screen also no longer moves the current screen; only posthog-flutter uses this API today. The screen check is separate from the distinct id fix in the sibling PR, and the two don't overlap.

🤖 Generated with Claude Code

@turnipdabeets turnipdabeets self-assigned this Nov 3, 2026
@turnipdabeets
turnipdabeets requested a review from a team as a code owner November 3, 2026 00:37
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

posthog-ios Compliance Report

Date: 2026-11-03T01:05:05.507541+00:00
Duration: 952779ms

✅ All Tests Passed!

233/233 tests passed


Capture_V1 Tests

✅ 106/106 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 2893ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 2863ms
Required Headers.Has Authorization Bearer Header ✅ 400ms
Required Headers.Has Content Type Json ✅ 2736ms
Required Headers.Has Posthog Sdk Info Format ✅ 2777ms
Required Headers.Has Posthog Attempt Header ✅ 2729ms
Required Headers.Has Posthog Request Id ✅ 2844ms
Required Headers.Has Posthog Request Timestamp ✅ 2750ms
Required Headers.Has User Agent ✅ 2811ms
Body Format.Body Has Created At And Batch ✅ 2814ms
Body Format.No Api Key In Body ✅ 2718ms
Body Format.No Sent At In Body ✅ 2735ms
Event Format.Event Has Required Root Fields ✅ 2777ms
Event Format.Event Uuid Is Valid ✅ 2731ms
Event Format.Event Timestamp Is Rfc3339 ✅ 2786ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 2821ms
Event Format.Distinct Id Is String ✅ 2805ms
Event Format.Distinct Id At Root Not Properties ✅ 2812ms
Event Format.Custom Properties Preserved ✅ 2813ms
Event Format.Set Properties Preserved ✅ 356ms
Event Format.Set Once Properties Preserved ✅ 2740ms
Event Format.Groups Properties Preserved ✅ 2657ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 2745ms
Event Format.Event Has Required Root Fields Batch ✅ 2854ms
Event Format.Event Uuid Is Valid Batch ✅ 2869ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 2902ms
Event Format.Distinct Id Is String Batch ✅ 2827ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 2778ms
Event Format.Custom Properties Preserved Batch ✅ 2727ms
Event Format.Set Properties Preserved Batch ✅ 2851ms
Event Format.Set Once Properties Preserved Batch ✅ 2819ms
Event Format.Groups Properties Preserved Batch ✅ 2884ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 2742ms
Batch Behavior.Multiple Events In Single Batch ✅ 2998ms
Batch Behavior.Batch Envelope Smoke ✅ 2873ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 318ms
Batch Behavior.Flush At Triggers Batch ✅ 1167ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 2708ms
Deduplication.Generates Unique Uuids ✅ 2911ms
Deduplication.Different Events Same Content Different Uuids ✅ 2789ms
Deduplication.Preserves Uuid On Retry ✅ 9225ms
Deduplication.Preserves Timestamp On Retry ✅ 9150ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7855ms
Deduplication.No Duplicate Events In Batch ✅ 2870ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 396ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 15745ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 9332ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 4969ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 9331ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 2730ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 2763ms
Response Format Validation.Success No Retry After When All Ok ✅ 2740ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2770ms
Response Format Validation.Success No Retry After When Drop Only ✅ 2839ms
Response Format Validation.Response Echoes Request Id ✅ 398ms
Retry Behavior.Retries On 408 ✅ 9249ms
Retry Behavior.Retries On 500 ✅ 9278ms
Retry Behavior.Retries On 503 ✅ 11620ms
Retry Behavior.Retries On 504 ✅ 5398ms
Retry Behavior.Retries On 404 ✅ 8892ms
Retry Behavior.Retries On 429 ✅ 9327ms
Retry Behavior.Retries On 502 ✅ 8715ms
Retry Behavior.Retryable Errors Have Retry After ✅ 6282ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 8345ms
Retry Behavior.Does Not Retry On 400 ✅ 2322ms
Retry Behavior.Does Not Retry On 401 ✅ 4827ms
Retry Behavior.Does Not Retry On 402 ✅ 4753ms
Retry Behavior.Does Not Retry On 413 ✅ 2409ms
Retry Behavior.Does Not Retry On 415 ✅ 4806ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4794ms
Retry Behavior.Implements Backoff ✅ 12365ms
Partial Batch Handling.Handles 200 Full Success ✅ 4674ms
Partial Batch Handling.Handles 200 With All Ok ✅ 5860ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 5909ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 5900ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7906ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7729ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7872ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7796ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7866ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7784ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7711ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 5838ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 5848ms
Compression.Sends Gzip Content Encoding ✅ 2746ms
Compression.No Content Encoding When Disabled ✅ 2671ms
Compression.Compressed Body Is Decompressible ✅ 2694ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4818ms
Event Options.Cookieless Mode Override ✅ 2815ms
Event Options.Disable Skew Correction Override ✅ 314ms
Event Options.Process Person Profile Override ✅ 2805ms
Event Options.Product Tour Id Override ✅ 2780ms
Event Options.Unset Options Omitted ✅ 2671ms
Event Options.Options Override In Batch ✅ 2757ms
Event Options.Unknown Option Passes Through ✅ 2778ms
Event Options.Option Value Is Not Converted ✅ 293ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 2801ms
Event Options.Option Wins Over Legacy Property ✅ 2803ms
Event Options.Legacy Property Fills Unset Option ✅ 413ms
Event Options.Null Option Falls Back To Legacy Property ✅ 357ms
Property Layers.Caller Property Beats Registered Property ✅ 2761ms
Property Layers.Before Send Runs Last ✅ 2731ms
Fail Open.Empty Api Key Sends Nothing ✅ 1260ms
Fail Open.Personal Api Key Sends Nothing ✅ 1260ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 2854ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 2771ms

Capture_Ai_V1 Tests

✅ 110/110 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 2842ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 348ms
Endpoint And Method.Capture Does Not Reroute Ai Named Events ✅ 2722ms
Endpoint And Method.Capture Ai Does Not Reroute Non Ai Events ✅ 2812ms
Lane Isolation.Failing Ai Lane Does Not Delay Analytics ✅ 11307ms
Required Headers.Has Authorization Bearer Header ✅ 2805ms
Required Headers.Has Content Type Json ✅ 2821ms
Required Headers.Has Posthog Sdk Info Format ✅ 2806ms
Required Headers.Has Posthog Attempt Header ✅ 2694ms
Required Headers.Has Posthog Request Id ✅ 2786ms
Required Headers.Has Posthog Request Timestamp ✅ 2768ms
Required Headers.Has User Agent ✅ 2780ms
Body Format.Body Has Created At And Batch ✅ 2723ms
Body Format.No Api Key In Body ✅ 2811ms
Body Format.No Sent At In Body ✅ 2762ms
Event Format.Event Has Required Root Fields ✅ 2801ms
Event Format.Event Uuid Is Valid ✅ 2754ms
Event Format.Event Timestamp Is Rfc3339 ✅ 2881ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 2838ms
Event Format.Distinct Id Is String ✅ 2910ms
Event Format.Distinct Id At Root Not Properties ✅ 553ms
Event Format.Custom Properties Preserved ✅ 382ms
Event Format.Set Properties Preserved ✅ 2985ms
Event Format.Set Once Properties Preserved ✅ 2889ms
Event Format.Groups Properties Preserved ✅ 2809ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 2830ms
Event Format.Event Has Required Root Fields Batch ✅ 2891ms
Event Format.Event Uuid Is Valid Batch ✅ 2904ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 2902ms
Event Format.Distinct Id Is String Batch ✅ 567ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 3028ms
Event Format.Custom Properties Preserved Batch ✅ 2809ms
Event Format.Set Properties Preserved Batch ✅ 2876ms
Event Format.Set Once Properties Preserved Batch ✅ 2827ms
Event Format.Groups Properties Preserved Batch ✅ 2985ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 611ms
Batch Behavior.Multiple Events In Single Batch ✅ 3103ms
Batch Behavior.Batch Envelope Smoke ✅ 2922ms
Batch Behavior.Flush At Triggers Batch ✅ 1291ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 2974ms
Deduplication.Generates Unique Uuids ✅ 3008ms
Deduplication.Different Events Same Content Different Uuids ✅ 2905ms
Deduplication.Preserves Uuid On Retry ✅ 9189ms
Deduplication.Preserves Timestamp On Retry ✅ 5446ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7933ms
Deduplication.No Duplicate Events In Batch ✅ 3095ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 2846ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 16775ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 9385ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2831ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 5498ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 2870ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 3012ms
Response Format Validation.Success No Retry After When All Ok ✅ 2904ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2902ms
Response Format Validation.Success No Retry After When Drop Only ✅ 2976ms
Response Format Validation.Response Echoes Request Id ✅ 2742ms
Retry Behavior.Retries On 408 ✅ 9263ms
Retry Behavior.Retries On 500 ✅ 9375ms
Retry Behavior.Retries On 503 ✅ 5413ms
Retry Behavior.Retries On 504 ✅ 9182ms
Retry Behavior.Retries On 404 ✅ 9086ms
Retry Behavior.Retries On 429 ✅ 5483ms
Retry Behavior.Retries On 502 ✅ 9298ms
Retry Behavior.Retryable Errors Have Retry After ✅ 2467ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10831ms
Retry Behavior.Does Not Retry On 400 ✅ 4869ms
Retry Behavior.Does Not Retry On 401 ✅ 2503ms
Retry Behavior.Does Not Retry On 402 ✅ 2496ms
Retry Behavior.Does Not Retry On 413 ✅ 4873ms
Retry Behavior.Does Not Retry On 415 ✅ 4875ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4874ms
Retry Behavior.Implements Backoff ✅ 18314ms
Partial Batch Handling.Handles 200 Full Success ✅ 2435ms
Partial Batch Handling.Handles 200 With All Ok ✅ 5990ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 5819ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 5921ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 8026ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 8002ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7969ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7827ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7906ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7930ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7961ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 5921ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 5878ms
Compression.Sends Gzip Content Encoding ✅ 2828ms
Compression.No Content Encoding When Disabled ✅ 3032ms
Compression.Compressed Body Is Decompressible ✅ 3493ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4943ms
Event Options.Cookieless Mode Override ✅ 3030ms
Event Options.Disable Skew Correction Override ✅ 3247ms
Event Options.Process Person Profile Override ✅ 2933ms
Event Options.Product Tour Id Override ✅ 3068ms
Event Options.Unset Options Omitted ✅ 2751ms
Event Options.Options Override In Batch ✅ 563ms
Event Options.Unknown Option Passes Through ✅ 2782ms
Event Options.Option Value Is Not Converted ✅ 406ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 2761ms
Event Options.Option Wins Over Legacy Property ✅ 2804ms
Event Options.Legacy Property Fills Unset Option ✅ 2720ms
Event Options.Null Option Falls Back To Legacy Property ✅ 2755ms
Event Size.Event Over Ceiling Is Not Sent ✅ 4333ms
Event Size.Batches Close Before Byte Target ✅ 8766ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties ✅ 2859ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 2828ms
Property Layers.Caller Property Beats Registered Property ✅ 2794ms
Property Layers.Before Send Runs Last ✅ 416ms
Fail Open.Empty Api Key Sends Nothing ✅ 1337ms
Fail Open.Personal Api Key Sends Nothing ✅ 1366ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 2880ms
Request Payload.Flags Request Uses V2 Query Param ✅ 2874ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 2898ms
Request Payload.Flags Request Omits Authorization Header ✅ 2882ms
Request Payload.Token In Flags Body Matches Init ✅ 3011ms
Request Payload.Groups Round Trip ✅ 2964ms
Request Payload.Groups Default To Empty Object ✅ 3005ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 2764ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 2842ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 2897ms
Request Lifecycle.No Flags Request On Init Alone ✅ 99ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 469ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 5664ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 2892ms
Retry Behavior.Retries Flags On 502 ✅ 3311ms
Retry Behavior.Retries Flags On 504 ✅ 3081ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 2963ms

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good; no qualifying findings. Verdict: correct.

@turnipdabeets
turnipdabeets merged commit 6c70fff into feat/v4-capture-v1 Nov 3, 2026
47 checks passed
@turnipdabeets
turnipdabeets deleted the fix/wrapper-screen-built-name branch November 3, 2026 13:51
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