The drs module allows you to integrate Fraud Prevention services into your application.
When the SDK is initialized, it automatically starts to collect and submit telemetry data to Mosaic—including information of the user journey using various JS events, browser data, and user interactions. Once specific user actions are performed on the client side (such as login), this SDK module should be called in order to track those action events. The data collected by the SDK can then be queried for recommendations using Recommendations backend API.
Loads the SDK:
<script src="https://platform-websdk.transmitsecurity.io/platform-websdk/1.x/ts-platform-websdk.js" id="platform-sdk"></script>To initialize, activate the following code:
import { drs } from '@transmitsecurity/platform-web-sdk';
// Initialize an instance of the Fraud Prevention SDK
// If SDK was loaded via script tag, invoke functions inside 'window.tsPlatform'
await initialize({
clientId: 'my-client-id',
drs: {
serverPath: 'https://api.transmitsecurity.io/risk-collect/' // US region, global
}});Customizations:
| Name | Type | Description |
|---|---|---|
serverPath | string | (Required) The Fraud Prevention module can be configured to work with a different cluster or proxy by setting serverPath to https://api.transmitsecurity.io/risk-collect/ (for US, global), https://api.eu.transmitsecurity.io/risk-collect/ (for EU) or https://api.ca.transmitsecurity.io/risk-collect/ (for Canada). For the SDK modules to work properly together, the regions must match. |
enableSessionToken | boolean | When set to true, generates a session token required for reporting action events from the backend. See getSessionToken(). |
▸ clearUser(options?): Promise<boolean>
Clears the user context for all subsequent events in the browser session
| Name | Type | Description |
|---|---|---|
options? | Object | Reserved for future use |
Promise<boolean>
Indicates if the call succeeded
▸ setAuthenticatedUser(userId, options?): Promise<boolean>
Sets the user context for all subsequent events in the browser session (or until the user is explicitly cleared). It should be set 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 |
options? | Object | Reserved for future use |
Promise<boolean>
Indicates if the call succeeded
▸ triggerActionEvent(actionType, options?): Promise<ActionResponse>
Reports a user action event to the SDK
| Name | Type | Description |
|---|---|---|
actionType | string | Type of user action event that was predefined in the Mosaic server |
options? | ActionEventOptions | - |
Promise<ActionResponse>
Indicates if the call succeeded
▸ getSessionToken(): Promise<string>
Get a session token, which can be used to trigger an action event via backend API. Requires setting enableSessionToken to true in the SDK configuration.
Promise<string>
The session token.