Repository navigation
Add user identity (setUserId / logout) - #13
Open
ahsanalidotme wants to merge 1 commit into
Open
ahsanalidotme wants to merge 1 commit into
ahsanalidotme wants to merge 1 commit into
Conversation
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.
Closes linktrail-io/linktrail-backend#112
Backend PR (deploy first, SDKs send userId which older backends reject with 400): https://github.com/linktrail-io/linktrail-backend/pull/139
The backend PR (
POST /v1/events/identify+ optionaluserIdon events) must be deployed before this is released.What
LinkTrail.setUserId(id): Promise<void>,LinkTrail.logout(): Promise<void>,LinkTrail.getUserId(): Promise<string | null>.^[A-Za-z0-9_.:-]{1,128}$; invalid id rejects withcode: 'invalid_user_id', nothing stored/sent.requireConsent: false); revoking clears it on the native side.logout()clears locally, no network call.src/identity.ts(pure TS, injected bridge). Tests:npm test(node:test + tsx; 11 tests: validation, persistence, consent gating, logout, failure swallowing).Design decision and limits
The native SDKs perform all HTTP and own the device id (internal), so the JS layer cannot call
/v1/events/identifyor adduserIdto events itself. I did not depend on unreleased native APIs or bump pins. Instead the wrapper owns identity state and hands the id to the native SDK through a newforwardUserIdbridge method:setUserId(String)/logout()on the SDK, so it compiles againstio.linktrail:sdk:0.0.5and delivers automatically once the pin moves to a release that has them (method names assumed from the issue; must match the other agent's Android PR).forwardUserIdreturnsfalsefor now. Needs a one-line wrapper change when the pod pin moves to a release with identity.Checks
npm run typecheck,npm run lint(0 errors, warnings pre-existing/no-deep-imports),npm run prepare, codegen validation,npm testall pass locally.CI does not run tests; adding
npm testto.github/workflows/ci.ymlis a follow-up (workflow files are not touched here).Unverified
package-lock.jsonchanged only for the newtsxdevDependency.🤖 Generated with Claude Code