Skip to content

test: verify SDK timestamps use UTC - #185

Merged
marandaneto merged 1 commit into
mainfrom
fix/normalize-utc-timestamps
Aug 14, 2026
Merged

test: verify SDK timestamps use UTC#185
marandaneto merged 1 commit into
mainfrom
fix/normalize-utc-timestamps

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

PostHog.bare_capture/3 adds an SDK-generated event timestamp in UTC. This test protects that behavior while confirming that a DateTime supplied as an event property keeps its original time zone offset.

The regression test captures an event with an Asia/Kathmandu property. It verifies that the generated event timestamp ends in Z and parses with a zero UTC offset. It also verifies that the captured property remains the original DateTime value and that JSON encoding produces 2024-01-02T03:04:05.678+05:45 for that property.

💚 How did you test it?

  • mix test test/posthog_test.exs - 28 tests passed.
  • mix test - 332 tests passed and 18 integration tests were excluded.
  • mix format --check-formatted test/posthog_test.exs
  • git diff --check origin/main...HEAD

📝 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

No changeset was added because this PR only adds regression coverage and does not release a product change.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Pi's worker agent preserved the existing test-only change, ran the repository tests, and completed an isolated autoreview. The task was kept to regression coverage with no production or release metadata changes. A shareable agent session link was not available in this environment.

@marandaneto marandaneto self-assigned this Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

posthog-elixir Compliance Report

Date: 2026-08-14 06:10:23 UTC
Duration: 117648ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 611ms
Format Validation.Event Has Uuid 609ms
Format Validation.Event Has Lib Properties 610ms
Format Validation.Distinct Id Is String 610ms
Format Validation.Token Is Present 610ms
Format Validation.Custom Properties Preserved 610ms
Format Validation.Event Has Timestamp 610ms
Retry Behavior.Retries On 503 5615ms
Retry Behavior.Does Not Retry On 400 2613ms
Retry Behavior.Does Not Retry On 401 2613ms
Retry Behavior.Respects Retry After Header 5616ms
Retry Behavior.Implements Backoff 15626ms
Retry Behavior.Retries On 500 5615ms
Retry Behavior.Retries On 502 5616ms
Retry Behavior.Retries On 504 5616ms
Retry Behavior.Max Retries Respected 15626ms
Deduplication.Generates Unique Uuids 622ms
Deduplication.Preserves Uuid On Retry 5615ms
Deduplication.Preserves Uuid And Timestamp On Retry 10621ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5617ms
Deduplication.No Duplicate Events In Batch 614ms
Deduplication.Different Events Have Different Uuids 613ms
Compression.Sends Gzip When Enabled 609ms
Batch Format.Uses Proper Batch Structure 609ms
Batch Format.Flush With No Events Sends Nothing 608ms
Batch Format.Multiple Events Batched Together 614ms
Error Handling.Does Not Retry On 403 2613ms
Error Handling.Does Not Retry On 413 2613ms
Error Handling.Retries On 408 5616ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 610ms
Request Payload.Flags Request Uses V2 Query Param 610ms
Request Payload.Flags Request Hits Flags Path Not Decide 609ms
Request Payload.Flags Request Omits Authorization Header 609ms
Request Payload.Token In Flags Body Matches Init 611ms
Request Payload.Groups Round Trip 609ms
Request Payload.Groups Default To Empty Object 610ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 609ms
Request Payload.Disable Geoip Omitted Defaults To False 610ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 609ms
Request Lifecycle.No Flags Request On Init Alone 5ms
Request Lifecycle.No Flags Request On Normal Capture 607ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 1214ms
Request Lifecycle.Mock Response Value Is Returned To Caller 611ms
Retry Behavior.Retries Flags On 502 914ms
Retry Behavior.Retries Flags On 504 911ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 1213ms

@marandaneto
marandaneto marked this pull request as ready for review August 14, 2026 08:44
@marandaneto
marandaneto requested a review from a team as a code owner August 14, 2026 08:44
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown

Reviews (1): Last reviewed commit: "test: verify SDK timestamps use UTC" | Re-trigger Greptile

@arnohillen arnohillen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(created by claude code)

[arno's agent] Verified at a77ca8c: test-only; the SDK's only emission path is DateTime.utc_now() |> to_iso8601() and the public API accepts no user timestamp, so the offset-conversion requirement has no surface here.

@marandaneto
marandaneto merged commit 6956a32 into main Aug 14, 2026
31 checks passed
@marandaneto
marandaneto deleted the fix/normalize-utc-timestamps branch August 14, 2026 11:18
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