1.0.47 • Published 5 months ago

@sensfrx/sensfrx v1.0.47

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Sensfrx React Native SDK

Sensfrx Logo

Overview

Sensfrx React Native SDK is a comprehensive fraud detection solution tailored to secure mobile applications built with React Native. By collecting real-time device information and tracking user interactions, the SDK helps detect a wide range of fraudulent activities such as app cloning, network evasion, device rooting, and emulator-based attacks.

With AI-driven risk analysis and advanced behavioral analytics, Sensfrx SDK ensures that businesses can protect user accounts, prevent fake registrations, and reduce online transaction fraud. Its lightweight nature ensures minimal impact on app performance while providing strong protection against evolving security threats.

Sensfrx React Native SDK supports only Android platform and works seamlessly with your existing React Native applications. Know more about us

Configuration Requirements

  • React Native version: 0.64+
  • Required Credentials: Property ID and Property Secret from the Sensfrx Dashboard
  • Supported OS Version: Android: Android 9.0+ (Pie)

Installation

Add SDK Dependency

Step 1: Install Sensfrx SDK using npm or yarn:

npm install @sensfrx/sensfrx
or
yarn add @sensfrx/sensfrx

Note: Manual linking is not required.

The Sensfrx SDK supports React Native 0.64 and above, which uses autolinking. You do not need to run react-native link.

Required Permissions (Optional)

For enhanced security features, request permissions where needed:

Android: INTERNET, ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION


Configuration

Step 2: Initialize the SDK

In your main application file (typically App.js or index.js), initialize the Sensfrx SDK.

To Get Your Property Secret

  • Register on the Sensfrx Dashboard.
  • After registration, log in to your dashboard.
  • Generate your Property ID and Property Secret from the dashboard. These credentials are required to configure the SDK in your app.

sandboxMode Parameter

sandboxMode (boolean):

  • true: Use this mode for testing. In sandbox mode, the SDK will simulate interactions and data without affecting your production environment.
  • false: Set this mode to false when you are ready to deploy the app in a live production environment. This ensures the SDK works with real data and integrates with the live backend services.
import * as Sensfrx from '@sensfrx/sensfrx';

// Initialize the SDK with your Property ID and Property Secret
Sensfrx.configure({
  sandboxMode: false,  // Set to true for testing,
  propertySecret: 'PropertyID:Secret'
});

Make sure to replace 3764534847133568:VGF9TR2qfOnGCEghl with the Property Secret you obtained from the Sensfrx Dashboard.


Event Tracking

Sensfrx React Native SDK provides various mechanisms to track important events like user interactions, login attempts, registrations, and transactions.

Click Events

Monitor user interactions with the app by tracking button clicks or any other view clicks. Click events help us read the behavioral data of users, providing insights into how users interact with different elements of your app. Add this code to track click events on the screens.

import { TouchableOpacity } from 'react-native';
import * as Sensfrx from '@sensfrx/sensfrx';

 const handleTap = (event: GestureResponderEvent) => {
    Sensfrx.trackClickEvent(event); // full gesture event
  };

  return (
    <Pressable style={styles.container} onPress={handleTap}>
      <Text style={styles.title}>Sensfrx</Text>
      <Text style={styles.status}>.....</Text>
 );
    </Pressable>

Track App State Events

Tracking the app's state allows you to monitor when your app is opened, closed, or moved to the background. This information is crucial for detecting unusual app usage patterns, improving user engagement, and strengthening security measures.

import * as Sensfrx from '@sensfrx/sensfrx';

Sensfrx.trackAppEvent('OPEN');  // When the app is launched
Sensfrx.trackAppEvent('BACKGROUND');  // When the app moves to background

Screen Change Events

Tracking screen transitions allows you to monitor how users navigate through your app, helping you understand their behavior and detect potential fraud. Sensfrx automatically tracks screen changes and provides valuable insights into user journeys, such as how many screens a user visits and how long they stay on each. Capture screen transitions:

  • User Behavior Analysis: Understanding user navigation patterns allows us to identify normal and abnormal behavior, improving user experience and fraud detection.
  • Fraud Detection: Unusual screen change patterns, such as rapid or unexpected transitions, could indicate suspicious activity or attempts to bypass security.
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
import * as Sensfrx from '@sensfrx/sensfrx';

