From 606b98aaddc7c78edada65a9f5e155b8fb9966db Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 20 Jan 2021 15:34:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=95=B0=E6=95=B0=E3=80=91=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E4=BD=BF=E7=94=A8=E6=95=B0=E6=95=B0=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E5=A4=87id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Manager/ThinkingAnalyticsManager.cs | 7 ++++++- .../ThinkingAnalyticsManager.lua | 11 +++++++++++ .../~Lua/Modules/Login/LoginManager.lua | 2 +- .../~Lua/Modules/Net/NetManager.lua | 2 +- .../GameLogic_ThinkingAnalyticsManagerWrap.cs | 18 ++++++++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Assets/LuaFramework/Scripts/Manager/ThinkingAnalyticsManager.cs b/Assets/LuaFramework/Scripts/Manager/ThinkingAnalyticsManager.cs index 174db625cc..6cead430c9 100644 --- a/Assets/LuaFramework/Scripts/Manager/ThinkingAnalyticsManager.cs +++ b/Assets/LuaFramework/Scripts/Manager/ThinkingAnalyticsManager.cs @@ -119,7 +119,12 @@ namespace GameLogic Dictionary data = stringToDic(trackData); ThinkingAnalyticsAPI.Track(trackEvent, data); } - + + // 设置访客Id + public string GetDeviceId() + { + return ThinkingAnalyticsAPI.GetDeviceId(); + } // Debug.Log("TA.TAExample - current disctinct ID is: " + ThinkingAnalyticsAPI.GetDistinctId()); diff --git a/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua b/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua index ebf0c19d02..5e39bfeb68 100644 --- a/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua @@ -68,6 +68,17 @@ function this.GetDistinctId() end return "" end +-- 获取设备Id +function this.GetDeviceId() + if AppConst.isSDK then + if App.TAMgr.GetDeviceID then + return App.TAMgr:GetDeviceId() + end + return AndroidDeviceInfo.Instance:GetDeviceID() + end + return "" +end + -- 登录 function this.Login(accountId) diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua index 4de0999780..5f07b19eab 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua @@ -49,7 +49,7 @@ function this.Initialize() account = AppConst.isSDK and tostring(AppConst.OpenId) or "", Bundle_id = AppConst.isSDK and AppConst.SdkPackageName or "", xx_id = AppConst.isSDK and AppConst.SdkChannel or "", - device_id = AppConst.isSDK and AndroidDeviceInfo.Instance:GetDeviceID() or "" + device_id = AppConst.isSDK and ThinkingAnalyticsManager.GetDeviceId() or "" }) ThinkingAnalyticsManager.Track("create_account") end diff --git a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua index cc85554bd6..36a80bd149 100644 --- a/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Net/NetManager.lua @@ -33,7 +33,7 @@ end --请求登录 function this.LoginRequest(openId, func) local data = PlayerInfoProto_pb.LoginRequest() - data.device_id_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetDeviceID() or "" + data.device_id_s = AppConst.isSDK and ThinkingAnalyticsManager.GetDeviceId() or "" data.idfa_sOr_imei_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetIMEICode() or "" data.brand_type_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetDeviceBrand() or "" data.brand_s = AppConst.isSDK and AndroidDeviceInfo.Instance:GetDeviceModel() or "" diff --git a/Assets/Source/Generate/GameLogic_ThinkingAnalyticsManagerWrap.cs b/Assets/Source/Generate/GameLogic_ThinkingAnalyticsManagerWrap.cs index a9b4b8b8a6..29b469e666 100644 --- a/Assets/Source/Generate/GameLogic_ThinkingAnalyticsManagerWrap.cs +++ b/Assets/Source/Generate/GameLogic_ThinkingAnalyticsManagerWrap.cs @@ -17,6 +17,7 @@ public class GameLogic_ThinkingAnalyticsManagerWrap L.RegFunction("SetSuperProperties", SetSuperProperties); L.RegFunction("ClearSuperProperties", ClearSuperProperties); L.RegFunction("Track", Track); + L.RegFunction("GetDeviceId", GetDeviceId); L.RegFunction("__eq", op_Equality); L.RegFunction("__tostring", ToLua.op_ToString); L.EndClass(); @@ -190,6 +191,23 @@ public class GameLogic_ThinkingAnalyticsManagerWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int GetDeviceId(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 1); + GameLogic.ThinkingAnalyticsManager obj = (GameLogic.ThinkingAnalyticsManager)ToLua.CheckObject(L, 1); + string o = obj.GetDeviceId(); + LuaDLL.lua_pushstring(L, o); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int op_Equality(IntPtr L) {