SmartBeat

Includes:
<Foundation/Foundation.h>
<UIKit/UIKit.h>

Introduction

The SmartBeat API provides an initilization interface and configuration interface. Use these APIs to enable SmartBeat functionality. Please be sure to include the following frameworks in your project to use SmartBeat.

  • CoreLocation.framework

  • SystemConfiguration.framework

  • CoreTelephony.framework



Functions

SBLog

Puts a log message in the SmartBeat SDK.

SBLogv

Puts a log message in the SmartBeat SDK. (takes va_list)


SBLog


Puts a log message in the SmartBeat SDK.

void SBLog(
    NSString *format,
    ...);  
Parameters
format

A log format like printf

...

Log arguments

Discussion

If enableNSLog is called, logs by this function are ignored and logs by NSLog() are used instead. However, logs by this function are always used on iOS 10 and above.

If you want to use this function instead of NSLog(), it is usefull to define the following macro in your application's Prefix.pch.

#define NSLog(...) (NSLog(__VA_ARGS__), SBLog(__VA_ARGS__))

Swift can not treatment C style variable length arguments, so please use SBLogv.


SBLogv


Puts a log message in the SmartBeat SDK. (takes va_list)

void SBLogv(
    NSString *format,
    va_list args);  
Parameters
format

A log format like printf

args

Log arguments

Discussion

If enableNSLog is called, logs by this function are ignored and logs by NSLog() are used instead. However, logs by this function are always used on iOS 10 and above.

In Swift, please use with getVaList() as below.

SBLogv("String: %@, Integer: %d", getVaList(["text", 1]))

Methods

+addSensitiveViewTag:

Add tag of sensitive view. Screen capture is skipped if the view with tag is included in keywindow view hierarchy. NOTE "0" cannot be added because it's default tag id.

+afterPresentRenderbuffer

Call this API right after calling presentRenderbuffer in your rendering loop when taking OpenGL screen captures.

+beforePresentRenderbuffer:

Call this API right before calling presentRenderbuffer in your rendering loop to take OpenGL screen captures.

+disable

Disable saving/sending Crash/Exception/Captured image.

+disableAutoScreenCapture

Disable auto screen capture. Call this method to stop automatic screen captures.

+enable

Enable saving/sending Crash/Exception/Captured image.

+enableAutoScreenCapture

Enable auto screen capture. If this option is enabled screenshots will be taken automatically every second and sent to server when a crash occurs. At most the last 3 screenshots will be sent.

+enableDebugLog

Enable SmartBeat debug log. If this option is enabled the SmartBeat library will print debug entries to NSLog.

+enableNSLog

Enable sending NSLog contents to SmartBeat server with crash reports. If this option is enabled the content of the system log is sent in the crash report when a crash occurs.

+getSdkVersion

Get current SDK version

+isEnabled

Return if saving/sending Crash/Exception/Captured image is enabled.

+isWhiteListed

Check if this device is listed in white list for OpenGL screen capture.

+leaveBreadcrumb:

Leave a breadcrumb. When a crash occurs, the last 16 breadcrumbs to be set will be sent with the crash report.

+logException:

Send exception data handled by application code to the SmartBeat server.

+logException:withExtraData:

Send exception data handled by application code with any extra data to SmartBeat server.

+logExceptionForCocos2dJS:withName:withMessage:withAuxData:

This method is not public. It may be called from your Cocos2d-JS guru code.

+logExceptionForUnity:withMessage:withImagePath:

This method is not public. It may be called from your unity guru code.

+notifyRunning

Notifies the SmartBeat server that an application is running in the background.

+removeSensitiveViewTag:

Remove tag of sensitive view.

+setExtraData:

Set extra data set that will be sent with crash data.

+setUserId:

Set user unique identifier. Any string can be set. If a user ID has been set it will be included in the crash report.

+shared

Get the SmartBeat instance. Note that you must initilize the SmartBeat instance by calling "startWithApiKey" before calling this method.

+startWithApiKey:

Create and initilize a new SmartBeat instance. This method must be called before calling other SmartBeat methods.

+startWithApiKey:withEnabled:

Create and initilize a new SmartBeat instance with initial control. This method must be called before calling other SmartBeat methods.

+whiteListModelForOpenGLES:

OpenGLES capture will only be enabled for whitelisted model names. Use this interface to register additional model names to the default whitelist. Model names can be acquired by using the sysctlbyname() function with "hw.machine".


addSensitiveViewTag:


Add tag of sensitive view. Screen capture is skipped if the view with tag is included in keywindow view hierarchy. NOTE "0" cannot be added because it's default tag id.

- (void) addSensitiveViewTag:(NSInteger) tag;  
Parameters
tag

The tag id of view that screen capture shouldn't be taken.


afterPresentRenderbuffer


Call this API right after calling presentRenderbuffer in your rendering loop when taking OpenGL screen captures.

- (void) afterPresentRenderbuffer;  

beforePresentRenderbuffer:


Call this API right before calling presentRenderbuffer in your rendering loop to take OpenGL screen captures.