export default function App() {
  const navigationRef = useNavigationContainerRef();

  return (
    <NavigationContainer
      ref={navigationRef}
      onStateChange={() => {
        if (navigationRef) {
          Sensfrx.trackScreenChangeEvent(navigationRef);
        }
      }}
    >
      {/* Your navigators and screens */}
    </NavigationContainer>
  );
}

Note: Sensfrx.trackScreenChangeEvent(navigationRef) automatically extracts the current screen name and timestamp, so there's no need to manually provide screen details.

Login Event

The Login Event is critical for tracking and protecting user logins. By monitoring login attempts and associated behaviors, Sensfrx can detect abnormal patterns that may indicate fraud, such as multiple failed login attempts, IP location changes, and device fingerprint mismatches.

Benefits of Tracking Login Events:

  • Account Takeover (ATO) Detection: Identifies fraudulent login attempts and potential account takeovers.
  • Fraud Prevention: Detects patterns indicative of credential stuffing, password spraying, or other automated attack techniques.
  • Risk Analysis: Provides actionable insights into login behaviors and risks, improving security measures.

Implementation Example

// Create a login request and send it to your backend
import * as Sensfrx from '@sensfrx/sensfrx';

const loginEvent = (email, password) => {
  const loginData = {
     uex: {
      email: email,
      password: password,
    },
    package: 'com.yourapp',
    request_token: Sensfrx.getRequestToken(),
    d_f: Sensfrx.getDeviceFingerprints(),
  };
};

// You can also pass location for better accuracy or location-based detectors
Sensfrx.getRequestTokenWithLocation(latitude, longitude)
Sensfrx.getDeviceFingerprints(latitude, longitude)

For more details checkout the demo application or connect with our support team.

Registration Event Tracking

The Registration Event helps track new user registrations. This is essential for preventing fraudulent account creation, such as fake registrations or bot-driven sign-ups. By tracking registration behaviors, Sensfrx can detect suspicious activities like repeated sign-ups from the same IP address, unusual device fingerprints, or unverified user information.

Benefits of Tracking Registration Events:

  • Fake Registration Detection: Identifies automated or bot-driven sign-ups that don't match typical user behavior.
  • Fraud Prevention: Prevents fake account creation by detecting patterns such as multiple sign-ups with the same email or device fingerprint.
  • Risk Analysis: Provides insights into registration behaviors, helping to prevent fraud and improve account security from the start.

Implementation Example

import * as Sensfrx from '@sensfrx/sensfrx';

const registrationEvent = (name, email, mobile, password) => {
  const registrationData = {
    rfs: {
      name: name,
      email: email,
      phone: mobile,
      password: password,
    },
    package: 'com.yourapp',
    request_token: Sensfrx.getRequestToken(),
    d_f: Sensfrx.getDeviceFingerprints(),
  };

};

// You can also pass location for better accuracy or location-based detectors
Sensfrx.getRequestTokenWithLocation(latitude, longitude)
Sensfrx.getDeviceFingerprints(latitude, longitude)

For more details checkout the demo application or connect with our support team.

Transaction Event Tracking

The Transaction Event provides insights into user purchases and financial transactions. By monitoring transaction data, Sensfrx can help detect suspicious activities like payment fraud, stolen credit cards, and transaction manipulation, ensuring secure and reliable financial interactions.

Benefits of Tracking Transaction Events:

  • Payment Fraud Detection: Identifies abnormal transaction patterns such as high-value transactions, unusual payment methods, or frequent payment failures.
  • Risk Management: Helps businesses assess transaction risks and detect compromised accounts or fraudulent payment methods.
  • Transaction Integrity: Ensures that only legitimate purchases are processed, protecting both users and merchants from fraud.
import * as Sensfrx from '@sensfrx/sensfrx';

