Skip to content

fix: stop duplicating distinct_id in flags person properties#195

Draft
marandaneto wants to merge 2 commits into
mainfrom
fix/remove-flags-person-distinct-id
Draft

fix: stop duplicating distinct_id in flags person properties#195
marandaneto wants to merge 2 commits into
mainfrom
fix/remove-flags-person-distinct-id

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

/flags requests already send distinct_id at the top level. Automatically copying the same value into person_properties.distinct_id sends duplicated identity data and differs from the desired payload shape.

This PR keeps the top-level distinct_id and stops automatically injecting it into person_properties. Caller-provided person properties are still forwarded.

💚 How did you test it?

  • vendor/bin/phpunit (tests passed; command exited 1 because PHPUnit reported no coverage driver plus warnings/deprecations)

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

This was implemented with pi in dedicated git worktrees. I changed the /flags request construction so SDKs keep the top-level distinct_id while no longer auto-copying it into person_properties; explicit caller-provided person_properties['distinct_id'] values are still preserved where covered.

@marandaneto marandaneto self-assigned this Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

posthog-php Compliance Report

Date: 2026-07-01 15:15:43 UTC
Duration: 95120ms

⚠️ Some Tests Failed

43/45 tests passed, 2 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 12ms
Format Validation.Event Has Uuid 6ms
Format Validation.Event Has Lib Properties 6ms
Format Validation.Distinct Id Is String 6ms
Format Validation.Token Is Present 6ms
Format Validation.Custom Properties Preserved 6ms
Format Validation.Event Has Timestamp 5ms
Retry Behavior.Retries On 503 5316ms
Retry Behavior.Does Not Retry On 400 2010ms
Retry Behavior.Does Not Retry On 401 2009ms
Retry Behavior.Respects Retry After Header 8012ms
Retry Behavior.Implements Backoff 15729ms
Retry Behavior.Retries On 500 5115ms
Retry Behavior.Retries On 502 5115ms
Retry Behavior.Retries On 504 5115ms
Retry Behavior.Max Retries Respected 16530ms
Deduplication.Generates Unique Uuids 12ms
Deduplication.Preserves Uuid On Retry 5113ms
Deduplication.Preserves Uuid And Timestamp On Retry 10318ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5117ms
Deduplication.No Duplicate Events In Batch 11ms
Deduplication.Different Events Have Different Uuids 8ms
Compression.Sends Gzip When Enabled 5ms
Batch Format.Uses Proper Batch Structure 6ms
Batch Format.Flush With No Events Sends Nothing 3ms
Batch Format.Multiple Events Batched Together 10ms
Error Handling.Does Not Retry On 403 2008ms
Error Handling.Does Not Retry On 413 2010ms
Error Handling.Retries On 408 5115ms

Feature_Flags Tests

⚠️ 14/16 tests passed, 2 failed

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

Failures

request_payload.request_with_person_properties_device_id

Field 'distinct_id' not found in /flags request body at path 'person_properties.distinct_id'. Available keys: ['$device_id']

request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it

Field 'distinct_id' not found in /flags request body at path 'person_properties.distinct_id'. Available keys: ['email']

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown

Comments Outside Diff (1)

  1. lib/Client.php, line 2088-2094 (link)

    P2 The $distinctId parameter is no longer read anywhere in the function body, making it a superfluous parameter (violates simplicity rule 4). All three call sites still pass it, adding noise and leaving a trap for future readers who might expect it to influence the output. The parameter and all three call sites should be cleaned up together.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "fix: stop duplicating distinct_id in fla..." | Re-trigger Greptile

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.

1 participant