数数和AF打通

This commit is contained in:
chenxi 2023-06-21 10:30:45 +08:00
parent f15e3f6c11
commit 22549903c5
5 changed files with 78 additions and 3 deletions

View File

@ -27,6 +27,7 @@ namespace BF
public void SetThinkingAnalyticsAccountId(string id) public void SetThinkingAnalyticsAccountId(string id)
{ {
TASdk.SetAccountId(id); TASdk.SetAccountId(id);
AFSdk.SetTaAccountId(id);
} }
// 清除账户id // 清除账户id

View File

@ -9,7 +9,10 @@ namespace BF.NativeCore.ThirdPlatform
{ {
public void Init() public void Init()
{ {
// Debug.Log("AppsFlyerSdk Init version = " + AppsFlyer.getSdkVersion()); // 打通TA和AF的设置,要在AF初始化之前执行
var customData = new Dictionary<string, string>();
customData.Add("ta_distinct_id", ThinkingAnalyticsAPI.GetDistinctId());
AppsFlyer.setAdditionalData(customData);
AppsFlyer.setCustomerIdAndStartSDK(ThinkingAnalyticsAPI.GetDeviceId()); AppsFlyer.setCustomerIdAndStartSDK(ThinkingAnalyticsAPI.GetDeviceId());
} }
@ -17,5 +20,13 @@ namespace BF.NativeCore.ThirdPlatform
{ {
AppsFlyer.sendEvent(eventName, properties); AppsFlyer.sendEvent(eventName, properties);
} }
public void SetTaAccountId(string accountId)
{
var customData = new Dictionary<string, string>();
customData.Add("ta_distinct_id", ThinkingAnalyticsAPI.GetDistinctId());
customData.Add("ta_account_id", accountId);
AppsFlyer.setAdditionalData(customData);
}
} }
} }

View File

@ -40,5 +40,10 @@ namespace BF.NativeCore.ThirdPlatform
{ {
ThinkingAnalyticsAPI.Track(eventName, properties, date, appId); ThinkingAnalyticsAPI.Track(eventName, properties, date, appId);
} }
public string GetDistinctId()
{
return ThinkingAnalyticsAPI.GetDistinctId();
}
} }
} }

View File

@ -21,10 +21,11 @@ namespace XLua.CSObjectWrap
{ {
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
System.Type type = typeof(BF.NativeCore.ThirdPlatform.AppsFlyerSdk); System.Type type = typeof(BF.NativeCore.ThirdPlatform.AppsFlyerSdk);
Utils.BeginObjectRegister(type, L, translator, 0, 2, 0, 0); Utils.BeginObjectRegister(type, L, translator, 0, 3, 0, 0);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Init", _m_Init); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Init", _m_Init);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "SendEvent", _m_SendEvent); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SendEvent", _m_SendEvent);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetTaAccountId", _m_SetTaAccountId);
@ -129,6 +130,34 @@ namespace XLua.CSObjectWrap
} }
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
static int _m_SetTaAccountId(RealStatePtr L)
{
try {
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
BF.NativeCore.ThirdPlatform.AppsFlyerSdk gen_to_be_invoked = (BF.NativeCore.ThirdPlatform.AppsFlyerSdk)translator.FastGetCSObj(L, 1);
{
string _accountId = LuaAPI.lua_tostring(L, 2);
gen_to_be_invoked.SetTaAccountId( _accountId );
return 0;
}
} catch(System.Exception gen_e) {
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
}
}

View File

@ -21,12 +21,13 @@ namespace XLua.CSObjectWrap
{ {
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
System.Type type = typeof(BF.NativeCore.ThirdPlatform.ThinkingAnalyticsSdk); System.Type type = typeof(BF.NativeCore.ThirdPlatform.ThinkingAnalyticsSdk);
Utils.BeginObjectRegister(type, L, translator, 0, 4, 0, 0); Utils.BeginObjectRegister(type, L, translator, 0, 5, 0, 0);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Init", _m_Init); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Init", _m_Init);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetAccountId", _m_SetAccountId); Utils.RegisterFunc(L, Utils.METHOD_IDX, "SetAccountId", _m_SetAccountId);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "ClearAccountId", _m_ClearAccountId); Utils.RegisterFunc(L, Utils.METHOD_IDX, "ClearAccountId", _m_ClearAccountId);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Track", _m_Track); Utils.RegisterFunc(L, Utils.METHOD_IDX, "Track", _m_Track);
Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetDistinctId", _m_GetDistinctId);
@ -227,6 +228,34 @@ namespace XLua.CSObjectWrap
} }
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
static int _m_GetDistinctId(RealStatePtr L)
{
try {
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
BF.NativeCore.ThirdPlatform.ThinkingAnalyticsSdk gen_to_be_invoked = (BF.NativeCore.ThirdPlatform.ThinkingAnalyticsSdk)translator.FastGetCSObj(L, 1);
{
var gen_ret = gen_to_be_invoked.GetDistinctId( );
LuaAPI.lua_pushstring(L, gen_ret);
return 1;
}
} catch(System.Exception gen_e) {
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
}
}