Logging a Custom Event
You may keep a numeric value, a text value, or a collection of name/value string pairs every time an event is reported. This can be used, for example in the case of ruiTrackEventNumeric(), to keep track of the length of time it took to save a file, or the file size that was saved, etc. These events can be recorded using the functions ruiTrackEventNumeric(), ruiTrackEventText(), and ruiTrackEventCustom() respectively.
The ruiTrackEventCustom() function logs a normal event with the supplied data, including an array of custom name/value pairs.
The ruiTrackEventCustom() function can be called between ruiStartSDK() and ruiStopSDK(), and can be called zero or more times.
The ruiTrackEventCustom() function can be called while a New Registration is being performed (ruiCreateConfig(), ruiStartSDK()). However, the event data is not written to the log file until the New Registration completes, and if the New Registration fails, the data will be lost.
The ruiTrackEventCustom() function is an asynchronous function, returning immediately with further functionality executed on separate thread(s).
The name/value pairs are supplied in a struct of type RUINAMEVALUEPAIR. The struct contains two fields:
const char* name;
const char* value;
Note:Custom data will be logged in the format (Key1,Value1)&&(Key2,Value2)…&&(KeyN,ValueN).
RUIRESULT ruiTrackEventCustom(RUIINSTANCE* ruiInstance, const char* eventCategory, const char* eventName, RUINAMEVALUEPAIR* customValue, uint32_t numValues, const char* sessionID)
Parameters
The ruiTrackEventCustom() function has the following parameters.
Parameter |
Description |
|||||||||||||||
ruiInstance (RUIINSTANCE* |
Pointer to the RUI instance created via ruiCreateInstance(). |
|||||||||||||||
eventCategory (const char*) |
The name of the category that this event forms part of. This parameter is optional (send empty string if not required). Unlike V4 of the Usage Intelligence SDK, there is no concept of extended names (for eventCategory and eventName). The content of eventCategory and eventName is conditioned and validated (after conditioning) with the following rules:
|
|||||||||||||||
eventName (const char*) |
The name of the event to be tracked. Unlike V4 of the Usage Intelligence SDK, there is no concept of extended names (for eventCategory and eventName). The content of eventCategory and eventName is conditioned and validated (after conditioning) with the following rules:
|
|||||||||||||||
customValues (RUINAMEVALUEPAIR*) |
Custom data associated with the event. A given name and/or value can be empty. A given name cannot contain white space. All names and values are trimmed to a maximum length determined by the Server. Both names and values have a default maximum of 128 UTF-8 characters. |
|||||||||||||||
numValues (uint32_t) |
The size of the customValues array (i.e., the number of name/value pairs). Cannot be 0. |
|||||||||||||||
sessionID (const char*) |
If multiple user sessions are supported within the application (multiSessionEnabled = true), this should contain the unique ID that refers to the user session in which the event occurred. It must be a current valid value used in ruiStartSession. If the application supports only a single session (multiSessionEnabled = false), then this value should be empty. |
Returns
The ruiTrackEventCustom() function returns one of the return status constants below.
Return |
Description |
RUI_OK |
Synchronous functionality successful. |
RUI_INVALID_SDK_OBJECT |
SDK Instance parameter is NULL or invalid. |
RUI_SDK_INTERNAL_ERROR_FATAL |
Irrecoverable internal fatal error. No further API calls should be made. |
RUI_SDK_ABORTED |
A required New Registration has failed, and hence the SDK is aborted. ruiStopSDK() and ruiDestroyInstance() are possible. |
RUI_SDK_SUSPENDED |
The Server has instructed a temporary back-off. |
RUI_SDK_PERMANENTLY_DISABLED |
The Server has instructed a permanent disable. |
RUI_SDK_OPTED_OUT |
Instance has been instructed by the application to opt-out. |
RUI_CONFIG_NOT_CREATED |
Configuration has not been successfully created. |
RUI_SDK_NOT_STARTED |
SDK has not been successfully started. |
RUI_SDK_ALREADY_STOPPED |
SDK has already been successfully stopped. |
RUI_INVALID_SESSION_ID_EXPECTED_EMPTY |
The sessionID is expected to be empty, and it was not. |
RUI_INVALID_SESSION_ID_EXPECTED_NON_EMPTY |
The sessionID is expected to be non-empty, and it was not. |
RUI_INVALID_SESSION_ID_TOO_SHORT |
The sessionID violates its allowable minimum length. |
RUI_INVALID_SESSION_ID_TOO_LONG |
The sessionID violates its allowable maximum length. |
RUI_INVALID_SESSION_ID_NOT_ACTIVE |
Parameter validation: The sessionID is not currently in use. |
RUI_INVALID_PARAMETER_EXPECTED_NON_EMPTY |
Parameter validation: Some API parameter is expected to be non-empty, and is not. |
RUI_INVALID_PARAMETER_EXPECTED_NO_WHITESPACE |
Some API parameter is expected to be free of white space, and is not. |