Skip to content

fix: send batch sent_at in snake case#676

Merged
marandaneto merged 3 commits into
mainfrom
fix/use-snake-case-sent-at
Jun 18, 2026
Merged

fix: send batch sent_at in snake case#676
marandaneto merged 3 commits into
mainfrom
fix/use-snake-case-sent-at

Conversation

@marandaneto

@marandaneto marandaneto commented Jun 18, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Python SDK batch requests currently send the top-level client submission timestamp as sentAt, but the batch ingestion backend reads sent_at. As a result, the backend ignores the value and skips clock-skew correction that depends on the batch-level sent timestamp.

This includes a patch changeset for pypi/posthog.

💚 How did you test it?

  • uv run pytest posthog/test/test_request.py -q

📝 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 sampo add to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

This PR was authored with Pi. The backend batch endpoint was cross-checked and found to deserialize sent_at, so the SDK was updated to emit the backend-supported snake_case field. A parameterized regression test ensures sent_at is present and the old sentAt key is absent. The changeset targets pypi/posthog.

@marandaneto marandaneto self-assigned this Jun 18, 2026
@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
posthog/test/test_request.py:114-130
**Test not parameterised**

The team rule prefers parameterised tests. The two assertions here — `"sent_at"` must be present and `"sentAt"` must be absent — are independent enough to express as a `@pytest.mark.parametrize` table, which also makes it easy to extend the key allow/deny list without duplicating the mock setup.

Reviews (1): Last reviewed commit: "fix: send batch sent_at in snake case" | Re-trigger Greptile

Comment thread posthog/test/test_request.py Outdated
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-06-18 12:31:04 UTC
Duration: 540099ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 517ms
Format Validation.Event Has Uuid 10007ms
Format Validation.Event Has Lib Properties 10007ms
Format Validation.Distinct Id Is String 10007ms
Format Validation.Token Is Present 10007ms
Format Validation.Custom Properties Preserved 10007ms
Format Validation.Event Has Timestamp 10006ms
Retry Behavior.Retries On 503 18020ms
Retry Behavior.Does Not Retry On 400 12003ms
Retry Behavior.Does Not Retry On 401 10008ms
Retry Behavior.Respects Retry After Header 16014ms
Retry Behavior.Implements Backoff 32028ms
Retry Behavior.Retries On 500 16001ms
Retry Behavior.Retries On 502 16010ms
Retry Behavior.Retries On 504 16011ms
Retry Behavior.Max Retries Respected 32027ms
Deduplication.Generates Unique Uuids 9992ms
Deduplication.Preserves Uuid On Retry 16016ms
Deduplication.Preserves Uuid And Timestamp On Retry 23019ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 16005ms
Deduplication.No Duplicate Events In Batch 10002ms
Deduplication.Different Events Have Different Uuids 10007ms
Compression.Sends Gzip When Enabled 10007ms
Batch Format.Uses Proper Batch Structure 10007ms
Batch Format.Flush With No Events Sends Nothing 5005ms
Batch Format.Multiple Events Batched Together 10005ms
Error Handling.Does Not Retry On 403 12009ms
Error Handling.Does Not Retry On 413 10008ms
Error Handling.Retries On 408 14013ms

Feature_Flags Tests

16/16 tests passed

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

@marandaneto marandaneto force-pushed the fix/use-snake-case-sent-at branch from 954f92b to dd14841 Compare June 18, 2026 09:05
@marandaneto marandaneto changed the title fix: Send batch sent_at in snake case fix: send batch sent_at in snake case Jun 18, 2026
@marandaneto marandaneto marked this pull request as ready for review June 18, 2026 09:06
@marandaneto marandaneto requested a review from a team as a code owner June 18, 2026 09:06
@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "address pr review feedback" | Re-trigger Greptile

@ioannisj

Copy link
Copy Markdown

CI is not happy here?

@marandaneto

Copy link
Copy Markdown
Member Author

CI is not happy here?

blocked by #677 which is now merged and ok

@marandaneto marandaneto enabled auto-merge (squash) June 18, 2026 12:28
@marandaneto marandaneto merged commit bdcd251 into main Jun 18, 2026
30 checks passed
@marandaneto marandaneto deleted the fix/use-snake-case-sent-at branch June 18, 2026 12:31
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