▸ triggerAction(action, options?, locationConfig?, customAttributes?): Promise<TSSetActionResponse>
Reports a user action event and returns an action token. The action token should be passed to your backend to fetch risk recommendations via the Recommendation API.
| Name | Type | Description |
|---|---|---|
action | string | TSAction | The type of user action to report |
options? | TSActionEventOptions | Additional context for the action event |
locationConfig? | Object | Controls location data collection for this action (see Track geolocation) |
locationConfig.mode | string | One of "disabled", "default", "forceCurrent", "forceLastKnown", "lastKnown" |
locationConfig.validFor? | number | For "lastKnown" mode, return location only if not older than this many minutes |
customAttributes? | Record<string, any> | Additional contextual data for the action; must match the schema defined in the Portal (see Custom attributes) |
Promise<TSSetActionResponse>
import { triggerAction, TSAction, TSClaimedUserIdType } from 'react-native-ts-accountprotection';
const response = await triggerAction(
TSAction.login,
{
correlationId: "CORRELATION_ID",
claimedUserId: "91e25bea0c...", // hashed email
claimedUserIdType: TSClaimedUserIdType.email,
referenceUserId: "REFERENCE_USER_ID"
},
{ mode: "default" },
{ userLevel: "premium" }
);
const actionToken = response.actionToken;▸ setAuthenticatedUser(userId): Promise<boolean>
Sets the user context for all subsequent events in the session (or until the user is explicitly cleared). It should be called only after you've fully authenticated the user (including, for example, any 2FA that was required).
| Name | Type | Description |
|---|---|---|
userId | string | Opaque identifier of the user in your system |
Promise<boolean>
Indicates if the call succeeded
import { setAuthenticatedUser } from 'react-native-ts-accountprotection';
await setAuthenticatedUser(username);▸ clearUser(): Promise<boolean>
Clears the user context for all subsequent events in the mobile session. The user is automatically cleared once the session expires or in case of a new login action.
Promise<boolean>
Indicates if the call succeeded
import { clearUser } from 'react-native-ts-accountprotection';
await clearUser();▸ getSessionToken(): Promise<string>
Returns a device session token that can be used to trigger action events via the Backend API. The session token binds user interactions to their device and is required for backend integrations. Call this after SDK initialization and before triggering events.
Promise<string>
The session token.
import { getSessionToken } from 'react-native-ts-accountprotection';
const sessionToken = await getSessionToken();▸ logPageLoad(pageName): Promise<void>
Tracks screen navigation events for behavioral data collection. Call this whenever the user navigates to a new screen in your app.
| Name | Type | Description |
|---|---|---|
pageName | string | The name of the screen or page the user navigated to |
Promise<void>
import { logPageLoad } from 'react-native-ts-accountprotection';
await logPageLoad("login-page");
await logPageLoad("dashboard");▸ setLogLevel(isLogEnabled): Promise<void>
Enables or disables verbose SDK logging for debugging purposes.
| Name | Type | Description |
|---|---|---|
isLogEnabled | boolean | Set to true to enable debug logging |
Promise<void>