Jump to: navigation, search

Analytic System APIs

Relative APIs

Session analytics

When using the data analytic system, you need to add call methods as follows at least. These calls is used to follow accurately the users’ operation to app each time, which is the foundation of accurate analytics on start, active and retained data.
Call startSession() in each onResume method belongs to Activity of the application. It is used to follow the opening and jumping operation of users.
Call stopSession() in each onPause method belongs to Activity of the application. It is used to follow the leaving and exiting operation of users.
@Override
protected void onStop() {
// TODO Auto-generated method stub
	super.onStop();
	 wrapper.nativeStopSession();
}	
	 
@Override
protected void onResume() {
	// TODO Auto-generated method stub	
	super.onResume();
	wrapper.nativeStartSession();
}


void Java_com_anysdk_sample_wrapper_nativeStartSession(JNIEnv*  env, jobject thiz)
{
	if(AgentManager::getInstance()->getAnalyticsPlugin())
	{
		AgentManager::getInstance()->getAnalyticsPlugin()->startSession();
	}
}

void Java_com_anysdk_sample_wrapper_nativeStopSession(JNIEnv*  env, jobject thiz)
{
	f(AgentManager::getInstance()->getAnalyticsPlugin())
	{
		AgentManager::getInstance()->getAnalyticsPlugin()->stopSession();
	}
}

Note: 1. Ensure to call startSession() and stopSession() methods in each Activity. These calls won’t block the main thread of apps or influence the performance of apps. 2. If your Activities have the relationship of inheritance or control, please do not add operations on both parent and child activity at the same time, or it will cause repetitive analytics.

Custom event

Custom event could realize the analytics of user clicking behavior by buried points in apps. Meanwhile custom event also support to add some descriptive attribute parameters, Pass with the method of multiple Key-Value (optional),use to analyze detailedly of the event status.
1.The dependencies of the usage of custom event
a.Please add the relative event in the analytic SDK management background when using custom event function. Then the server will deal with the corresponding event request.
b.The code of custom event should be written behind onResume method of Activity.
AgentManager::getInstance()->getAnalyticsPlugin()->logEvent(const char* eventId);
event_id is the current analytic event ID. Please notice that there should be no space or other escape characters in event_id.
To add detailed descriptions in the event could analyze the triggered conditions and scene of event more effectively. Code could be added as follows.
AgentManager::getInstance()->getAnalyticsPlugin()->logEvent(const char* eventId, LogEventParamMap* paramMap);

LogEventParamMap is the type of std::map< std::string, std::string >

Response time configuration

When the time of twice usages is too long, they are deemed to be two seperated sessions. For example, if the user choose to go back home, or enter other procedures. After a while he back to the previous app. He could configuration these gap(param unit is millisecond) through the interface: setSessionContinueMillis(long interval)
void Analytics::setSessionContinueMillis(long millis)
{
	if(AgentManager::getInstance()->getAnalyticsPlugin())
	{
		AgentManager::getInstance()->getAnalyticsPlugin()->setSessionContinueMillis(millis);
	}

}


Application error log collection  

To collect the application error log could help you to fix the bugs and to improve your products. In the report, we not only provide the error number data, but also provide the detailed information of errors for you to read, and make reasonable classification of errors.
SDK automatically access to exception information.
In order to simplify the work of developers, we provide the function of automatic abnormal information. However, considering the abnormal information collection would cause the loss of user flow, automatically capture is closed by default.  
You can import true(open the automatically capture) or false (close the automatically capture) to control the automatically capture function by methods as follows:
void setCaptureUncaughtException(bool enabled);
void Analytics::setCaptureUncaughtException(bool isEnabled)
{
	if(AgentManager::getInstance()->getAnalyticsPlugin())
	{
		AgentManager::getInstance()->getAnalyticsPlugin()->setCaptureUncaughtException(true);
	}

}
Passing Exception Information Actively  
void logError(const char* errorId, const char* message);
{
	if(AgentManager::getInstance()->getAnalyticsPlugin())
	{
		AgentManager::getInstance()->getAnalyticsPlugin()->logError(errorId.c_str(),message.c_str());
	}

}