Cordova/Monaca SDK

1. Supported Cordova Versions

This SDK supports Cordova 5.0 and above.

Android Platform Requirements:
* Cordova-android platform 3.6.4 and above.
* Android SDK 4.4 (android-19) and above.

iOS Platform Requirements:
* Cordova-ios platform 3.7.0 and above.
* OS X El Capitan and above
* XCode 7.0 and above.

Monaca Platform Requirements
※ The Cordova version used by a Monaca project must meet the above requirements.
※ Your Monaca plan must support user installed Cordova plugins.

2. Cordova/Monaca Project Integration

Step1:SDK Integration

  • Cordova
  • Monaca
From the project folder, execute the commands below, or add the shown plugins via your IDE.

cordova plugin add cordova-plugin-smartbeat-plus

※ When using 'cordova-plugin-smartbeat-plus'、the device's IDFA will be used. If using IDFA is not desired, use 'cordova-plugin-smartbeat' instead. The audience function will be disabled if IDFA is not used.

From the IDE Menu, select Configure > Cordova Plugin Settings... to open the Cordova Plugins page; from there, click Import Cordova Plugin.

Select Specify URL or Package Name and enter "cordova-plugin-smartbeat-plus" in the Package Name/URL field, then click OK.

※ When using 'cordova-plugin-smartbeat-plus'、the device's IDFA will be used. If using IDFA is not desired, use 'cordova-plugin-smartbeat' instead. The audience function will be disabled if IDFA is not used.

Step2:Setting the API Key

Modify the file www/js/index.js or your application's main JS file to catch the Cordova ondeviceready event, and after substituting the API Key(s) from the SmartBeat console, include the following code in that method:

SmartBeat.startWithApiKey({android: "Android Api Key", ios: "iOS API Key"});

Step3:Duplicate User Count Prevention

No additional steps are necessary when using Cordova SDK 1.3.10 and later. Duplicate users are determined automatically. Because of this, unwanted increases in MAU(Monthly Active Users) will be suppressed even if an applications is repeatedly re-installed. (Commonly referred to as a "reset marathon")

Step4(iOS):Audience feature settings

By using Advertising ID for Android or IDFA for iOS, it's possible to understand the gender and age distribution of your users.

How to use

In Step1, if 'cordova-plugin-smartbeat-plus' was specified, then no additional steps are necessary.

3. Extra functions

3.1 Log Handled Exceptions

SDK Version 1.2.0 and up

SmartBeat supports handed exceptions logging.

How to use
try {
    throw new Error();
} catch (e) {
    SmartBeat.logException(e);
}

3.2 Logging Output

Logs will be gathered internally, and not output to the device log.
*The most recent 64KB or 500 lines of log will be included in crash reports.

How to use

Output logs using the following API calls.

Smartbeat.log("Log message here");

3.3 User ID Setting

If your application provides a user ID for each user, you can include it with crash/exception data. That help you find specific user’s errors by using this user ID on the SmartBeat web console.

How to use

In order to set user ID, call the API below:

SmartBeat.setUserId("user001");

3.4 Extra Data Setting

You have another option to add extra custom information into the crash/exception reports. This will help you reproduce and fix errors. (e.g. user’s entering parameters, API return values etc.)

How to use

In order to set a key and a value with crash data, call the API below:

SmartBeat.setExtraData("key","value");

3.5 Leaving Breadcrumbs

You can know what the user did by adding breadcrumbs at any point.

How to use

Call the following API where you'd like to leave a breadcrumb.

SmartBeat.leaveBreadcrumb:("game scene 1");

Only last 128 breadcrumbs are saved and displayed on SmartBeat console.
Typical actions and status changes are automatically recorded as breadcrumbs. Please see here (Android / iOS) for details of what is recorded.