Skip to content

fix: leave eventTime unset until event() sends it - #4

Merged
drkjc merged 3 commits into
mainfrom
event-time-default
Nov 13, 2026
Merged

drkjc merged 3 commits into
mainfrom
event-time-default

Conversation

@drkjc

@drkjc drkjc commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Changes

  • ApiEvent(type, data) leaves eventTime null instead of setting it to the time the object is created
  • When eventTime is null, event() sends the current time without setting it on the caller's ApiEvent, so a reused event gets a fresh time on each call
  • event() sends only type, data and eventTime, so fields added in an ApiEvent subclass aren't sent
  • Add both changes to the 1.0.0 CHANGELOG

Copilot AI balanced review requested due to automatic review settings November 11, 2026 22:13
@drkjc
drkjc requested review from a team, Samy-O7, almalee24, britth, codingit, demostheneslld, drcolburn, kylene-spreedly and naashton and removed request for a team November 11, 2026 22:14

Copilot AI 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.

🟡 Changes recommended

Defaulting a null eventTime by replacing the event with a base ApiEvent drops fields from caller-provided subclasses, causing payload data loss.

1 open issue
What changed in this PR

This PR moves default tracking timestamps from event construction to sending, so reused events receive a fresh timestamp without modifying the caller’s object.

Changes:

  • Leave eventTime null in the two-argument ApiEvent constructor.
  • Apply a default timestamp to a copy when sending an event.
  • Document the behavior and test event reuse and explicit timestamps.
File Description
src/​test/​java/​com/​spreedly/​composer/​ComposerIntegrationTest.java Tests fresh timestamps on reuse and preservation of explicit timestamps.
src/​test/​java/​com/​spreedly/​composer/​api/​ApiTest.java Expects a null timestamp after construction.
src/​main/​java/​com/​spreedly/​composer/​api/​ComposerServices.java Defaults the timestamp on a copy before serialization.
src/​main/​java/​com/​spreedly/​composer/​api/​ApiEvent.java Removes timestamp initialization from the two-argument constructor.
CHANGELOG.md Documents send-time defaulting without caller mutation.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 12, 2026 16:45

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the event timestamp and serialization changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Samy-O7 Samy-O7 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.

Checked before approving, at e8a6bc0: event() no longer changes the caller's ApiEvent, and the constructor no longer sets the time, so a reused event gets a fresh time on each call. It now always sends just type, data and eventTime, like the Python SDK. That settles the subclass case Copilot raised, and the CHANGELOG says so. Checkpoints aren't affected because they use Event. Two of the new tests would fail on main: the constructor's timestamp makes both sends identical, and a subclass's extra field gets sent. I reviewed this by reading the code, without running Java locally. CI passes on Java 11 and 25, and its logs show the new tests ran.

One optional note: in protect-core 1.2.0, eventTime was a Date. It's now a Long in milliseconds, and the CHANGELOG doesn't mention that yet.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 19:30
@drkjc
drkjc merged commit d776a5e into main Nov 13, 2026
6 checks passed
@drkjc
drkjc deleted the event-time-default branch November 13, 2026 19:32

Copilot AI 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.

🟢 Approval recommended

There are no active review issues requiring resolution.

No open issues 🎉

Review effort: Balanced

@Samy-O7 Samy-O7 mentioned this pull request Nov 13, 2026
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.

3 participants