const transactionEvent = {
  transaction_id: "TXN123456",
  transaction_type: "purchase",
  email: "dummy@example.com",
  first_name: "John",
  last_name: "Doe",
  username: "john_doe123",
  payment_mode: "Credit Card",
  payment_provider: "Visa",
  card_fullname: "John Doe",
  card_bin: "411111",
  card_expire: "12/2026",
  card_last: "1234",
  cvv: "999",
  phone_no: "9998887777",
  transaction_amount: "1500",
  transaction_currency: "INR",
  items: [
    {
      item_id: "101",
      item_name: "Wireless Headphones",
      item_category: "Electronics",
      item_quantity: "1",
      item_price: "1200",
      item_url: "https://example.com/item101"
    },
    {
      item_id: "102",
      item_name: "USB-C Charger",
      item_category: "Accessories",
      item_quantity: "1",
      item_price: "300",
      item_url: "https://example.com/item102"
    }
  ],
  shipping_cost: "50",
  shipping_country: "India",
  shipping_state: "Maharashtra",
  shipping_city: "Mumbai",
  shipping_zip: "400001",
  shipping_phone: "9998887777",
  shipping_fullname: "John Doe",
  shipping_method: "Express",
  billing_country: "India",
  billing_state: "Maharashtra",
  billing_city: "Mumbai",
  billing_zip: "400001",
  billing_phone: "9998887777",
  merchant_name: "Gadget World",
  merchant_category: "Electronics",
  merchant_id: "M123456",
  merchant_country: "India",
  ev: "attempt_succeeded",
  card_type: "Visa",
  tax_amount: "100",
  discount_amount: "50",
  invoice_id: "INV98765",
  d_f: Sensfrx.getDeviceFingerprints(),
  request_token: Sensfrx.getRequestToken(),
  user_id: "user_987654"
};

// Track the transaction event
Sensfrx.trackTransactionEvent(transactionEvent);

// You can also pass location for better accuracy or location-based detectors
Sensfrx.getRequestTokenWithLocation(latitude, longitude)
Sensfrx.getDeviceFingerprints(latitude, longitude)

Transaction Success/Failure Handling

After initiating the payment process with your payment SDK, you can track whether the transaction was successful or failed by utilizing Sensfrx.trackTransactionEvent in your onPaymentSuccess and onPaymentError methods. This helps in tracking the transaction's outcome and improves fraud detection.

// Called when payment is successful
const onPaymentSuccess = (transactionDetails) => {
  // Set the event to transaction_succeeded
  transactionDetails.ev = "transaction_succeeded";

  // Send the complete transaction details again with updated flag
  Sensfrx.trackTransactionEvent(transactionDetails);
};

// Called when payment fails
const onPaymentError = (errorCode, errorMessage, transactionDetails) => {
  // Set the event to transaction_failed
  transactionDetails.ev = "transaction_failed";

  // Send the complete transaction details again with updated flag
  Sensfrx.trackTransactionEvent(transactionDetails);
};

Error Handling

To ensure smooth SDK integration, consider the following common issues:

  • Network Issues: Ensure the app has internet access and is not blocked by firewalls.
  • Invalid Keys: Verify the correct secret key.
  • Invalid Package: Verify the correct package name.

Enable detailed logging using Android Studio Logcat for debugging.


Analytics and Dashboard

After integrating Sensfrx into your app, you can view real-time fraud detection analytics, user behavior, and transaction logs directly on the Sensfrx Dashboard. This allows you to monitor suspicious activities and make data-driven decisions for fraud prevention.

Access your Sensfrx Dashboard


SDK Publication Details


Support

For assistance, contact our support team at info@sensfrx.com or visit our developer portal.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

1.0.47

5 months ago

1.0.46

5 months ago

1.0.45

5 months ago

1.0.44

5 months ago

1.0.43

5 months ago

1.0.42

5 months ago

1.0.41

5 months ago

1.0.40

5 months ago

1.0.39

5 months ago

1.0.38

5 months ago

1.0.37

5 months ago

1.0.36

5 months ago

1.0.35

5 months ago

1.0.34

5 months ago

1.0.33

5 months ago

1.0.32

5 months ago

1.0.31

5 months ago

1.0.30

5 months ago

1.0.29

5 months ago

1.0.28

5 months ago

1.0.27

5 months ago

1.0.26

5 months ago

1.0.25

5 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.22

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago