feat(server): allow a timestamp override on identify - #834
Open
santimillang wants to merge 1 commit into
Open
santimillang wants to merge 1 commit into
santimillang wants to merge 1 commit into
Conversation
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>
This branch has not been deployed
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.
💡 Motivation and Context
Closes #303.
capture()inposthog-serveralready accepts atimestampoverride (#297), butidentify()didn't, so backfilling or replaying identify calls meant hand-building a$identifyevent viacapture.This adds an overload:
PostHogInterface(sealed) gets the new 4-arg abstractidentify; the existing 3-arg one becomes a default that delegates withtimestamp = null, so current callers are unaffected (binary and source).PostHogStateless.identifynow routes through aprotectedidentifyStateless(..., timestamp)that forwards the timestamp tocaptureStateless. Android behavior is unchanged.apiDumpregenerated).sdk-specs: this matches the
identifyspec (openspec/specs/identify/spec.md), which listsoptions.timestamp. Go and Ruby already expose it. The only divergence is shape: the spec sketches an options object, while this follows the existingcapture(..., timestamp)overload style in this SDK. Happy to switch to aPostHogIdentifyOptionsbuilder 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?
PostHogTest:identifywith a timestamp sends a$identifyevent carrying that timestamp and the$setproperties (written first, failed, then passed)../gradlew :posthog:test :posthog-server:test: all pass exceptPostHogServerWireSnapshotTest, which fails identically onmainwhen run on Windows (it compares<project>/...paths againstD:\...), so it's unrelated.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Generated with Claude Code