Passing metric relevant information to the SDK

The SDK collects certain metrics about the user behavior, such as the current tracking mode, the number of interactions with the app and whether push notifications will be visible to the user. For some metrics, the SDK needs to be notified about changes as it not able determine the status on its own. This happens by calling the dedicated methods in the SDK, which register and persist the new status. The sending of the metrics to the Bitplaces backend happens automatically.

As an app developer, it is your responsibility to notify the SDK about changes of the metrics. Otherwise, the metrics shown in the Bitplaces Analytics Dashboard will not be correct. For the methods to succeed, the SDK has to already be initialized, which will be described in the next section. Currently, the SDK needs to be informed about the following two events.

Customizing Metrics Tracking

You can customize which metrics will be collected and sent back to the Bitplaces backend by passing a MetricPreferences to the BitplacesSDK.getInstance().setMetricPreferences-method. Although more metrics are available in the MetricPreferences, only the following ones will be used the BitplacesSDK. Functionality for the other ones will be added at a later point in time.

  • MonitoringStatus
  • PushNotification
  • LocationPermission
  • AppOpenings
  • Current Country
  • Network operator
  • Android statistics (version, locale, bluetooth)

Take note that you can individually turn off the metrics by setting the values to false

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
//turn off te metrics by setting the paramters to false eg .setSendAppLocale(false)
MetricPreferences metricPreferences = new MetricPreferences.MetricPreferencesBuilder()
    .setSendMonitoringStatus(true)
    .setSendLocationPermission(true)
    .setSendAppOpenings(true)
    .setSendAndroidModel(true)
    .setSendAndroidVersion(true)
    .setSendManufacturer(true)
    .setSendNetworkOperatorInformation(true)
    .setSendAppLocale(true)
    .setSendAppCountryISO(true)
    .setSendPushNotificationVisibility(true)
    .build();

BitplacesSDK.getInstance().setMetricPreferences(metricPreferences)

User interaction

The SDK collects various metrics about when and how often an app is visible to the user. For this purpose, it is necessary, that you call BitplacesSDK.getInstance().registerAppInteraction() in the onStart() method of your app´s main activity as well as all other activities, that are relevant to the BitplacesSDK. In particular, this means your app´s Inbox, where the user´s messages are shown, the detail screen for each message, or other activities, that are reachable without opening one of the activities mentioned before. If you are using the Android Toolbox, then you only need to take care of your own activities, as the Inbox and detail screen will automatically do this.

1
2
3
4
5
6
@Override
protected void onStart() {
    super.onStart();
    BitplacesSDK.getInstance().registerAppInteraction();
    ...
}

Take note that the metrics will collected and sent to the server automatically.

Enabling & disabling metrics

The default behaviour of the SDK is to send metrics. If this functionality is not required it is recommended to turn it off by simply disabling the metrics as follows.

1
BitplacesSDK.setMetricsEnabled(false)

This will override the metrics preferences.

Push notifications

The BitplacesSDK also tracks, whether the user will see push notifications. This typically corresponds to the setting in you own app´s settings or some other screen, where the user can choose, if we want to receive the notifications. During the first start of your app, and upon each subsequent change of this settings, notify the SDK via BitplacesSDK.getInstance().changedPushNotificationVisibility(boolean) about the new status of this metric.