Sessions¶
Part of the Human Scoring use case.
A session is the stretch of interaction a classification
is about. The SDK starts one at init. Tell the SDK when a session ends in a way only your app
knows about — a logout or an account switch — so that one user's interaction is never counted toward
the next user's classification.
When to use it¶
- The user logs out
- The user switches accounts
- You need the current session id, for example to log it beside your own records
Prerequisites¶
- The SDK is installed and initialized. See the Quick Start.
Usage¶
Start a new session¶
reset() ends the current session and starts a new one with a new id. Evidence collected before
the reset does not count toward the new session's classification. Consent is not affected.
Read the current session¶
const info = await Dea.getSessionInfo();
console.log(info.session); // current session id, a UUID
console.log(info.sdk); // { version, core }
console.log(info.device); // { runtime, os, surface, pixelRatio, rotation, maxTouchPoints, sensorRate }
Shut the SDK down¶
dispose() stops capture and releases the SDK. After dispose(), calls reject as they do before
init, until init is called again, which starts a new session.
Examples¶
Reset on logout¶
import * as Dea from '@dea/react-native';
import {authService} from './auth';
export async function logout(navigation: {reset: (state: object) => void}) {
await authService.signOut();
await Dea.reset();
navigation.reset({index: 0, routes: [{name: 'Login'}]});
}
API¶
| Member | Returns | Description |
|---|---|---|
reset() |
Promise<void> |
Ends the session and starts a new one |
getSessionInfo() |
Promise<Record<string, unknown>> |
Session id, device and SDK version |
dispose() |
Promise<void> |
Stops capture and releases the SDK |