- (void) beforePresentRenderbuffer:(UIView *)view;  
Parameters
view

The UIView to be rendered.


disable


Disable saving/sending Crash/Exception/Captured image.

- (void) disable;  

disableAutoScreenCapture


Disable auto screen capture. Call this method to stop automatic screen captures.

- (void) disableAutoScreenCapture;  

enable


Enable saving/sending Crash/Exception/Captured image.

- (void) enable;  

enableAutoScreenCapture


Enable auto screen capture. If this option is enabled screenshots will be taken automatically every second and sent to server when a crash occurs. At most the last 3 screenshots will be sent.

- (void) enableAutoScreenCapture;  

enableDebugLog


Enable SmartBeat debug log. If this option is enabled the SmartBeat library will print debug entries to NSLog.

- (void) enableDebugLog;  

enableNSLog


Enable sending NSLog contents to SmartBeat server with crash reports. If this option is enabled the content of the system log is sent in the crash report when a crash occurs.

- (void) enableNSLog;  

getSdkVersion


Get current SDK version

- (NSString *)getSdkVersion;  
Return Value

returns current SDK version.


isEnabled


Return if saving/sending Crash/Exception/Captured image is enabled.

- (BOOL) isEnabled;  
Return Value

YES if saving/sending Crash/Exception/Captured image is enabled, NO otherwise.


isWhiteListed


Check if this device is listed in white list for OpenGL screen capture.

- (BOOL) isWhiteListed;  
Return Value

YES if it is enabled, NO otherwise.


leaveBreadcrumb:


Leave a breadcrumb. When a crash occurs, the last 16 breadcrumbs to be set will be sent with the crash report.

- (void) leaveBreadcrumb: (NSString *) breadcrumb;  
Parameters
breadcrumb

A string shall be set as a breadcrumb


logException:


Send exception data handled by application code to the SmartBeat server.

- (void) logException: (NSException *) exception;  
Parameters
exception

The exception that is handled by the application.


logException:withExtraData:


Send exception data handled by application code with any extra data to SmartBeat server.

- (void) logException: (NSException *) exception 
        withExtraData:(NSDictionary *) extraData;  
Parameters
exception

The exception that is handled by the application.

extraData

The extraData set that should be sent to server with exception data. Note that extraData set by "setExtraData" won't be sent.


logExceptionForCocos2dJS:withName:withMessage:withAuxData:


This method is not public. It may be called from your Cocos2d-JS guru code.

- (void) logExceptionForCocos2dJS: (NSString *) stackTrace 
        withName:(NSString *) name withMessage:(NSString *) message 
        withAuxData:(NSDictionary *) auxData;  

logExceptionForUnity:withMessage:withImagePath:


This method is not public. It may be called from your unity guru code.

- (void) logExceptionForUnity: (NSString *) stackTrace 
        withMessage:(NSString *) message withImagePath:(NSString *) imagePath;  

notifyRunning


Notifies the SmartBeat server that an application is running in the background.

- (void) notifyRunning;  
Discussion

If your application supports background modes, call this method when the background task is invoked.


removeSensitiveViewTag:


Remove tag of sensitive view.

- (void) removeSensitiveViewTag:(NSInteger) tag;  
Parameters
tag

setExtraData:


Set extra data set that will be sent with crash data.

- (void) setExtraData: (NSDictionary *) extraData;  
Parameters
extraData

Set of keys/values. A string represented by description method is logged.


setUserId:


Set user unique identifier. Any string can be set. If a user ID has been set it will be included in the crash report.

- (void) setUserId:(NSString *) userId;  
Parameters
userId

A unique user ID string used by your application.


shared


Get the SmartBeat instance. Note that you must initilize the SmartBeat instance by calling "startWithApiKey" before calling this method.

+ (SmartBeat *) shared;  
Return Value

Returns the instance of SmartBeat object if it is already initilized or nil if it is not initilized.


startWithApiKey:


Create and initilize a new SmartBeat instance. This method must be called before calling other SmartBeat methods.

+ (SmartBeat *) startWithApiKey:(NSString *) apiKey;  
Parameters
apiKey

The API key for your application. You can find your API key on the settings screen of the SmartBeat web console.

Return Value

Returns the newly initialized SmartBeat object or nil on error.


startWithApiKey:withEnabled:


Create and initilize a new SmartBeat instance with initial control. This method must be called before calling other SmartBeat methods.

+ (SmartBeat *) startWithApiKey:(NSString *) apiKey 
        withEnabled:(BOOL) enabled;  
Parameters
apiKey

The API key for your application. You can find your API key on the settings screen of the SmartBeat web console.

enabled

NO if saving/sending Crash/Exception/Captured image shall be disabled by default.

Return Value

Returns the newly initialized SmartBeat object or nil on error.


whiteListModelForOpenGLES:


OpenGLES capture will only be enabled for whitelisted model names. Use this interface to register additional model names to the default whitelist. Model names can be acquired by using the sysctlbyname() function with "hw.machine".

- (void) whiteListModelForOpenGLES:(NSString *)model;  
Parameters
model

The model name to enable for OpenGL screen capture.