c1_unity/Assets/Scripts/Common/SDK/BFThirdReportSDKManager.cs
2025-11-03 10:59:33 +08:00

141 lines
4.0 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using BF.NativeCore.ThirdPlatform;
using Newtonsoft.Json;
using AppsFlyerSDK;
namespace BF
{
public class BFThirdReportSDKManager : MonoBehaviour
{
private ThinkingAnalyticsSdk TASdk = new ThinkingAnalyticsSdk();
private AppsFlyerSdk AFSdk = new AppsFlyerSdk();
void Start()
{
Init();
}
public void Init()
{
BFLog.Log("TASdk.Init");
TASdk.Init();
AFSdk.Init();
}
// 设置账户id
public void SetThinkingAnalyticsAccountId(string id)
{
TASdk.SetAccountId(id);
AFSdk.SetTaAccountId(id);
}
public void CalibrateTime(long timestamp)
{
TASdk.CalibrateTime(timestamp);
}
// 清除账户id
public void ClearThinkingAnalyticsAccountId()
{
TASdk.ClearAccountId();
}
public string GetAFConversionData()
{
return AppsFlyerObjectScript.AFConversionData;
}
public bool IsGetConversionDataOver()
{
return AppsFlyerObjectScript.IsGetConversionDataOver;
}
public string GetAFAttributionData()
{
return AppsFlyerObjectScript.AFAttributionData;
}
public bool IsGetAppOpenAttributionOver()
{
return AppsFlyerObjectScript.IsGetAppOpenAttributionOver;
}
public bool IsGetAFOnRequestResponse()
{
return AppsFlyerObjectScript.IsGetAFOnRequestResponse;
}
public int GetAFOnRequestResponseStatusCode()
{
return AppsFlyerObjectScript.AFOnRequestResponseStatusCode;
}
public string GetAFOnRequestResponseErrorDescription()
{
return AppsFlyerObjectScript.AFOnRequestResponseErrorDescription;
}
// 数数科技上报
// lua端使用
public void PostThinkingAnalyticsEvent(string eventName, string data = "")
{
if (string.IsNullOrEmpty(data))
{
TASdk.Track(eventName, null);
}
else
{
var properties = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
TASdk.Track(eventName, properties);
}
}
// 数数科技上报
// c#端使用,只上报事件名
public void PostThinkingAnalyticsEventName(string eventName)
{
TASdk.Track(eventName, null);
}
// 数数科技上报
// c#端使用,上报事件名和参数
public void PostThinkingAnalyticsEventProperties(string eventName, Dictionary<string, object> properties)
{
TASdk.Track(eventName, properties);
}
public void PostAppsflyerEvent(string eventName, string data = "")
{
if (string.IsNullOrEmpty(data))
{
AFSdk.SendEvent(eventName, null);
}
else
{
var properties = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
AFSdk.SendEvent(eventName, properties);
}
}
public void PostFireBaseEvent(string eventName, string data = "")
{
if (string.IsNullOrEmpty(data))
{
return;
}
else
{
BFMain.Instance.SDKMgr.BFNativeSDKMgr.LogEvent(eventName, data);
}
}
public void LogAppsFlyerAdRevenue(int mediationNetwork, string monetizationNetwork, double eventRevenue, string data)
{
var properties = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
var mediationNetworkType = (AppsFlyerSDK.MediationNetwork)mediationNetwork;
var adRevenueData = new AFAdRevenueData(monetizationNetwork, mediationNetworkType, "USD", eventRevenue);
AFSdk.LogAdRevenue(adRevenueData, properties);
}
}
}