Ionic agent

Prerequisites

Cordova 10, Capacitor 5

Android

  • Android 8.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 Ionic dependency (Common for iOS & Android)

Add the package dependency in the package.json file.

"@sixthsense/sixthsense-ionic-agent": "^0.1.6"

After adding the dependency, run the following commands to set the appropriate registry, authenticate, and download SixthSense Ionic dependency.

npm config set @sixthsense:registry https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/57/packages/npm/
npm config set -- '//artifacts-observability.sixthsense.rakuten.com/api/v4/projects/57/packages/npm/:_authToken' "${PACKAGE_TOKEN}"
npm install @sixthsense/sixthsense-ionic-agent

SixthSense Ionic dependency will download in the node modules folder.

  1. Open the main.ts file and do the following changes:
import ClientMonitor from '@sixthsense/sixthsense-ionic-agent';

a. Add the following code in the main.ts file.

ClientMonitor.register({
service: "pass application name", // Name the app
collector: 'pass endpoint url',
serviceVersion: "pass app version",
authorization: "pass access token",});
  1. Create a new global-error-handler.ts file inside the Project/src/app folder and add the following code in the file.

(OPTIONAL - need to implement if global error handler not there(specific to angular)):

import { ErrorHandler, Injectable } from '@angular/core';
import ClientMonitor from '@sixthsense/sixthsense-ionic-agent';
//import ErrorHandler in app.module.ts
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
constructor() {}
handleError(error: any) {
ClientMonitor.reportSixthsenseFrameErrors( {
collector: "pass endpoint url",
service: "pass application name",
serviceVersion: "pass app version",
authorization: "pass access token"
}, error)
}
}
  1. Save all changes and perform ionic build.

Android

  1. Install SixthSense Mobile Monitoring Android SDK and add the dependency to your build.gradle file in the dependencies block.
implementation("com.rakuten.sixthsense.observability:mobilemonitoring:2.1.0")
  1. Add the following lines to 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)
}
}
}

Configuring using AndroidManifest.xml

  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 Access Token from the SixthSense dashboard. For accessing your access token, see Accessing your 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/poc-mobile"/>
  1. 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 dashboard. To report handled exceptions in native (Java) code use the SSLogger as given below.

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

To automatically capture http requests made using the Fetch API:

  1. Add the following to buildscript under dependencies block.
dependencies {
classpath "com.rakuten.sixthsense.mobilemonitoring:SSNetworkPlugin:1.2.0"
}
  1. Apply the plugin in module level build.gradle
apply plugin: "SSNetworkPlugin"

The requirements for the above Http clients' auto instrumentation is as follows:

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

IOS

To implement SixthSenseMobileSDK.

a. Open the xcworkspace file in X-Code.

b. Open the Podfile inside the Pods folder and add pod 'SixthSenseMobileSDK'.

c. Open the Project in terminal and run pod update command. It will download the SixthSenseMobileSDK file in the Sample app.

d. Go to AppDelegate class and import SixthSenseMobileSDK. Initialise SDK in didDinishLaunching function with the following code.

SixthSenseMobile.shared.initSixthSenseMobileSDK()

e. Open the Info.plist file and add the "AccessToken" key as a string and also add the value for the same.

f. Open the Info.plist file and add "EndPointName" key as a string and also add the value "https://http-collector-observability.sixthsense.rakuten.com/poc-mobile/"

Testing the build

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

  1. For force crash, import SixthSenseMobileSDK in any View Controller class and call fatalError().
  2. Run the application in simulator/device and try to make the application crash. After crashing, relaunch the application in simulator/device.
  3. Open the Mobile Monitoring dashboard and go to the Mobile Monitoring tab and check the crash logs and other matrices.