diff --git a/ProjectNLD/Assets/Code/Scripts/HotUpdate/GameLauncher.cs b/ProjectNLD/Assets/Code/Scripts/HotUpdate/GameLauncher.cs index 1614f84847f..9dedbac8e6f 100644 --- a/ProjectNLD/Assets/Code/Scripts/HotUpdate/GameLauncher.cs +++ b/ProjectNLD/Assets/Code/Scripts/HotUpdate/GameLauncher.cs @@ -4,6 +4,7 @@ using PhxhSDK.AOT; using PhxhSDK.AOT.SimpleLoader; using PhxhSDK.AOT.VersionUpdate; using System; +using System.IO; #if UNITY_IOS && !UNITY_EDITOR using System.Runtime.InteropServices; #endif @@ -164,6 +165,7 @@ public class GameLauncher : MonoBehaviour versionUpdateUI.ShowVersion(Application.version, localInfo.workSpace, displayLocalVersion, acquiring, acquiring); BIToolinAOT.Instance.Init();//TalkingData初始化 + TrackHarmonyFirstStart(); try { DeviceIdHandle.Instance.Initialize();//设备ID获取初始化 @@ -335,6 +337,30 @@ public class GameLauncher : MonoBehaviour _finalProgess = progress; } + private void TrackHarmonyFirstStart() + { +#if UNITY_OPENHARMONY + var markerPath = Path.Combine(Application.persistentDataPath, "local_hm_first_start"); + if (File.Exists(markerPath)) + { + Debug.Log("BI AOT 鸿蒙首次启动事件已上报,跳过 hm_first_start"); + return; + } + + BIToolinAOT.Instance.TrackEventInAOT("hm_first_start", null); + + try + { + File.WriteAllText(markerPath, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString()); + Debug.Log("BI AOT 鸿蒙首次启动事件标记写入成功: " + markerPath); + } + catch (Exception e) + { + Debug.LogError("BI AOT 鸿蒙首次启动事件标记写入失败: " + e); + } +#endif + } + #region iOS_DeviceHelper #if UNITY_IOS && !UNITY_EDITOR