Configuration

Start/Stop data collection

After calling the run method the SDKs start data collection and
data transferring to the web service. From that point you can see
your session in the AppSpector client.

Since plugin initialization should locate in the main function we provide
methods to help you control AppSpector state by calling stop() and start() methods.

You are able to use these methods only after AppSpector was initialized.

The stop() tells AppSpector to disable all data collection and close current session:

await AppSpectorPlugin.shared().stop();

The start() starts it again using config you provided at initialization:

await AppSpectorPlugin.shared().start();

As the result new session will be created and all activity between
stop() and start() calls will not be tracked.

To check AppSpector state you can use isStarted() method:

await AppSpectorPlugin.shared().isStarted();

Custom device name

You can assign a custom name to your device to easily find needed sessions
in the sessions list. To do this you should add the desired name as a value
for MetadataKeys.deviceName key to the metadata dictionary:

void runAppSpector() {
  var config = new Config()
    ..iosApiKey = "Your iOS API_KEY"
    ..androidApiKey = "Your Android API_KEY"
    ..metadata = {MetadataKeys.deviceName: "CustomName"};
  
  AppSpectorPlugin.run(config);
}

Also, the plugin allows managing the device name during application lifetime using
the setMetadataValue method to change device name:

AppSpectorPlugin.shared().setMetadataValue(MetadataKeys.deviceName, "New Device Name");

or the removeMetadataValue to remove your custom device name:

AppSpectorPlugin.shared().removeMetadataValue(MetadataKeys.deviceName);

Getting session URL

Sometimes you may need to get URL pointing to current session from code.
Say you want link crash in your crash reporter with it, write it to logs or
display in your debug UI. To get this URL you have to add a session start callback:

AppSpectorPlugin.shared()?.sessionUrlListener = (sessionUrl) => {
// Save url for future use...
};

Correct SQLite setup for the SDK

The SQLite monitor on Android demands that any DB files are located at the database folder.
So, if you're using sqflite the code for opening db will be looks like that:

var dbPath = await getDatabasesPath() + "/my_database_name";
var db = await openDatabase(dbPath, version: 1, onCreate: _onCreate);

The getDatabasesPath() method is imported from package:sqflite/sqflite.dart.