React Native agent

Prerequisites

  • react-native >= 0.65.0

Android

  • Android 5.0 or higher - min SDK 21
  • Android Gradle Plugin - 4.2.0+
  • Gradle version - 6.7.1+

IOS

  • Mac OS 10.15.7 and above
  • iOS 12 and above
  • Download Install X-Code 12.2 and above
  • Install cocoa pods in system

Adding SixthSense React Native dependency for iOS and Android

Run the following commands to set the appropriate registry, authenticate, and download SixthSense react native dependency.

npm config set @sixthsense:registry https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/36/packages/npm/
npm config set -- '//artifacts-observability.sixthsense.rakuten.com/api/v4/projects/36/packages/npm/:_authToken' "$AUTH_TOKEN"
npm install @sixthsense/react-native-sixthsense-react-native@1.0.0

Android

To install SixthSense Mobile Monitoring Android SDK, add the dependency to your build.gradle file dependencies block.

implementation("com.rakuten.sixthsense.observability:mobilemonitoring:1.2.0")

Add the following lines to the repositories block for downloading dependencies.

repositories {
maven {
url "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/21/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "Git_lab_access_token_here"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}

Configuration is done via the AndroidManifest.xml file.

  1. Configure the Access Token in the application tag.
<meta-data android:name="com.rakuten.sixthsense.ACCESS_TOKEN"
android:value="access-token-here"/>

You can find the Access Token from the SixthSense dashboard. Navigate to Settings > General > Access token

  1. Similarly configure reporting base URL.
<meta-data android:name= "com.rakuten.sixthsense.BASE_URL"
android:value="https://http-collector-observability.sixthsense.rakuten.com/mobile"/>

For OneCloud Platform, use the following commnad:

<meta-data android:name= "com.rakuten.sixthsense.BASE_URL"
android:value="https://sixthsense-backend.jpe2-caas1-prod1.caas.jpe2b.r-local.net/mobile"/>

Initialize SSObservability in the OnCreate callback of your MainApplication.java.

@Override
public void onCreate() {
super.onCreate();
SSObservability.init(this);
...
}

This will capture crashes and ANRs and list them on the dashboard. To report handled exceptions in native (Java) code, use SSLogger as follows.

try {
...
}
catch (e: Exception) {
SSLogger.log(e)
...
}

To report errors from the javascript code do the following.

import { NativeModules } from 'react-native';
try {
var a = b; // Error Code
} catch (error) {
const { SixthsenseReactNativeMobile } = NativeModules;
SixthsenseReactNativeMobile.reportError(error.name, error.message,error.stack,false);
}

To automatically capture http requests made using Fetch API, add the following to the buildscript dependencies block.

dependencies {
classpath "com.rakuten.sixthsense.mobilemonitoring:SSNetworkPlugin:1.2.0"
}

Apply the plugin in the module level build.gradle.

apply plugin: "SSNetworkPlugin"

Requirements for the above http clients auto instrumentation are as follows:

  • Android Gradle Plugin - 7.1+
  • Gradle version - 7.2+

IOS

Implementing the mobile agent

  1. Open xcworkspace file in X-Code.
  2. Open Podfile inside the Pods folder and add the 'SixthSenseMobileSDK' pod.
  3. Open the project in a terminal and run the pod update command. It will download the SixthSenseMobileSDK in Sample app.
  4. Go to the index.js class and import initReactSDKInterceptor. Initialize SDK in the index.js file with the following code:
initReactSDKInterceptor();
NativeModules.SixthSenseMobileReact.initializeSDK('AccessTokenValue');
  1. Pass the access token value to initializeSDK function.
note

Get the accessToken value from the Mobile monitoring dashboard.

  1. Open the Info.plist file and add the "AccessToken" key as a string and also add the value.
  2. Open the Info.plist file and add "CountryCode" key as a string and also add the country code value. For example, for India value should be IN and for for USA value should be US.
  3. Open the Info.plist file and add "EndPointName" key as a string and also add the value "https://http-collector-observability.sixthsense.rakuten.com/mobile/".

For OneCloud Platform use, Open the Info.plist file and add "EndPointName" key as a string and also add the value "https://sixthsense-backend.jpe2-caas1-prod1.caas.jpe2b.r-local.net/mobile".

Testing the mobile agent

You are now in an Xcode workspace for building, debugging, and testing Mobile Monitoring.

  1. Force crash using import SixthSenseMobileSDK in any View Controller class and call SixthSenseMobile.shared.raiseException().
  2. Run the application in a simulator/device and make the application crash. After crashing, relaunch the application in the simulator/device.
  3. Navigate to Mobile monitoring dashboard from the SixthSense portal and check the crash logs and other matrices.