npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@devrev/sdk-react-native

v2.2.2

Published

DevRev SDK, used for integrating DevRev services into your React Native app.

Readme

DevRev SDK for React Native and Expo

DevRev SDK, used for integrating DevRev services into your React Native and Expo apps.

Quickstart

Requirements

  • React Native 0.79.0 or later.
  • For Expo apps, Expo 50.0.0 or later.
  • Android: minimum API level 24.
  • iOS: minimum deployment target 15.1.
  • (Recommended) An SSH key configured locally and registered with GitHub.

Installation

To install the DevRev SDK, run the following command:

npm install @devrev/sdk-react-native

Expo

  1. To install the DevRev SDK, run the following command:
    npx expo install @devrev/sdk-react-native-expo-plugin
  2. Configure the Expo config plugin in your app.json or app.config.js:
    {
      "expo": {
        "plugins": [
          "@devrev/sdk-react-native-expo-plugin"
        ]
      }
    }
  3. Rebuild your app:
    npx expo prebuild --clean

Set up the DevRev SDK

  1. Open the DevRev web app at https://app.devrev.ai and go to the Settings page.
  2. Under PLuG settings copy the value under Your unique App ID.
  3. Configure the DevRev SDK in your app using the obtained credentials.

[!WARNING] The DevRev SDK must be configured before you can use any of its features.

The SDK becomes ready for use once the following configuration method is executed.

DevRev.configure(appID: string)

Features

Identification

To access certain features of the DevRev SDK, user identification is required.

The identification function should be placed appropriately in your app after the user logs in. If you have the user information available at app launch, call the function after the DevRev.configure(appID: string) method.

[!TIP] If you haven't previously identified the user, the DevRev SDK will automatically create an anonymous user for you immediately after the SDK is configured.

[!TIP] The Identity structure allows for custom fields in the user, organization, and account traits. These fields must be configured through the DevRev app before they can be used. For more information, refer to Object customization.

You can select from the following methods to identify users within your application:

Identify an unverified user

The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.

DevRev.identifyUnverifiedUser(userID: string, organizationID?: string)

Identify a verified user

The verified identification method is used to identify users with an identifier unique to your system within the DevRev platform. The verification is done through a token exchange process between you and the DevRev backend.

The steps to identify a verified user are as follows:

  1. Generate an AAT for your system (preferably through your backend).
  2. Exchange your AAT for a session token for each user of your system.
  3. Pass the user identifier and the exchanged session token to the DevRev.identifyVerifiedUser(userID: string, sessionToken: string) method.

[!WARNING] For security reasons, it is strongly recommended that the token exchange is executed on your backend to prevent exposing your application access token (AAT).

Generate an AAT
  1. Open the DevRev web app at https://app.devrev.ai and go to the Settings page.
  2. Open the PLuG Tokens page.
  3. Under the Application access tokens panel, click New token and copy the token that's displayed.

[!WARNING] Ensure that you copy the generated application access token, as you cannot view it again.

Exchange your AAT for a session token

To proceed with identifying the user, you need to exchange your AAT for a session token. This step helps you identify a user of your own system within the DevRev platform.

Here is a simple example of an API request to the DevRev backend to exchange your AAT for a session token:

[!WARNING] Make sure that you replace the <AAT> and <YOUR_USER_ID> with the actual values.

curl \
--location 'https://api.devrev.ai/auth-tokens.create' \
--header 'accept: application/json, text/plain, */*' \
--header 'content-type: application/json' \
--header 'authorization: <AAT>' \
--data '{
  "rev_info": {
    "user_ref": "<YOUR_USER_ID>"
  }
}'

The response of the API call contains a session token that you can use with the verified identification method in your app.

[!WARNING] As a good practice, your app should retrieve the exchanged session token from your backend at app launch or any relevant app lifecycle event.

Identify the verified user

Pass the user identifier and the exchanged session token to the verified identification method:

DevRev.identifyVerifiedUser(userID: string, sessionToken: string)

Update the user

You can update the user's information using the following method:

DevRev.updateUser(identity: Identity)

[!WARNING] The userID property cannot be updated.

Logout

You can logout of the current user by using the following method:

DevRev.logout(deviceID: string)

Identity model

The Identity interface is used to provide user, organization, and account information when identifying users or updating their details. This class is used primarily with the identifyUnverifiedUser and updateUser methods.

Properties

The Identity class contains the following properties:

| Property | Type | Required | Description | |----------|------|----------|-------------| | userRef | string | ✅ | A unique identifier for the user | | organizationRef | string? | ❌ | An identifier for the user's organization | | accountRef | string? | ❌ | An identifier for the user's account | | userTraits | UserTraits? | ❌ | Additional information about the user | | organizationTraits | OrganizationTraits? | ❌ | Additional information about the organization | | accountTraits | AccountTraits? | ❌ | Additional information about the account |

[!NOTE] The custom fields properties defined as part of the user, organization and account traits, must be configured in the DevRev web app before they can be used. See Object customization for more information.

User traits

The UserTraits class contains detailed information about the user:

[!NOTE] All properties in UserTraits are optional.

| Property | Type | Description | |----------|------|-------------| | displayName | string? | The displayed name of the user | | email | string? | The user's email address | | fullName | string? | The user's full name | | description | string? | A description of the user | | customFields | { [key: string]: any } | Dictionary of custom fields configured in DevRev |

Organization traits

The OrganizationTraits class contains detailed information about the organization:

[!NOTE] All properties in OrganizationTraits are optional.

| Property | Type | Description | |----------|------|-------------| | displayName | string? | The displayed name of the organization | | domain | string? | The organization's domain | | description | string? | A description of the organization | | phoneNumbers | string[]? | Array of the organization's phone numbers | | tier | string? | The organization's tier or plan level | | customFields | { [key: string]: any } | Dictionary of custom fields configured in DevRev |

Account traits

The AccountTraits class contains detailed information about the account:

[!NOTE] All properties in AccountTraits are optional.

| Property | Type | Description | |----------|------|-------------| | displayName | string? | The displayed name of the account | | domains | string[]? | Array of domains associated with the account | | description | string? | A description of the account | | phoneNumbers | string[]? | Array of the account's phone numbers | | websites | string[]? | Array of websites associated with the account | | tier | string? | The account's tier or plan level | | customFields | { [key: string]: any } | Dictionary of custom fields configured in DevRev |

Support chat

Once the user identification is complete, you can start using the chat (conversations) dialog supported by our DevRev SDK. The support chat feature can be shown as a modal screen from the top-most screen.

DevRev.showSupport()

Create a new support conversation

You can initiate a new support conversation directly from your app. This method displays the support chat screen and simultaneously creates a new conversation.

DevRev.createSupportConversation()

In-app link handling

In certain cases, the links opened from the support chat are opened in the app instead of a browser. You can control whether the chat modal should be dismissed after the link is opened by calling the following method:

DevRev.setShouldDismissModalsOnOpenLink(value: boolean)

Setting this flag to true applies the system's default behavior for opening links, which includes dismissing any DevRev modal screens to facilitate handling your own deep links.

In-app link callback

[!TIP] This feature is supported only on Android.

For scenarios where custom handling is needed, links from the support chat can be captured with the following method:

DevRev.setInAppLinkHandler((url) => {
	// Perform an action here.
});

Dynamic theme configuration

The DevRev SDK allows you to configure the theme dynamically based on the system appearance, or use the theme configured on the DevRev portal. By default, the theme is dynamic and follows the system appearance.

DevRev.setPrefersSystemTheme(value: boolean)

Analytics

The DevRev SDK allows you to send custom analytic events by using a properties map. You can track these events using the following function:

DevRev.trackEvent(name: string, properties?: { [key: string]: string })

Session analytics

The DevRev SDK offers session analytics features to help you understand how users interact with your app.

Opt in or out

Session analytics features are opted-in by default, enabling them from the start. However, you can opt-out using the following method:

DevRev.stopAllMonitoring()

To opt back in, use the following method:

DevRev.resumeAllMonitoring()

Session recording

You can enable session recording to record user interactions with your app.

[!NOTE] The session recording feature is opt-out and is enabled by default.

The session recording feature includes the following methods to control the recording:

| Method | Action | |--------------------------------------------------------------------|-----------------------------------------------------------| |DevRev.startRecording() | Starts the session recording. | |DevRev.stopRecording() | Stops the session recording and uploads it to the portal. | |DevRev.pauseRecording() | Pauses the ongoing session recording. | |DevRev.resumeRecording() | Resumes a paused session recording. | |DevRev.processAllOnDemandSessions() | Stops the ongoing user recording and sends all on-demand sessions along with the current recording. |

Session properties

You can add custom properties to the session recording to help you understand the context of the session. The properties are defined as a map of string values.

DevRev.addSessionProperties(properties: { [key: string]: string })

To clear the session properties in scenarios such as user logout or when the session ends, use the following method:

DevRev.clearSessionProperties()

Mask sensitive data

To protect sensitive data, the DevRev SDK provides an auto-masking feature that masks data before sending to the server. Input views such as password text fields are automatically masked.

While the auto-masking feature is sufficient for most situations, you can manually mark additional views as sensitive using the following method:

DevRev.markSensitiveViews(tags: any[])

If any previously masked views need to be unmasked, you can use the following method:

DevRev.unmarkSensitiveViews(tags: any[])

For example:

import * as DevRev from '@devrev/sdk-react-native';
import { View, Text, findNodeHandle } from "react-native";
import { useRef, useEffect } from "react";

const YourComponent = () => {
  const sensitiveViewRef = useRef(null);
  const insensitiveViewRef = useRef(null);

  useEffect(() => {
    // Mark sensitive view
    const sensitiveId = findNodeHandle(sensitiveViewRef.current);
    if (sensitiveId) {
      DevRev.markSensitiveViews([sensitiveId]);
    }

    // Unmark insensitive view
    const insensitiveId = findNodeHandle(insensitiveViewRef.current);
    if (insensitiveId) {
      DevRev.unmarkSensitiveViews([insensitiveId]);
    }
  }, []);

  return (
    <View>
      <View ref={sensitiveViewRef}>
        <Text>Sensitive content (masked in recordings)</Text>
      </View>
      <View ref={insensitiveViewRef}>
        <Text>Insensitive content (visible in recordings)</Text>
      </View>
    </View>
  );
};

export default YourComponent;

Mask elements inside web views

To mark elements as sensitive inside a web view (WebView), apply the devrev-mask CSS class. To unmark them, use devrev-unmask.

  • Mark an element as masked:
    <label class="devrev-mask">OTP: 12345</label>
  • Mark an element as unmasked:
    <input type="text" placeholder="Enter Username" name="username" required class="devrev-unmask">

User interaction tracking

The DevRev SDK automatically tracks user interactions such as taps, swipes, and scrolls. However, in some cases you may want to disable this tracking to prevent sensitive user actions from being recorded.

To temporarily disable user interaction tracking, use the following method:

DevRev.pauseUserInteractionTracking()

To resume user interaction tracking, use the following method:

DevRev.resumeUserInteractionTracking()

Timers

The DevRev SDK offers a timer mechanism to measure the time spent on specific tasks, allowing you to track events such as response time, loading time, or any other duration-based metrics.

The mechanism uses balanced start and stop methods, both of which accept a timer name and an optional dictionary of properties.

To start a timer, use the following method:

DevRev.startTimer(name: string, properties: { [key: string]: string })

To stop a timer, use the following method:

DevRev.endTimer(name: string, properties: { [key: string]: string })

Track screens

The DevRev SDK offers automatic screen tracking to help you understand how users navigate through your app. Although screens are automatically tracked, you can manually track screens using the following method:

DevRev.trackScreenName(name: string)

Manage screen transitions (Android only)

The DevRev SDK allows tracking of screen transitions to understand the user navigation within your app. You can manually update the state using the following methods:

// Mark the transition as started.
DevRev.setInScreenTransitioning(true)

// Mark the transition as ended.
DevRev.setInScreenTransitioning(false)

Push notifications

You can configure your app to receive push notifications from the DevRev SDK. The SDK is able to handle push notifications and execute actions based on the notification's content.

The DevRev backend sends push notifications to your app to notify users about new messages in the support chat.

Configuration

To receive push notifications, you need to configure your DevRev organization by following the instructions in the push notifications section.

Register for push notifications

