Repository navigation
fix: don't write the default event_time back onto the caller's event - #17
Merged
Merged
Conversation
event() set event.event_time when it was empty, so an event object reused for a later call was sent with the first call's timestamp. Use the default for the request only.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the timestamp-handling change.
No open issues 🎉
What changed in this PR
Fixes timestamp handling in the Python SDK’s Composer.event() so reusing a TrackEvent generates a fresh default timestamp without modifying the caller’s object.
Changes:
- Computes the default timestamp locally for each request.
- Adds regression tests for reused events and preservation of caller-provided timestamps.
| File | Description |
|---|---|
| tests/test_composer.py | Adds tests for fresh default timestamps and explicit timestamp preservation. |
| composer/composer.py | Sends a request-local timestamp instead of assigning it to the caller’s event. |
Review effort: Balanced
drkjc
approved these changes
Nov 11, 2026
drkjc
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, the fix and tests are clear. Thanks for the contribution, and the note about the other sdks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
event()fills inevent_timewhen the caller left it empty, but it does that by assigning to the caller'sTrackEvent. If the same event object is sent again later, it already has a timestamp, so the second call goes out with the first call's time.This change computes the default for the request only and leaves the caller's object alone, the same way
__init__copies the config instead of mutating it. A caller-providedevent_timeis still sent unchanged.Tests: added
test_event_does_not_write_default_time_back_to_event(fails on main with[1000000, 1000000] == [1000000, 2000000], passes with the fix) andtest_event_keeps_caller_event_time.pytest(163 passed),ruff format --check composer tests,ruff check composer testsandmypy composerpass locally on Python 3.12.The Node, Ruby and Go server SDKs set the default the same way, so they may want the same change. I used AI assistance while working on this and reviewed and tested the change myself.