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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@devrev/sdk-react-native

v1.0.0

Published

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

Downloads

408

Readme

DevRev SDK for React Native

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

Table of contents

Installation

npm install @devrev/sdk-react-native

Setting up the DevRev SDK

Step 1: Credentials

  1. Open the DevRev web app at https://app.devrev.ai.
  2. Go to the Settings page.
  3. Then open the PLuG Settings page, and copy the value under Your Unique App ID.

Step 2: Configuration

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

Once you have the credentials, you can configure the DevRev SDK in your app. The SDK will be ready to use once you have called the configuration method:

DevRev.configure(appID: string)

Features

Identification

Certain features of the DevRev SDK require a user identification. There are two methods to identify your users:

  • Anonymous users: Creates an anonymous user with an optional user identifier, no other data is stored or associated with the user.
  • Unverified users: Identifies the user with a unique identifier, but does not verify the user's identity with the DevRev backend.

The identification functions should be placed at the appropriate place in your app after you login your user. If you have the user information at app launch, call the function after the DevRev.configure(appID:) method.

[!IMPORTANT] If you haven't previously identified the user, the DevRev SDK will automatically create an anonymous user for you right after the SDK has been configured.

[!IMPORTANT] The user, organization and account traits in the Identity object also support custom fields, which need to be configured in the DevRev web app before they can be used. For more information, see Object customization.

Anonymous identification

The anonymous identification method is used to create an anonymous user with an optional user identifier.

DevRev.identifyAnonymousUser(userID: string)

Unverified identification

The unverified identification method is used to identify the user with a unique identifier, but does not verify the user's identity with the DevRev backend.

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

Updating the user

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

DevRev.updateUser(identity: Identity)

[!IMPORTANT] The userID property can not be updated.

PLuG support chat

The support chat feature can be shown as a modal screen from the top-most screen.

[!IMPORTANT] This feature requires that the SDK has been configured and the user has been identified (unverified and anonymous users).

DevRev.showSupport()

Creating a new support conversation

You have the ability to create a new conversation from within your app. The method will show the support chat screen and create a new conversation at the same time.

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 will use the system's default behavior for opening links, it will dismiss any DevRev modal screen in order to handle your own deep links.

In-app link callback (Android Only)

In certain cases where custom handling is required, the links from the support chat can be captured as follows:

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

[!NOTE] By default, if a custom handler is not set, all external/in-app links from the support chat are opened via the system default (e.g Chrome).

Analytics

The DevRev SDK supports sending custom analytic events using a properties map.

[!IMPORTANT] This feature requires that the SDK has been configured and the user has been identified (unverified and anonymous users).

You can track them using the following function:

DevRev.trackEvent(name: string, properties?: Map<string, string>)

Observability

The DevRev SDK provides observability features to help you understand how your users are interacting with your app.

Opting in/out

The observability features are opted-in by default, meaning that they are enabled from start. You can opt-out of the observability features by calling the following method:

DevRev.stopAllMonitoring()

To opt back in, you can call the following method:

DevRev.resumeAllMonitoring()

Session recording

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

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

The session recording feature has a number of methods to help you control the recording:

  • 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.

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: Map<string, string>)

You also have the ability to clear the session properties in scenarios like user logout or when the session ends.

DevRev.clearSessionProperties()

Masking sensitive data

In order to protect sensitive data the DevRev SDK provides an auto-masking feature, which masks the data before it is being sent to the server. Input views such as text fields, text views, and web views are automatically masked.

While the auto-masking mechanism might be sufficient for most cases, you can also manually mark other 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[])

Timers

As part of the observability features, the DevRev SDK provides a timer mechanism to help you measure the time spent on a specific task. Events such as response time, loading time, or any other time-based event can be measured using the timer.

The mechanism works using balanced start and stop methods that both accept a timer name and an optional dictionary of properties.

Start a timer using the method:

DevRev.startTimer(name: string, properties: Map<string, string>)

And balance it with the stop method:

DevRev.stopTimer(name: string, properties: Map<string, string>)

Screen tracking

The DevRev SDK provides automatic screen tracking to help you understand how users are navigating through your app. While view controllers are automatically tracked, you can also manually track screens using the following method:

DevRev.trackScreen(name: string)

Push notifications

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

The DevRev backend sends push notifications to your app to notify users about new messages in the PLuG support chat. In the future, the push notification support will be expanded with additional features.

Configuration

In order to receive push notifications, you need to configure your DevRev organization by following the Push Notifications integration guide.

Registering for push notifications

[!IMPORTANT] Push notifications require that the SDK has been configured and the user has been identified (unverified and anonymous users). The user identification is required to send the push notification to the correct user.

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

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

On Android devices the deviceToken should be the Firebase Cloud Messaging (FCM) token value, and on iOS devices it should be the APNS (Apple Push Notification Service) token. The deviceID is a unique identifier for the device that must persist across device restarts and app launches.

Unregistering from push notifications

In cases when your app no longer wants to receive push notifications, you can unregister the device from receiving them. The method to unregister the device is:

DevRevSDK.unregisterDevice(deviceID: string)

The method requires the device identifier, which is the same as the one used for registering the device.

Processing push notification

Android

Android notifications are implemented as data messages for flexibility, but this means 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 allows for tailored notification handling in Android applications.

DevRevSDK.processPushNotification(payload: string)

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

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

On iOS devices you need to pass the received push notification payload to the DevRev SDK for processing. The SDK will handle the notification and perform the necessary actions:

DevRevSDK.processPushNotification(payload: string)
Example
DevRevSDK.processPushNotification(JSON.stringify(payload));

License

Apache 2.0