adjust 事件上报
This commit is contained in:
parent
ea569697ca
commit
0d9b96949b
|
@ -1,11 +1,48 @@
|
|||
using AdjustSdk;
|
||||
using Firebase.RemoteConfig;
|
||||
using System.Collections.Generic;
|
||||
using AdjustSdk;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using WZ;
|
||||
|
||||
|
||||
public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
||||
{
|
||||
private Dictionary<string, string> eventTokenMap;
|
||||
|
||||
|
||||
private string GetEventToken(string eventName)
|
||||
{
|
||||
if (eventTokenMap == null)
|
||||
{
|
||||
UpdateEventToken();
|
||||
}
|
||||
|
||||
if (eventTokenMap == null || eventTokenMap.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return eventTokenMap.GetValueOrDefault(eventName, null);
|
||||
}
|
||||
|
||||
public void UpdateEventToken()
|
||||
{
|
||||
var remoteConfigString = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("event_adjust_set");
|
||||
if (string.IsNullOrEmpty(remoteConfigString)) return;
|
||||
|
||||
var deserializeObject = JsonConvert.DeserializeObject<Dictionary<string, string>>(remoteConfigString);
|
||||
if (eventTokenMap == null)
|
||||
{
|
||||
eventTokenMap = deserializeObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var keyValuePair in deserializeObject)
|
||||
{
|
||||
eventTokenMap[keyValuePair.Key] = keyValuePair.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adjust事件上报
|
||||
/// </summary>
|
||||
|
@ -16,6 +53,32 @@ public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
|||
Adjust.TrackEvent(adjustEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 会将eventName 转化成 token 进行上报
|
||||
/// </summary>
|
||||
/// <param name="eventName"></param>
|
||||
/// <param name="extraInfo"></param>
|
||||
public void TrackEventName(string eventName, Dictionary<string, object> extraInfo)
|
||||
{
|
||||
var eventToken = GetEventToken(eventName);
|
||||
if (string.IsNullOrEmpty(eventToken))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var adjustEvent = new AdjustEvent(eventToken);
|
||||
if (extraInfo != null)
|
||||
{
|
||||
foreach (var keyValuePair in extraInfo)
|
||||
{
|
||||
adjustEvent.AddPartnerParameter(keyValuePair.Key, keyValuePair.Value.ToString());
|
||||
adjustEvent.AddCallbackParameter(keyValuePair.Key, keyValuePair.Value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Adjust.TrackEvent(adjustEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 广告收益上报
|
||||
/// </summary>
|
||||
|
@ -42,11 +105,12 @@ public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
|||
{
|
||||
string source = "applovin_max_sdk";
|
||||
//获取在线参数
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_adj");
|
||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("revenue_adj");
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
var revenueAdjs = JsonConvert.DeserializeObject<RevenueData[]>(json);
|
||||
if (revenueAdjs == null && revenueAdjs.Length == 0)
|
||||
{
|
||||
|
@ -59,8 +123,9 @@ public class AdjustTrackEvent : NormalSingleton<AdjustTrackEvent>
|
|||
{
|
||||
totalRate += item.rate;
|
||||
}
|
||||
|
||||
//开始随机
|
||||
int randomValue = UnityEngine.Random.Range(0, totalRate);
|
||||
int randomValue = Random.Range(0, totalRate);
|
||||
int accumulatedRate = 0;
|
||||
|
||||
//根据随机值定位
|
||||
|
|
|
@ -158,18 +158,25 @@ public class AppSDKManager : D_MonoSingleton<AppSDKManager>
|
|||
{
|
||||
ShuShuEvent.Instance.Track(eventName);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName);
|
||||
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>());
|
||||
}
|
||||
|
||||
public void LogEvent(string eventName, string key1, object value1)
|
||||
{
|
||||
ShuShuEvent.Instance.Track(eventName, key1, value1);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1);
|
||||
AdjustTrackEvent.Instance.TrackEventName(eventName, new Dictionary<string, object>
|
||||
{
|
||||
[key1] = value1
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void LogEvent(string eventName, Dictionary<string, object> extraInfo)
|
||||
{
|
||||
ShuShuEvent.Instance.Track(eventName, extraInfo);
|
||||
FireBaseAnalyticsManager.Instance.LogEvent(eventName, extraInfo);
|
||||
AdjustTrackEvent.Instance.TrackEventName(eventName, extraInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -10,14 +10,15 @@ namespace WZ
|
|||
{
|
||||
public void FetchRemoteConfig()
|
||||
{
|
||||
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
||||
{
|
||||
if (task.Result == Firebase.DependencyStatus.Available)
|
||||
{
|
||||
// Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
||||
// {
|
||||
// if (task.Result == Firebase.DependencyStatus.Available)
|
||||
// {
|
||||
Firebase.RemoteConfig.FirebaseRemoteConfig.DefaultInstance.FetchAsync(TimeSpan.Zero).ContinueWithOnMainThread(task =>
|
||||
{
|
||||
FirebaseRemoteConfig.DefaultInstance.ActivateAsync().ContinueWithOnMainThread(task =>
|
||||
{
|
||||
AdjustTrackEvent.Instance.UpdateEventToken();
|
||||
// 获取广告位信息
|
||||
AdConfigParser.Parse(GetRemoteConfigString("ad_config"));
|
||||
// 刷新广告位信息
|
||||
|
@ -36,8 +37,8 @@ namespace WZ
|
|||
// 检查Adjust归因
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void GroupSet()
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace WZ
|
|||
{
|
||||
public void Init()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// if (Application.isEditor)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
InitSDK();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue