先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
125 lines
4.3 KiB
C#
125 lines
4.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace game
|
|
{
|
|
public static class AdsEventLogger
|
|
{
|
|
private const string CRASH_FLAG_KEY = "ads_crash_flag";
|
|
|
|
public static void SetCrashFlag(string adType, string operation)
|
|
{
|
|
PlayerPrefs.SetString(CRASH_FLAG_KEY, $"{adType}_{operation}_{System.DateTimeOffset.UtcNow.ToUnixTimeSeconds()}");
|
|
PlayerPrefs.Save();
|
|
}
|
|
|
|
public static void ClearCrashFlag()
|
|
{
|
|
PlayerPrefs.DeleteKey(CRASH_FLAG_KEY);
|
|
PlayerPrefs.Save();
|
|
}
|
|
|
|
public static void CheckAndLogCrash()
|
|
{
|
|
string flag = PlayerPrefs.GetString(CRASH_FLAG_KEY, "");
|
|
if (string.IsNullOrEmpty(flag)) return;
|
|
|
|
PlayerPrefs.DeleteKey(CRASH_FLAG_KEY);
|
|
PlayerPrefs.Save();
|
|
|
|
string[] parts = flag.Split('_');
|
|
string adType = parts.Length > 0 ? parts[0] : "unknown";
|
|
string operation = parts.Length > 1 ? parts[1] : "unknown";
|
|
|
|
using (var e = GEvent.GameEvent("ads_app_crash"))
|
|
{
|
|
e.AddContent("crash_flag", flag);
|
|
e.AddContent("ad_type", adType);
|
|
e.AddContent("operation", operation);
|
|
}
|
|
}
|
|
public static void LogLoadStart(string adType, string adUnitId, string triggerSource)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_load_start"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("trigger_source", triggerSource);
|
|
}
|
|
}
|
|
|
|
public static void LogLoadSuccess(string adType, string adUnitId, string placement)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_load_success"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("placement", placement);
|
|
}
|
|
}
|
|
|
|
public static void LogLoadFail(string adType, string adUnitId, int retryCount, string errorCode, string errorMessage)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_load_fail"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("retry_count", retryCount);
|
|
e.AddContent("error_code", errorCode);
|
|
e.AddContent("error_message", errorMessage);
|
|
}
|
|
}
|
|
|
|
public static void LogDisplay(string adType, string adUnitId, string placement)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_display"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("placement", placement);
|
|
}
|
|
}
|
|
|
|
public static void LogDisplayFail(string adType, string adUnitId, string placement, string errorCode, string errorMessage)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_display_fail"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("placement", placement);
|
|
e.AddContent("error_code", errorCode);
|
|
e.AddContent("error_message", errorMessage);
|
|
}
|
|
}
|
|
|
|
public static void LogHidden(string adType, string adUnitId, string placement)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_hidden"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("placement", placement);
|
|
}
|
|
}
|
|
|
|
public static void LogRewarded(string adUnitId, string placement)
|
|
{
|
|
using (var e = GEvent.GameEvent("ads_reward_rewarded"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("placement", placement);
|
|
}
|
|
}
|
|
|
|
public static void LogClick(string adType, string adUnitId, string placement)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_click"))
|
|
{
|
|
e.AddContent("ad_unit_id", adUnitId);
|
|
e.AddContent("placement", placement);
|
|
}
|
|
}
|
|
|
|
public static void LogNotReady(string adType, string placement)
|
|
{
|
|
using (var e = GEvent.GameEvent($"ads_{adType}_not_ready"))
|
|
{
|
|
e.AddContent("placement", placement);
|
|
}
|
|
}
|
|
}
|
|
}
|