All Products
Search
Document Center

Mobile Platform as a Service:Active device/user log

Last Updated:Jan 28, 2023

This topic describes how to add active device/user reporting log.

The logs are classified into two categories:

  • Active device log: calculate the number of devices where the app is started.

  • Active user log: calculate the number of users who log in to the app.

After these logs are reported, you can view indicators such as the number of active users, number of new users, and number of active accounts on the Mobile Analysis Service > Data overview page.

Active device reporting

The mPaaS framework automatically reports the data of active devices, you don't have to handle it. To stop automatic log reporting, you just need to add the following content (only works in baseline 10.1.68.30 and later versions) in the file AndroidManifest.xml.

<meta-data
    android:name="report.launch.switch"
    android:value="off" />

After you stop automatic log reporting, you can customize the time to report logs, for example:

MPLogger.reportClientLaunch();

When an app returns to the frontend from the backend, another active device is counted if the interval since the last reporting exceeds the specified interval (30 minutes by default).

You can customize a reporting interval in milliseconds, for example:

MPLogger.setReportClientLaunchInterval(long interval);

If the active device reporting API is called several times within the reporting interval, only the first call takes effect.

Active user reporting

The code for reporting active users is as follows:

MPLogger.reportUserLogin(String userId);

userId uniquely identifies a user who logs in to your App. You can call the active user reporting API after successful user login or after you obtain userId in another way.

After you call the active user reporting API, userId is set in the code. That is, userId is set successfully. In addition, you can also set userId separately by calling the following method.

The method for setting a user ID is as follows:

MPLogger.setUserId(String userId);

After setting a userId, you can add the userId to a whitelist created under Mobile Delivery Service > Whitelist management in the mPaaS console.

When the user logs out, call MPLogger.setUserId(null) to delete the userId so as to ensure the accuracy of relevant data.