Web SDK

1. Supported Browsers

Browser Supported Version
Apple Safari (Mac) 8 or later
Apple Safari (iOS) 7 or later
Google Chrome 52 or later
Google Chrome (Android) 51 or later
Internet Explorer 10 or later
Microsoft Edge 10 or later
Mozilla Firefox 47 or later
Opera 41 or later

2. Integrating the API into a HTML page

Insert the following tags within the body tag of the HTML page. Multiple invocations will have no effect.

<script src="https://assets.smrtbeat.com/scripts/v2/smartbeat.min.js"></script>
<script type="application/javascript">
    // Initialize the API
    SmartBeat.init("<API Key from the SmartBeat console>","<App version, IE:1.1.25>","<App Name or BundleID>");
</script>

Caution: When using obfuscation, the app version field is used as a differentiator during mapping, so please use unique version numbers. Effective error management and statistics are also made possible by unique version numbers.

3. Optional Features

3.1 Reporting thrown exceptions

Caught exceptions may optionally be reported to the SmartBeat system.
Repeated usage of this API will result in increased network usage, and may impact app performance, so it's not recommended to use this API for exceptions which occur very frequently.

How to activate
try {
    // Code which may throw an exception
} catch (error) {
    SmartBeat.handledException(error.message, error.fileName, error.lineNumber, error.columnNumber, error);
}

3.2 Logging

It's possible to leave log messages without outputting anything to the javascript console log.
*The most recent 64KB or 500 lines of log output will be saved.
*It's possible to log both String and Object types. Objects will be converted to JSON then logged.

How to activate

Log messages may be output using the following API.

// Outputting String messages
SmartBeat.log("Log Message");
// Outputting Object messages. The resulting JSON is saved to the log.
var someObject = {some: "object"};
SmartBeat.log(someObject);

3.3 Capturing console logs

Capturing the console log using the following API will overwrite the window.console logging functions. There is a performance penalty for doing this, roughly 8-10us per message. (Performance measured on a 2.7GHz Intel Core i7 using Safari, Firefox and Chrome)

How to activate
SmartBeat.delegateLog(window.console);

*As it's only necessary to use this API once, using this method during app initialization is recommended.

3.4 Stopping browser console logging

After enabling the delegateLog API, it's possible to restrict console message and error logging.

How to activate/deactivate
SmartBeat.delegateLog(window.console);
SmartBeat.enableConsolePassthrough(false);

To re-enable console logging, use the following API.

SmartBeat.enableConsolePassthrough(true);

3.5 Restricting log output by severity

This API will limit log output by the severity of the logged message. (Messages displayed on the javascript console are unaffected)

How to activate
SmartBeat.enableLoggingPriorities([SmartBeat.LOG_LEVEL.ERROR,SmartBeat.LOG_LEVEL.WARN]);

3.6 Setting the User ID

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

How to activate

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

SmartBeat.setUser("user id");

3.7 Add extra data

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

How to activate

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

SmartBeat.addExtraData("key1", "value1");

The value will be overwritten by a new one if you supply the same key.

3.8 Breadcrumb function

It's possible to track user behavior by leaving breadcrumbs to indicate user behavior.
*The most recent 16 breadcrumbs are recorded.
*Including the separator |(pipe character) between breadcrumbs, up to 255 characters are recorded.

How to activate

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

SmartBeat.leaveBreadcrumb("game scene 1");

If you leave breadcrumbs when the screen transition (IE: :Map screen -> Game screen -> Setting screen), you can determine the screen transition history just before the error occurred.

3.9 Mapping file upload

By embedding the provided "mapping File Upload script" in your build environment, a mapping file will be automatically uploaded for every build.

For more details, please check the provided readme file.

3.10 Screen Capture Function

When this function is active, a screenshot will be saved and sent to the SmartBeat server along with the error information.
*The screen capture function does not send the actual user's screen, but due to security constraints a recreation of the DOM based on an HTML canvas.
*Due to security constraints, the capture may appear blank (background color) in places where resources from other sites would otherwise appear.

How to activate

To enable or disable the Screen Capture Function, call the API below:

SmartBeat.enableScreenCapture();
SmartBeat.disableScreenCapture();