Skip to content

feat(server): allow a timestamp override on identify - #834

Open
santimillang wants to merge 1 commit into
PostHog:mainfrom
santimillang:feat/server-identify-timestamp
Open

santimillang wants to merge 1 commit into
PostHog:mainfrom
santimillang:feat/server-identify-timestamp

Conversation

@santimillang

Copy link
Copy Markdown

💡 Motivation and Context

Closes #303.

capture() in posthog-server already accepts a timestamp override (#297), but identify() didn't, so backfilling or replaying identify calls meant hand-building a $identify event via capture.

This adds an overload:

posthog.identify(distinctId, userProperties, userPropertiesSetOnce, timestamp)
  • PostHogInterface (sealed) gets the new 4-arg abstract identify; the existing 3-arg one becomes a default that delegates with timestamp = null, so current callers are unaffected (binary and source).
  • PostHogStateless.identify now routes through a protected identifyStateless(..., timestamp) that forwards the timestamp to captureStateless. Android behavior is unchanged.
  • The API surface change is additive only (apiDump regenerated).

sdk-specs: this matches the identify spec (openspec/specs/identify/spec.md), which lists options.timestamp. Go and Ruby already expose it. The only divergence is shape: the spec sketches an options object, while this follows the existing capture(..., timestamp) overload style in this SDK. Happy to switch to a PostHogIdentifyOptions builder if you'd prefer.

Note: I'm an external contributor. There's no separate agreement issue beyond #303, but the published spec covers this API.

💚 How did you test it?

  • New test in PostHogTest: identify with a timestamp sends a $identify event carrying that timestamp and the $set properties (written first, failed, then passed).
  • ./gradlew :posthog:test :posthog-server:test: all pass except PostHogServerWireSnapshotTest, which fails identically on main when run on Windows (it compares <project>/... paths against D:\...), so it's unrelated.

📝 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

🤖 Generated with Claude Code

Adds identify(distinctId, userProperties, userPropertiesSetOnce, timestamp)
to the server SDK, matching the timestamp override capture() already has.
Closes PostHog#303.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@santimillang
santimillang requested a review from a team as a code owner October 2, 2026 20:22

This branch has not been deployed

No deployments
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.

Allow timestamp to be set in posthog-server identify calls

1 participant