Finotes Core (finotescoreplugin)

Flutter plugin with the ability to detect and report bugs in Android and iOS mobile apps.

Getting started

  1. Register with Finotes using the 'Get Started' button in https://finotes.com and login to dashboard.
  2. Use "Add App" to link android and iOS applications to Finotes.
  3. Integrate Finotes plugin to your application.
  4. Test your integration.

Prerequisites for Integration

Plugin supports dart SDK versions greater than or equal to 3.1.0 and less than 4.0.0.
Flutter version should be greater than or equal to 3.3.0.
For Android platform Kotlin version should be greater than or equal to 1.8.0.

Integrating plugin

Add finotescoreplugin to pubspec.yaml file.

dependencies:
  finotescoreplugin: ^version

Initializing Finotes

Call Fn.init() function within the main function. Make sure to call WidgetsFlutterBinding.ensureInitialized() before calling init API.

void main() {
    runApp(const MyApp());

    WidgetsFlutterBinding.ensureInitialized();
    Fn.init();

}

Setting Proguard Rules

If you are using proguard in release build, you need to add the following to the proguard-rules.pro file.

proguard-rules.pro:

-keep class com.finotes.android.finotescore.* { *; }

-keepclassmembers class * {
    @com.finotes.android.finotescore.annotation.Observe *;
}

Add below line to keep the exact line number and source file name in the stacktrace.

proguard-rules.pro:

-keepattributes SourceFile,LineNumberTable

Please make sure that the mapping file of production build (each build) is backed up, inorder to deobfuscate the stacktrace from Finotes dashboard. Location of mapping file: project-folder/app/build/outputs/proguard/release/mapping.txt

Testing Integration

Now that the basic integration of Finotes plugin is complete, Let us make sure that the dashboard and plugin are in sync.

Step One

Add Fn.test() under Fn.init

import 'package:finotescoreplugin/finotescoreplugin.dart';

....
void main() {
    runApp(const MyApp());

    WidgetsFlutterBinding.ensureInitialized();
    Fn.init();

    Fn.test(); //Line to raise test issue.
}

Step Two

Once the application opens up, open Finotes dash. The test issue that we raised should be reported.

Remember to remove the Fn.test() call, else every time the app is run, an issue will be reported.

Crash Reporting

With basic integration, Finotes will track and report uncaught exceptions to Finotes dashboard automatically.

Report GuardedZone Errors

Any exceptions that may have already been caught within the Zone needs to be reported as they might prevent the application from crashing, but at the same time can make app unstable if gone unreported.

    runZonedGuarded<Future<void>>(() async {
      
        ....

    }, (dynamic error, StackTrace stackTrace) {
        Fn.reportError(error, stackTrace); //Single line API to report caught errors. 
    });

Reporting App startup delays

In order to activate the ability to detect app start up delays, extend the first State class with FnInitialState class and the rest of the State classes with FnState class.

If the app takes more than 3000 milliseconds to load, then it will be reported to the Finotes dashboard.

class _MyAppState extends FnInitialState<MyApp> { //Replace State class with FnInitialState class.
    ....

    @override
    Widget build(BuildContext context) {
        super.build(context); //Make sure to call the super here.
        return ..
    }
}

Report Custom Issues

Report custom issues using the Fn.reportIssue() API.

    Fn.reportIssue("Main App", "Payment failed", "Payment failed when selecting basic package");

Memory Leaks

In order to capture memory leaks in the application, extend the State class from custom class FnState (extend the first State class with FnInitialState class) provided along with the plugin.

class _MyAppState extends FnState<MyApp> { //Replace State class with FnState class.
    ....

}

Track UI block issues

This feature is automatically activated in the plugin. With basic integration Finotes will track and report UI/ Main thread blocks that can lead to App Not Responding (ANR) situations in Android along with AppHangs in iOS/iPadOS.

Report HTTP(s) Issues

FinotesCore plugin supports tracking HTTP(s) calls.

Add FnClient provided in plugin.

    import 'package:finotescoreplugin/fn_client.dart';


    ....
    var client = http.Client(); //Regular http client to make calls.

    var client = FnClient(); //Replace your http client with finotescoreplugin client.

Activity Trail

Activity markers are events that occur in an application during runtime. In order to capture lifecycle events of states used in the application, extend the State class from custom class FnState (extend the first State class with FnInitialState class) provided along with the plugin.

class _MyAppState extends FnState<MyApp> { //Replace State class with FnState class.
    ....

    @override
    Widget build(BuildContext context) {
        super.build(context); //Make sure to call the super here.
        return ..
    }
}

Settings custom activity trail

Developers can set custom activity trail markers anywhere in the app using Fn.setActivityMarker(). These markers will be shown along with the lifecycle events, when an issue is reported.

    Fn.setActivityMarker("Main App", "User tapped on payment button");

Enable Finotes Logs

You can activate internal Finotes logging using logMe() API. Activating logMe() API will print all logs generated by the plugin including error and warning logs.

    Fn.logMe();

When preparing for production release, make sure to remove the log API.