修复topon loaded参数为0/快手激励切屏发放奖励/数数属性上报/admob开屏收益获取不到问题,adjust改为生产环境
This commit is contained in:
parent
799a2b32eb
commit
87de004f3d
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AdjustSdk;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
@ -7,17 +9,14 @@ using WZ;
|
|||
|
||||
public class AdjustManager : D_MonoSingleton<AdjustManager>
|
||||
{
|
||||
private AdjustEnvironment environment = AdjustEnvironment.Sandbox; // 测试用Sandbox,发布用Production
|
||||
private AdjustEnvironment environment = AdjustEnvironment.Production;
|
||||
|
||||
private long startTime = 0;
|
||||
|
||||
private string Adid;
|
||||
private string Gdid;
|
||||
|
||||
private string _adNetwork = "_adNetwork";
|
||||
private string _campaign = "_campaign";
|
||||
private string _adgroup = "_adgroup";
|
||||
private string _creative = "_creative";
|
||||
private string callbackNetwork = "";
|
||||
bool m_start = false;
|
||||
private int callGetTimes = 0;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
@ -39,13 +38,11 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
LoadAdid();
|
||||
LoadGaid();
|
||||
|
||||
//计时3分钟
|
||||
AppSDKManager.Instance.Coroutine(AdjustNetwork.Instance.SetOrganic3Min());
|
||||
|
||||
ShuShuEvent.Instance.Track("adjust_init");
|
||||
FireBaseAnalyticsManager.Instance.LogEvent("adjust_init");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 归因信息
|
||||
/// </summary>
|
||||
|
@ -53,50 +50,112 @@ public class AdjustManager : D_MonoSingleton<AdjustManager>
|
|||
private void AttributionChangedDelegate(AdjustAttribution attribution)
|
||||
{
|
||||
Debug.Log("Attribution changed network: " + attribution.Network + " campaign: " + attribution.Campaign + " adgroup: " + attribution.Adgroup + " creative: " + attribution.Creative);
|
||||
if (m_start) return;
|
||||
m_start = true;
|
||||
callbackNetwork = attribution.Network;
|
||||
if (IsOrganic(attribution.Network) == false)
|
||||
{
|
||||
OnReceiveCallback(attribution);
|
||||
return;
|
||||
}
|
||||
InvokeRepeating(nameof(CallGetAttributionAsync), 0, 1);
|
||||
}
|
||||
|
||||
private async Task CallGetAttributionAsync()
|
||||
{
|
||||
callGetTimes++;
|
||||
|
||||
AdjustAttribution attribute = await GetAttributionAsync();
|
||||
LoggerUtils.Debug("[adjust] adjust CallGetAttribution callGetTimes : " + callGetTimes + " attinfo:" + attribute.Network + " clicklabel:" + attribute.ClickLabel);
|
||||
if (attribute != null)
|
||||
{
|
||||
LoggerUtils.Debug("[adjust] adjust 重试次数 : " + callGetTimes + ", attribute : " + attribute.Network + ", callbackNetwork : " + callbackNetwork);
|
||||
if (attribute.Network.Equals(callbackNetwork) == false)
|
||||
{
|
||||
CancelInvoke(nameof(CallGetAttributionAsync));
|
||||
OnReceiveCallback(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if (callGetTimes >= 3*60)
|
||||
{
|
||||
if (attribute != null)
|
||||
{
|
||||
OnReceiveCallback(attribute);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnReceiveCallback(null);
|
||||
}
|
||||
CancelInvoke(nameof(CallGetAttributionAsync));
|
||||
}
|
||||
}
|
||||
|
||||
public static Task<AdjustAttribution> GetAttributionAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<AdjustAttribution>();
|
||||
|
||||
Adjust.GetAttribution(attribution =>
|
||||
{
|
||||
try
|
||||
{
|
||||
tcs.TrySetResult(attribution);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tcs.TrySetException(ex);
|
||||
}
|
||||
});
|
||||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
private void OnReceiveCallback(AdjustAttribution attribution)
|
||||
{
|
||||
string campaign = "";
|
||||
string adgroup = "";
|
||||
string creative = "";
|
||||
string network = "";
|
||||
|
||||
if (attribution != null)
|
||||
{
|
||||
campaign = attribution.Campaign;
|
||||
adgroup = attribution.Adgroup;
|
||||
creative = attribution.Creative;
|
||||
network = attribution.Network;
|
||||
}
|
||||
else
|
||||
{
|
||||
network = "Organic";
|
||||
}
|
||||
|
||||
AdjustNetwork.Instance.SetNetwork(attribution.Network);
|
||||
SaveProperties(attribution);
|
||||
|
||||
var userProperties = new Dictionary<string, object>();
|
||||
userProperties.Add("ad_network", AdjustManager.GetAdNetwork());
|
||||
userProperties.Add("campaign", AdjustManager.GetCampaign());
|
||||
userProperties.Add("adgroup", AdjustManager.GetAdgroup());
|
||||
userProperties.Add("creative", AdjustManager.GetCreative());
|
||||
ShuShuEvent.Instance.UserSet(userProperties);
|
||||
AdjustNetwork.Instance.LogEventGetSuccess();
|
||||
ShuShuEvent.Instance.UserSet(new Dictionary<string, object>
|
||||
{
|
||||
{ "user_ad_network", network ?? "" },
|
||||
{ "user_campaign", campaign ?? "" },
|
||||
{ "user_adgroup", adgroup ?? "" },
|
||||
{ "user_creative", creative ?? "" },
|
||||
});
|
||||
|
||||
var publicProperties = new Dictionary<string, object>();
|
||||
publicProperties.Add("user_ad_network", AdjustManager.GetAdNetwork());
|
||||
publicProperties.Add("user_campaign", AdjustManager.GetCampaign());
|
||||
publicProperties.Add("user_adgroup", AdjustManager.GetAdgroup());
|
||||
publicProperties.Add("user_creative", AdjustManager.GetCreative());
|
||||
AppSDKManager.Instance.SetSuperProperties(publicProperties);
|
||||
AppSDKManager.Instance.SetSuperProperties(new Dictionary<string, object>
|
||||
{
|
||||
{ "ad_network", network ?? "" },
|
||||
{ "campaign", campaign ?? "" },
|
||||
{ "adgroup", adgroup ?? "" },
|
||||
{ "creative", creative ?? "" },
|
||||
});
|
||||
}
|
||||
|
||||
private void SaveProperties(AdjustAttribution attribution)
|
||||
{
|
||||
PlayerPrefsUtils.SavePlayerPrefsString(_adNetwork, attribution.Network.Substring(0, 10));
|
||||
PlayerPrefsUtils.SavePlayerPrefsString(_campaign, attribution.Campaign.Substring(0, 20));
|
||||
PlayerPrefsUtils.SavePlayerPrefsString(_adgroup, attribution.Adgroup.Substring(0, 10));
|
||||
PlayerPrefsUtils.SavePlayerPrefsString(_creative, attribution.Creative.Substring(0, 20));
|
||||
}
|
||||
|
||||
public static string GetAdNetwork()
|
||||
private bool IsOrganic(string _network)
|
||||
{
|
||||
return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._adNetwork, "");
|
||||
}
|
||||
|
||||
public static string GetCampaign()
|
||||
{
|
||||
return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._campaign, "");
|
||||
}
|
||||
|
||||
public static string GetAdgroup()
|
||||
{
|
||||
return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._adgroup, "");
|
||||
}
|
||||
|
||||
public static string GetCreative()
|
||||
{
|
||||
return PlayerPrefsUtils.GetPlayerPrefsString(AdjustManager.Instance._creative, "");
|
||||
if (_network.Equals("Organic") || _network.Equals("Untrusted Devices") || _network.Equals(""))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public long GetStartTime()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using AdjustSdk;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
|
@ -29,31 +29,6 @@ public class AdjustNetwork : D_MonoSingleton<AdjustNetwork>
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3分钟设置自然量
|
||||
/// </summary>
|
||||
public IEnumerator SetOrganic3Min()
|
||||
{
|
||||
string curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
|
||||
if (!string.IsNullOrEmpty(curNetwork))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
//写死3分钟
|
||||
yield return new WaitForSeconds(3 * 60);
|
||||
|
||||
//重新获取
|
||||
curNetwork = PlayerPrefs.GetString(KEY_USER_NETWORK, "");
|
||||
if (!string.IsNullOrEmpty(curNetwork))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
LogEventGetSuccess();
|
||||
PlayerPrefs.SetString(KEY_USER_NETWORK, "Organic");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是自然量用户
|
||||
|
@ -85,7 +60,7 @@ public class AdjustNetwork : D_MonoSingleton<AdjustNetwork>
|
|||
/// <summary>
|
||||
/// 获取adjust信息成功
|
||||
/// </summary>
|
||||
private void LogEventGetSuccess()
|
||||
public void LogEventGetSuccess()
|
||||
{
|
||||
long startTime = AdjustManager.Instance.GetStartTime();
|
||||
long endTime = TimeUtils.GetLocalTimestamp();
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace WZ
|
|||
public string GetHighestPayingAdUnit()
|
||||
{
|
||||
string highestPayingAdUnit = null;
|
||||
double highestRevenue = 0;
|
||||
double highestRevenue = -1;
|
||||
|
||||
foreach (var kvp in _adRevenueCache)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ namespace WZ
|
|||
}
|
||||
|
||||
LoggerUtils.Debug("[Admob] appopen ad loaded with response : " + ad.GetResponseInfo().ToString()+" revenue:"+AdmobUtils.GetAppOpenAdEcpm(ad));
|
||||
LoggerUtils.Debug("[Admob] appopen ad loaded with revenue : " + AdmobUtils.GetAppOpenAdEcpm(ad));
|
||||
_appOpenAds[adUnitId] = ad;
|
||||
_adRevenueCache[adUnitId] = AdmobUtils.GetAppOpenAdEcpm(ad);
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Splash);
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace WZ
|
|||
|
||||
|
||||
private static readonly string[] BannerStack = { "zza", "zzj", "zzi", "zze", "zza", "zzk", "zzae" };
|
||||
private static readonly string[] SpStack = { "zzb", "zzi", "zze", "zze", "zzae" };
|
||||
private static readonly string[] SpStack = { "zzb", "zza", "zzc", "zza", "zzk", "zzae" };
|
||||
private static readonly string[] IvStack = { "zzc", "zzj", "zzf", "zzd", "zzae" };
|
||||
private static readonly string[] RvStack = { "zzb", "zzi", "zze", "zze", "zzae" };
|
||||
private static readonly string[] NaStack = { "zza", "zzb", "zzf", "zzD", "zzb", "zzae" };
|
||||
|
|
|
@ -30,13 +30,13 @@ namespace WZ
|
|||
public float _ivStartLoadTime = 0;
|
||||
public string ClientName => "Kwai";
|
||||
public PlatformType Platfrom => PlatformType.Kwai;
|
||||
|
||||
public bool _initialized { get; private set; } = false;
|
||||
public bool _receivedReward = false;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
LoggerUtils.Debug("KwaiAdsManager Initialize start" + _appId + " token:" + _token + " rewardAdUnitId:" + _rewardAdUnitId + " interstitialAdUnitId:" + _interstitialAdUnitId);
|
||||
if (string.IsNullOrEmpty(_appId) || string.IsNullOrEmpty(_token)|| _initialized) return;
|
||||
if (string.IsNullOrEmpty(_appId) || string.IsNullOrEmpty(_token) || _initialized) return;
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(_appId)
|
||||
.SetToken(_token)
|
||||
|
|
|
@ -25,8 +25,9 @@ namespace WZ
|
|||
AdsType.Rewarded,
|
||||
"",
|
||||
KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
KwaiAdsManager.Instance._rvCloseCallback?.Invoke(true, KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
KwaiAdsManager.Instance._rvCloseCallback?.Invoke(KwaiAdsManager.Instance._receivedReward, KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
KwaiAdsManager.Instance._rvCloseCallback = null;
|
||||
KwaiAdsManager.Instance._receivedReward = false;
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnAdClose");
|
||||
}
|
||||
|
@ -57,6 +58,7 @@ namespace WZ
|
|||
{
|
||||
// 获取到激励 | Reward earned
|
||||
LoggerUtils.Debug("[kwai] RewardAdListener#OnRewardEarned");
|
||||
KwaiAdsManager.Instance._receivedReward = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ namespace WZ
|
|||
public string _topon_rewarded_units;
|
||||
private string _rvPos;
|
||||
private string _ivPos;
|
||||
private Action<bool,double> _rvCloseCallback = null;
|
||||
private Action<bool, double> _rvCloseCallback = null;
|
||||
private Action<double> _ivCloseCallback = null;
|
||||
private Action _rvShowFailedCallback = null;
|
||||
public bool _initialized { get; private set; } = false;
|
||||
|
@ -64,7 +64,7 @@ namespace WZ
|
|||
|
||||
}
|
||||
public void LoadRewarded() { }
|
||||
public void DisplayRewarded(string adPos, Action<bool,double> rewardCallback = null, Action showFailedCallback = null)
|
||||
public void DisplayRewarded(string adPos, Action<bool, double> rewardCallback = null, Action showFailedCallback = null)
|
||||
{
|
||||
_rvPos = adPos;
|
||||
_rvCloseCallback = rewardCallback;
|
||||
|
@ -92,7 +92,7 @@ namespace WZ
|
|||
ATInterstitialAutoAd.Instance.client.onAdShowFailureEvent += OnAdVideoFailureEvent;
|
||||
ATInterstitialAutoAd.Instance.client.onAdClickEvent += OnAdVideoClickedEvent;
|
||||
ATInterstitialAutoAd.Instance.addAutoLoadAdPlacementID(new string[] { _topon_interstitial_units });
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom,"","",AdsType.Interstitial);
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, "", "", AdsType.Interstitial);
|
||||
}
|
||||
|
||||
public void LoadInterstitial() { }
|
||||
|
@ -114,20 +114,27 @@ namespace WZ
|
|||
#region 代理
|
||||
private void OnAdLoadedEvent(object sender, ATAdEventArgs erg)
|
||||
{
|
||||
AdsActionEvents.TrackAdLoaded(Platfrom,
|
||||
ClientName + "_" + erg.callbackInfo.network_firm_id,
|
||||
erg.callbackInfo.adunit_id,
|
||||
erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial,
|
||||
0);
|
||||
|
||||
if (erg.placementId.Equals(_topon_interstitial_units))
|
||||
{
|
||||
LoggerUtils.Debug("[Tpn] ads tpn topon interstitial loaded");
|
||||
var info = JsonUtility.FromJson<TopOnCallback>(ATInterstitialAutoAd.Instance.checkAutoAdStatus(erg.placementId));
|
||||
AdsActionEvents.TrackAdLoaded(Platfrom,
|
||||
ClientName + "_" + info.adInfo.network_firm_id,
|
||||
info.adInfo.adunit_id,
|
||||
erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial,
|
||||
0);
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Interstitial);
|
||||
}
|
||||
else if (erg.placementId.Equals(_topon_rewarded_units))
|
||||
{
|
||||
LoggerUtils.Debug("[Tpn] ads tpn topon rewarded loaded");
|
||||
var info = JsonUtility.FromJson<TopOnCallback>(ATRewardedAutoVideo.Instance.checkAutoAdStatus(erg.placementId));
|
||||
AdsActionEvents.TrackAdLoaded(Platfrom,
|
||||
ClientName + "_" + info.adInfo.network_firm_id,
|
||||
info.adInfo.adunit_id,
|
||||
erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial,
|
||||
0);
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Rewarded);
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +194,7 @@ namespace WZ
|
|||
}
|
||||
|
||||
private void OnAdRewardEvent(object sender, ATAdEventArgs erg)
|
||||
{
|
||||
{
|
||||
LoggerUtils.Debug("[Tpn] 广告奖励");
|
||||
_receivedReward = true;
|
||||
}
|
||||
|
@ -261,12 +268,12 @@ namespace WZ
|
|||
|
||||
public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void RemoveNative(string adUnitId)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public double GetNativeRevenue(string adUnitId)
|
||||
|
@ -314,5 +321,22 @@ namespace WZ
|
|||
AdPlayCountManager.GetAdPlayCount(erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial));
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Serializable]
|
||||
public class TopOnCallback
|
||||
{
|
||||
public bool isLoading;
|
||||
public bool isReady;
|
||||
public TopOnCallbackInfo adInfo;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class TopOnCallbackInfo
|
||||
{
|
||||
public double publisher_revenue;
|
||||
public string adunit_id;
|
||||
public int network_firm_id;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,10 +18,10 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
FileParse.Parse();
|
||||
// AdConfigParser.Parse();
|
||||
FireBaseSDKManager.Instance.Init();
|
||||
ShuShuMangage.Instance.Init();
|
||||
AdmobAdsManager.Instance.RefreshAdsData();
|
||||
AdmobAdsManager.Instance.Initialize();
|
||||
AdjustManager.Instance.Init();
|
||||
ShuShuMangage.Instance.Init();
|
||||
AdsSDKManager.Instance.InitSDK(action);
|
||||
EFSdkManager.Instance.Init();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AnyThinkAds.ThirdParty.LitJson;
|
||||
using ThinkingData.Analytics;
|
||||
|
||||
namespace WZ
|
||||
|
@ -11,6 +12,7 @@ namespace WZ
|
|||
/// </summary>
|
||||
public void UserSet(Dictionary<string, object> dic)
|
||||
{
|
||||
LoggerUtils.Debug("[shushu] userset:"+JsonMapper.ToJson(dic));
|
||||
TDAnalytics.UserSet(dic);
|
||||
}
|
||||
|
||||
|
@ -20,6 +22,7 @@ namespace WZ
|
|||
/// <param name="superProperties"></param>
|
||||
public void SetSuperProperties(Dictionary<string, object> superProperties)
|
||||
{
|
||||
LoggerUtils.Debug("[shushu] public:"+JsonMapper.ToJson(superProperties));
|
||||
TDAnalytics.SetSuperProperties(superProperties);//设置公共事件属性
|
||||
}
|
||||
|
||||
|
|
|
@ -14,22 +14,6 @@ namespace WZ
|
|||
TDAnalytics.Init(StaticValue.TDAppID, StaticValue.TDServerURL);
|
||||
//开启自动采集事件
|
||||
TDAnalytics.EnableAutoTrack(TDAutoTrackEventType.AppInstall | TDAutoTrackEventType.AppStart | TDAutoTrackEventType.AppEnd);
|
||||
//如果用户已登录,可以设置用户的账号ID作为身份唯一标识
|
||||
// TDAnalytics.Login("TA");
|
||||
var userProperties = new Dictionary<string, object>();
|
||||
userProperties.Add("ad_network", AdjustManager.GetAdNetwork());
|
||||
userProperties.Add("campaign", AdjustManager.GetCampaign());
|
||||
userProperties.Add("adgroup", AdjustManager.GetAdgroup());
|
||||
userProperties.Add("creative", AdjustManager.GetCreative());
|
||||
ShuShuEvent.Instance.UserSet(userProperties);
|
||||
|
||||
var publicProperties = new Dictionary<string, object>();
|
||||
publicProperties.Add("user_ad_network", AdjustManager.GetAdNetwork());
|
||||
publicProperties.Add("user_campaign", AdjustManager.GetCampaign());
|
||||
publicProperties.Add("user_adgroup", AdjustManager.GetAdgroup());
|
||||
publicProperties.Add("user_creative", AdjustManager.GetCreative());
|
||||
AppSDKManager.Instance.SetSuperProperties(publicProperties);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue