Flutter agent

Prerequisites

Following are the prerequisites required for installing Flutter.

  • Dart Version >=2.12.0 <=3.7.2
  • Flutter SDK >=2.12.0 <=3.0.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 the system

Adding SixthSense Flutter dependency

Add Flutter dependency for both iOS and Android using the following procedure.

  1. In your application's pubspec.yaml file, add the following under dependencies and run the pub get command.
logger: ^1.3.0
uuid: ^4.1.0
device_info_plus: ^11.0.0

GitLab access token will be shared by Rakuten's customer support team at the time of onboarding.

  1. Download the dart file using below command inside lib folder of the project:
curl --header "PRIVATE-TOKEN: Git_lab_access_token_here" --output SixthSenseDataReporter.dart "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/40/packages/generic/flutter/v1.0.0/SixthSenseDataReporter.dart"
  1. Make the following changes in your main.dart file.
import 'SixthSenseDataReporter.dart';
var sixthSenseDataReporter = SixthSenseDataReporter();
void main() {
runZonedGuarded<Future<void>>(() async {
WidgetsFlutterBinding.ensureInitialized();
sixthSenseDataReporter.initializeSixthSenseSDK(String "SixthSense_dashboard_access_token_here", String "https://http-collector-observability.sixthsense.rakuten.com/poc-mobile");
(); runApp(const YourApp());
}, (error, stack) {
sixthSenseDataReporter.reportError(error, stack);
});
}
  1. To report handled errors, use the following method in catch blocks from .dart files after importing SixthSenseDataReporter:
import 'SixthSenseDataReporter.dart';
try { throw StateError('try catch'); }
catch (e, stack) { sixthSenseDataReporter.reportHandledError(e, stack); }

Configuring for Android

  1. Download the SixthSenseInfo.kt android file using below command inside android/app/src/main/kotlin/com/example folder of the project (where you have MainActivity.kt file)
curl --header "PRIVATE-TOKEN: Git_lab_access_token_here" --output SixthSenseInfo.kt "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/40/packages/generic/flutter/v1.0.0/SixthSenseInfo.kt"
  1. To install SixthSense Mobile Monitoring Android SDK, add the dependency to your build.gradle file dependencies block:
implementation("com.rakuten.sixthsense.observability:mobilemonitoring:2.1.0")
  1. Add the following lines to the repositories block:
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)
}
}
}
  1. Configure via AndroidManifest.xml. Configure the Access Token in the application tag
<meta-data android:name="com.rakuten.sixthsense.ACCESS_TOKEN"
android:value=="SixthSense_dashboard_access_token_here"/>

You can find the Access Token from the SixthSense dashboard. For more information, see Accessing your access token.

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. Initialise SSObservability in the OnCreate callback of your application subclass(MainActivity.kt):
import com.rakuten.sixthsense.observability.mobilemonitoring.SSObservability
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
SSObservability.init(this)
}
  1. Initialise SixthSenseMethodHandler in the configureFlutterEngine callback of your application subclass(MainActivity.kt):
override fun configureFlutterEngine( flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
SixthSenseInfo.setSixthSenseMethodHandler(flutterEngine)
}
  1. Add these lines to repositories specified for downloading plugins (in buildscript):
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)
}
}
}

Add the following to the dependencies block of buildscript:

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

Apply the plugin in module level build.gradle

apply plugin: "SSNetworkPlugin"

Following are the requirements for the above Http client's auto instrumentation.

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

Configuring for iOS

You can configure the agent for iOS using the following procedure.

Using cocoa pods

  1. Install cocoa pods in your system (ignore if already installed).
  2. Open the Runner.xcworkspace file in X-Code.
  3. Open Podfile inside the Pods folder and add pod 'SixthSenseMobileSDK'.
  4. Open the project in a terminal and run pod update command (please use GitLab token for both username and password). It will download the SixthSenseMobileSDK in the Runner application.
  5. Download the SixthSenseInfo.swift file using the following command inside the project's /ios folder (where you have the AppDelegate.swift file):
curl --header "PRIVATE-TOKEN: Git_lab_access_token_here" --output SixthSenseInfo.swift "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/40/packages/generic/flutter/v1.0.0/SixthSenseInfo.swift"
  1. Go to AppDelegate class and initialise SDK in the didFinishLaunching function with the following code:
SixthSenseInfo.shared.initSixthSenseFlutterMobileSDK()
  1. Configure Info.plist: Open your Info.plist file and add the necessary keys and values:

    7a. AccessToken key as a string and also add value for the same (AccessToken: "SixthSense_dashboard_access_token_here")

    7b. Add EndPointName key as a string and also add the value: (EndPointName: "https://http-collector-observability.sixthsense.rakuten.com/poc-mobile/")

Using swift package manager

  1. Open the Runner.xcworkspace file in X-Code.

  2. Add SixthSenseMobileSDK as a Swift Package: Go to X-Code File -> Add Package Dependencies and search for SixthSenseMobileSDK with the following git URL:

    https://artifacts-observability.sixthsense.rakuten.com/sixthsense/sixthsense-mobile-monitoring-ios-swift.git.

  3. Click Add Package which will open Git Lab authentication window in X-Code. Please use GitLab token for the authentication (token will be shared by SixthSense DevOps team during installation).

  4. Download the SixthSenseInfo.swift file using the following command inside the project's /ios folder (where you have AppDelegate.swift file).

curl --header "PRIVATE-TOKEN: Git_lab_access_token_here" --output SixthSenseInfo.swift "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/40/packages/generic/flutter/v1.0.0/SixthSenseInfo.swift"
  1. Go to AppDelegate class and initialise SDK in the didFinishLaunching function with the following code:
SixthSenseInfo.shared.initSixthSenseFlutterMobileSDK()
  1. Configure Info.plist: Open your Info.plist file and add the necessary keys and values:

    6a. AccessToken key as a string and also add value for same(AccessToken: "SixthSense_dashboard_access_token_here")

    6b. Add EndPointName key as a string and also add the value: (EndPointName: "https://http-collector-observability.sixthsense.rakuten.com/poc-mobile/").