Skip to content

Migration to v3.x

This guide helps you migrate your React Native Fraud Prevention integration to version 3.x.

Important

Version 3.x includes breaking changes that will cause runtime errors if not addressed. Review all changes before upgrading. For the full release history, see Changelog.

What's new

Breaking changes:

  • setUserId() is renamed to setAuthenticatedUser().
  • initializeIOS() now requires baseUrl as a mandatory parameter.
  • Android native Fraud Prevention SDK dependency com.ts.sdk:accountprotection updated to 3.0.0.

New features:

  • claimedUserId and claimedUserIdType parameters in triggerAction() for typed user identification (claimUserId is deprecated).
  • Optional locationConfig parameter in triggerAction() for controlling location data collection.
  • Optional customAttributes parameter in triggerAction() for sending additional contextual data.
  • getSessionToken() for obtaining a device session token for backend integrations.
  • logPageLoad() for tracking screen navigation as part of behavioral data collection.
  • TSClaimedUserIdType enum for specifying the type of claimed user ID.

Migrate your integration to v3.x

Step 1: Update dependencies

Android (app/build.gradle):

Before:

dependencies {
  implementation "com.ts.sdk:accountprotection:2.1.+"
}

After:

dependencies {
  implementation "com.ts.sdk:accountprotection:3.+"
}

npm:

npm install react-native-ts-accountprotection@^3.0.0

iOS: Navigate to your iOS project directory and run pod install to install the React Native module's iOS CocoaPods dependencies.

Step 2: Rename setUserId to setAuthenticatedUser

The setUserId() function has been renamed to setAuthenticatedUser(). Update all occurrences in your code.

Before:

import { setUserId } from 'react-native-ts-accountprotection';

await setUserId(username);

After:

import { setAuthenticatedUser } from 'react-native-ts-accountprotection';

await setAuthenticatedUser(username);

Step 3: Update iOS initialization (if using explicit parameters)

If you initialize the React Native iOS module with explicit parameters using initializeIOS(), baseUrl is now a required parameter. The baseUrl value must include the /risk-collect/ path.

Before:

import { initializeIOS } from 'react-native-ts-accountprotection';

await initializeIOS('YOUR_CLIENT_ID');

After:

import { initializeIOS } from 'react-native-ts-accountprotection';

await initializeIOS('YOUR_CLIENT_ID', 'https://api.transmitsecurity.io/risk-collect/');

If you initialize using initializeSDKIOS() with a TransmitSecurity.plist file, no changes are needed for initialization.

Step 4: Update triggerAction calls

The claimUserId parameter is deprecated. Use claimedUserId and claimedUserIdType instead. The function also accepts two new optional parameters: locationConfig and customAttributes.

Before:

const response = await triggerAction(TSAction.login, {
  correlationId: "CORRELATION_ID",
  claimUserId: "CLAIMED_USER_ID",
  referenceUserId: "REFERENCE_USER_ID"
});

After:

import { 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" },        // locationConfig (optional)
  { userLevel: "premium" }    // customAttributes (optional)
);

Step 5: Update import statements

Update your imports to reflect the renamed function and new exports:

Before:

import { triggerAction, setUserId, clearUser, TSAction } from 'react-native-ts-accountprotection';

After:

import { triggerAction, setAuthenticatedUser, clearUser, TSAction, TSClaimedUserIdType } from 'react-native-ts-accountprotection';

Step 6: Test your integration

  • Verify all SDK functionality works as expected.
  • Check for any runtime errors related to renamed methods.
  • Confirm that triggerAction() returns action tokens as expected with the new parameter structure.