01/10/2025 10:53:00
Event Reporting Module
I. Overview
MSDK provides event data reporting for three channels: Adjust, Appsflyer and Beacon. Event reporting includes app installation, user-defined event, app uninstallation, etc.
II. Access Guide
2.0 Precondition
- Unity layer's CShalp file has been imported to Unity project
- Import iOS and Android related files into Unity project's directory: Assets/Plugins/iOS (Android)
- Recommended data reporting call process:
- Initialize SDK
- Initialize reporting channel
- Call event reporting interface to report, or automatically report exceptions when app crashes
2.1 Reporting Channel Initialization
1) Function Description
Initialize the reporting channel list; multiple channels are separated with comma, such as "Adjust,Appsflyer,Beacon".
2) Interface Declaration
public static bool Init (string channels)
static bool Init (const string &channels);
3) Parameter Description
Parameter name | Parameter type | Description |
---|---|---|
channels | string | list of reporting channels; multiple channels are separated with comma |
4) Demo code
string channels = "Beacon,Adjust,AppsFlyer";
MSDKReport.Init (channels);
string channels = "Adjust,Appsflyer,Beacon";
MSDKReport:: Init (channels);
2.2 Report Events
1) Function Description
Report the user-defined events. The Adjust channel needs to register events in the console in advance to get event key before it can report the events successfully
2) Interface Declaration
public static void ReportEvent(string eventName, Dictionary<string, string> paramsDic,string spChannels="", bool isRealTime=true)
static void ReportEvent(const string &eventName, std::map<std::string, std::string> params, const string &spChannel = "", bool isRealTime = true);
3) Parameter Description
Parameter Name | Parameter Type | Description |
---|---|---|
eventName | string | event 1. When Adjust channel reports data, EventToken must be filled in. For details, please refer to Adjust channel-Event Token (ID) acquisition description 2. When FireBase channel reports data, the report must start with an alphabetic character. For details, please refer to [Firebase description] (https: //firebase.google.com/docs /reference/cpp/namespace/firebase/analytics#logevent) 3. When Appsflyer channel reports data, the length of the data needs to be not more than 45 characters |
params | map | parameter |
spChannel | string | specified channel; fill in empty characters if there is no specified channel |
isRealTime | bool | whether to report in time (supported by Beacon channel only) true: enable; false: disable |
extraJson | string | The extended information must be a JSON structure. Only Adjust channel reporting pays attention to this parameter. If you use Adjust partner parameter, you need to use this parameter. Code example: "{\"isPartnerParameters\": true}". If this field is empty, or is set to false, then the reporting parameters will be set into Adjust's callback_params |
4) Demo code
Dictionary<string, string> paramsDic = new Dictionary<string, string> ();
paramsDic.Add ("k1", "v1");
paramsDic.Add("k2", "v2");
paramsDic.Add("k3", "v3");
MSDKReport.ReportEvent ("MSDK-EVENT-TEST", paramsDic, "", true);
std:: map<std:: string, std:: string> paramsDic;
paramsDic["k1"] = "v1";
paramsDic["k2"] = "v2";
paramsDic["k3"] = "v3";
MSDKReport:: ReportEvent ("MSDK-EVENT-TEST", paramsDic, "", true);
2.3 Binary reporting
Report binary files. This function is only supported by TDM Channel.
2.4 Set pushToken
1) Functional description
Set Firebase's pushToken for the uninstallation tracking function. Currently, adjust and appsflyer support this.
2) Interface declaration
public static void SetPushToken (string pushToken)
void MSDKReport::SetPushToken(const String &pushToken)
3) Description of input parameters
Parameter name | Parameter type | Description |
---|---|---|
pushToken | string | Firebase's token |
4) Demo code
MSDKReport.SetPushToken ("c72it0O-cmQ:APA91bGLNTzEinXfbzJvy55kC5fkpC2pchN_cvY1lh2MpbD6ptGzKkFJh0UhwveUVG8qokUV6NR7WavhFDpLuAwMdBdRvbSsegIFLETfv7z5knReouFxsVg32goTBPLYfKjkAKhKHdfu");
MSDKReport::SetPushToken ("c72it0O-cmQ:APA91bGLNTzEinXfbzJvy55kC5fkpC2pchN_cvY1lh2MpbD6ptGzKkFJh0UhwveUVG8qokUV6NR7WavhFDpLuAwMdBdRvbSsegIFLETfv7z5knReouFxsVg32goTBPLYfKjkAKhKHdfu");
2.5 Get Firebase's instanceID (V5.16)
1)Function description
Get Firebase's instanceID (Only support Firebase)
2)Interface Declaration
Get it through MSDKExtend, as follows:
// Add Extend's callback
MSDKExtend.ExtendRetEvent += mExtendCallBack.OnExtendRetEvent;
// Call getInstanceIDAsync
MSDKExtend.Invoke ("Firebase", "getInstanceIDAsync", "");
// Get the result in the callback of Extend; the result is in extendRet.extraJson, and its json format is as follows: {"instanceID": "xxxxxxx"}
public void OnExtendRetEvent (MSDKExtendRet extendRet)
{
string methodTag = extendRet.ExtendMethodName;
mCurrentTestMgr.ShowLogInNewLine (methodTag + Tools.Instance.GetRetString(extendRet));
}
// Add Extend's callback
MSDKExtend::SetExtendObserver(new MyExtendObserver());
// Call getInstanceIDAsync
MSDKExtend::Invoke("Firebase", "getInstanceIDAsync", "");
// Get the result in the callback of Extend; the result is in extendRet.extraJson, and its json format is as follows: {"instanceID": "xxxxxxx"}
class MyExtendObserver : public GCloud::MSDK::MSDKExtendObserver {
public:
void OnExtendNotify(const MSDKExtendRet &extendRet) {
handleCallback(extendRet, extendRet.methodNameID);
};
};
2.6 Get Firebase's instanceID (Only support Firebase)
Important: The GetInstanceID interface mentioned in this chapter has been obsolete since MSDKV5.16. Please use 'getInstanceIDAsync' mentioned in chapter 2.5 to get 'InstanceID'1) Function description
Get Firebase's instanceID (Only support Firebase)
2) Interface Declaration
public static string GetInstanceID(string channel)
std::string GetInstanceID(const String &channel);
3) Input parameter description
Parameter name | Parameter type | Description |
---|---|---|
channel | string | channel name;fill in here (Firebase) |
4) Demo code
string instanceID = MSDKReport.GetInstanceID(channel );
std::string instanceID = MSDKReport::GetInstanceID(channel);
All rights reserved.