Skip to content

19.4.0

Choose a tag to compare

@github-actions github-actions released this 07 Nov 11:37
· 8 commits to master since this release
4e198ba

Customer identity: Gleap.getInstance().setUserJwt(String) identifies the user with one HS256 JWT signed by your backend. The SDK reads userId (or user_id) from the payload without checking the signature and sends the identify with the token as the user hash and no other contact fields; a token that is not three base64url parts, has no user id or is longer than 4096 characters is refused with a log line and nothing is sent. The token stays in memory only (it is never written to the session store) and is sent again whenever it says something new (another claim or key), even when nothing else did (GleapSessionProperties.equals compares the token's kid and claims without iat/exp/nbf/jti, so a token re-minted per app start for the same user and data is not sent again). setUserJwtProvider(GleapUserJwtProvider) fetches a fresh token (callback.onToken(token)) when the server answers token_expired (the identify is retried once) and before the identify is sent again (file session refresh, retry) when the token expires within 5 minutes; one call at a time, 10 second timeout, 30 second pause after a failure. An identify refused with token_expired or token_invalid keeps the session and the user (a warning is logged) instead of starting over as a guest; signature_required and other refusals behave as before (signature_required now logs why). setAuthTokens(Map<String, String>) stores per-user tokens for API tools on the signed contact (POST /sessions/auth-tokens, a null value removes one), keeps them in memory and sends them again after a signed identify on a new session. clearIdentity drops the token and the auth tokens; the provider stays.

Signed sessions: a signed identify (identity token or user hash) answers with a grant (identity.grant), the server-signed session credential. The SDK keeps it in memory and in the session store (SharedPreferences) with its expiry, so an app restart stays signed until it expires, and sends it as the Gleap-Grant header on every request of the session it was issued to (session, identify, contact updates, auth tokens, events, reports, uploads, capture requests and uploads). The messenger gets it as a top-level grant field of session-update, sent again whenever it changes. An identify answered without a grant drops it, clearIdentity drops it, and a grant about to expire is renewed by sending the last signed identify again (through the JWT provider when the token is about to expire too), at most once a minute and when the app comes to the foreground. An identify refused with identity_mismatch (the session belongs to another user) drops the local session, starts a fresh visitor session and sends the identify once more; a second mismatch starts over as a guest. New: setSessionDuration(long) (milliseconds) caps the grant's lifetime and is sent with every identify.

Returning users and short sessions: when the session answer says the project runs Signed (identity.mode: "signed") and the identified session has no grant, the held identify (the app's last identify, or the user hash kept from the last app start) is sent once per app start and session even when nothing changed, so a returning user gets a grant; it is never repeated in a loop, and a refusal of that identify keeps the session. setUserJwt called before Gleap.initialize is kept and sent once the SDK starts (it was dropped). A grant is renewed at min(5 minutes, half its lifetime) before it expires, only the latest renewal stays posted, and a renewal held back by the once-a-minute limit runs once the minute is over. The JWT provider returning an expired token, or the token the server just refused, counts as a failure (30 second pause).