Skip to content

release: v1.22.21 - #891

Merged
unjica merged 3 commits into
mainfrom
release/v1.22.21
Oct 28, 2026
Merged

unjica merged 3 commits into
mainfrom
release/v1.22.21

Conversation

@unjica

@unjica unjica commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Release v1.22.21

Fixed

  • Stale identity overwrite (TT-031 follow-up): new nullable Session.identity_updated_at (migration 20261028120000_add_identity_updated_at, no backfill). When both stored and incoming session requests carry an identity timestamp, user_id/user_email only change if the incoming one is newer; client timestamps are clamped to server time and to started_at. Requests without the field keep v1.22.20 behavior. Old SDKs (RN 1.3.1 / core 1.5.2) stay affected until apps upgrade to core 1.5.3 / RN 1.3.2 (#890, Refs #886)

Checklist

Sync main into develop after v1.22.20
…follow-up) (#890)

* Fix stale identity overwrite with timestamp-based protection

**Server:** Add identity_updated_at column to Session table. Only update user_id/user_email when incoming timestamp is newer than stored value. Protects against delayed SDK requests overwriting fresher identity data.

**SDK:** Track identity timestamps in telemetry-core. When identify() is called, capture current timestamp and send as identity_updated_at. Old SDKs without this field fall back to started_at as the identity timestamp.

**Tests:** Added regression tests for:
- Stale request arriving after identify() (should be rejected)
- Newer identity overwriting older identity (should succeed)
- Backward compat: old SDK without identity_updated_at (uses started_at)

**Root cause:** RN SDK 1.3.1 sends delayed session requests ~1s after identify(), carrying previous user's ID. With new non-null-wins COALESCE logic from #887, stale requests overwrote correct user. Solution: timestamp-based ordering prevents out-of-order updates.

**Versions:**
- @telemetry-tracker/core: 1.5.2 → 1.5.3
- @telemetry-tracker/react-native: 1.3.1 → 1.3.2

Refs #886

* Address PR #890 review blockers

1. Drop started_at fallback: Only use strict-newer comparison when BOTH stored and incoming have timestamps. Requests without identity_updated_at use #887 behavior (new non-null wins). Old SDKs (1.3.1) remain affected until apps upgrade.

2. Migration: Remove backfill, leave identity_updated_at NULL for existing sessions.

3. Timestamp clamping: Clamp client timestamp to LEAST(client_ts, now()) and bound by started_at to prevent future timestamps and ensure logical ordering.

4. Core init() fix: Preserve identity only if set via identify-before-init (no active session). Clear stale identity from previous sessions. Supports identify-before-init pattern while preventing stale user carryover from re-init scenarios.

5. Tests updated:
   - QA sequence: stale init() first, then identify()
   - Old-SDK identify mid-session (uses #887 behavior)
   - Future timestamp clamping
   - SDK: identify-before-init preservation
   - SDK: re-init clears stale identity

6. CHANGELOG updated to reflect actual behavior and note that old SDKs stay affected.

Root cause confirmed: init() calls startSession() which builds payload with module-level userId before clearing it. With new strict-newer logic and timestamp clamping, this is now properly handled.

Refs #886

* Fix test timing: use past timestamps to avoid clamping to server time

Use timestamps 1 minute in the past for QA sequence test to prevent
clamping to server time when test runs close to 'now'.
@unjica
unjica merged commit 74d0f51 into main Oct 28, 2026
6 checks passed
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.

1 participant