[!TIP] Push notifications require that the SDK has been configured and the user has been identified, to ensure delivery to the correct user.

The DevRev SDK offers a method to register your device for receiving push notifications. You can register for push notifications using the following method:

DevRev.registerDeviceToken(deviceToken: string, deviceID: string)

On Android devices, the deviceToken should be the Firebase Cloud Messaging (FCM) token value, while on iOS devices, it should be the Apple Push Notification service (APNs) token.

Unregister from push notifications

If your app no longer needs to receive push notifications, you can unregister the device.

Use the following method to unregister the device:

DevRev.unregisterDevice(deviceID: string)

The method requires the device identifier, which should be the same as the one used when registering the device.

Handle push notifications

Android

On Android, notifications are implemented as data messages to offer flexibility. However, this means that automatic click processing isn't available. To handle notification clicks, developers need to intercept the click event, extract the payload, and pass it to a designated method for processing. This custom approach enables tailored notification handling in Android applications.

To process the notification, use the following method:

DevRev.processPushNotification(payload: string)

Here, the message object from the notification payload needs to be passed to this function.

For example:

const notificationPayload = {
	// message may be nested based on the notification library
	"message": {
		// ... (the entire message object)
	}
};
const messageJson = notificationPayload["message"];
DevRev.processPushNotification(JSON.stringify(messageJson));
iOS

On iOS devices, you must pass the received push notification payload to the DevRev SDK for processing. The SDK handles the notification and executes the necessary actions.

DevRev.processPushNotification(payload: string)

For example:

DevRev.processPushNotification(JSON.stringify(payload));

Sample app (without framework)

A sample app with use cases for the DevRev SDK for React Native has been provided as a part of our public repository. To set up and run the sample app, follow these steps:

  1. Go to the sample directory:
    cd sample/react-native
  2. Install the dependencies:
    yarn install
  3. For iOS, run:
    pod install --project-directory=ios --repo-update
  4. Start the React Native development server:
    npx react-native start
  5. Run the app on Android using:
    npx react-native run-android
    or open the android directory in Android Studio and run the app from there.
  6. Run the app on iOS using:
    npx react-native run-ios
    or open ios/DevRevSDKSampleRN.xcworkspace in Xcode and run the app from there.

Sample app (Expo)

A sample app with use cases for the DevRev SDK for Expo has been provided as a part of our public repository. To set up and run the sample app, follow these steps:

  1. Go to the sample directory:
    cd sample/expo
  2. Install the dependencies:
    yarn install
  3. Run clean and prebuild:
    npx expo prebuild --clean
  4. Run the app on Android using:
    npx expo run:android
    OR open the android directory in Android Studio and run the app.
  5. Run the app on iOS:
    npx expo run:ios
    OR open ios/DevRevSDKSample.xcworkspace in Xcode and run the app.

Troubleshooting

  • Issue: Support chat doesn't show. Solution: Ensure you have correctly called one of the identification methods: DevRev.identifyUnverifiedUser(...) or DevRev.identifyVerifiedUser(...).

  • Issue: Not receiving push notifications. Solution: Ensure that your app is configured to receive push notifications and that your device is registered with the DevRev SDK.

ProGuard (Android only)

When trying to build your app for Android with ProGuard enabled, refer to these common issues and their solutions.

[!NOTE] You can always refer to the Android ProGuard documentation for more information.

  • Issue: Missing class com.google.android.play.core.splitcompat.SplitCompatApplication. Solution: Add the following line to your proguard-rules.pro file:

    -dontwarn com.google.android.play.core.**
  • Issue: Missing class issue due to transitive Flutter dependencies. Solution: Add the following lines to your proguard-rules.pro file:

    -keep class io.flutter.** { *; }
    -keep class io.flutter.plugins.** { *; }
    -keep class GeneratedPluginRegistrant { *; }
  • Issue: Missing class org.s1f4j.impl.StaticLoggerBinder. Solution: Add the following line to your proguard-rules.pro file:

    -dontwarn org.slf4j.impl.StaticLoggerBinder

Migration Guide

If you are migrating from the legacy UserExperior SDK to the new DevRev SDK, please refer to the Migration Guide for detailed instructions and feature equivalence.