统计接口+用户属性打点
This commit is contained in:
parent
b7b1b2c9f4
commit
138f923264
|
@ -30,6 +30,7 @@ public class AppSDKManager : MonoBehaviour
|
||||||
AdsSDKManager.Instance.InitSDK(action);
|
AdsSDKManager.Instance.InitSDK(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 协程
|
/// 协程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -72,24 +73,20 @@ public class AppSDKManager : MonoBehaviour
|
||||||
|
|
||||||
public void LogEvent(string eventName)
|
public void LogEvent(string eventName)
|
||||||
{
|
{
|
||||||
// ShuShuEvent.Instance.Track(eventName);
|
ShuShuEvent.Instance.Track(eventName);
|
||||||
// FireBaseAnalyticsManager.Instance.LogEvent(eventName);
|
FireBaseAnalyticsManager.Instance.LogEvent(eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogEvent(string eventName, string key1, object value1)
|
public void LogEvent(string eventName, string key1, object value1)
|
||||||
{
|
{
|
||||||
// ShuShuEvent.Instance.Track(eventName, key1, value1);
|
ShuShuEvent.Instance.Track(eventName, key1, value1);
|
||||||
// FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1);
|
FireBaseAnalyticsManager.Instance.LogEvent(eventName, key1, value1);
|
||||||
}
|
|
||||||
|
|
||||||
public void LogEvent(string eventName, string key1, object value1, string key2, object value2)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogEvent(string eventName, Dictionary<string, object> extraInfo)
|
public void LogEvent(string eventName, Dictionary<string, object> extraInfo)
|
||||||
{
|
{
|
||||||
|
ShuShuEvent.Instance.Track(eventName, extraInfo);
|
||||||
|
FireBaseAnalyticsManager.Instance.LogEvent(eventName, extraInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -135,21 +132,37 @@ public class AppSDKManager : MonoBehaviour
|
||||||
|
|
||||||
public bool GetRemoteConfigBool(string key, bool defaultValue = false)
|
public bool GetRemoteConfigBool(string key, bool defaultValue = false)
|
||||||
{
|
{
|
||||||
|
if (Application.isEditor)
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigBool(key, defaultValue);
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigBool(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetRemoteConfigInt(string key, int defaultValue = 0)
|
public int GetRemoteConfigInt(string key, int defaultValue = 0)
|
||||||
{
|
{
|
||||||
|
if (Application.isEditor)
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt(key, defaultValue);
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigInt(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRemoteConfigString(string key, string defaultValue = "")
|
public string GetRemoteConfigString(string key, string defaultValue = "")
|
||||||
{
|
{
|
||||||
|
if (Application.isEditor)
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigString(key, defaultValue);
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigString(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetRemoteConfigFloat(string key, float defaultValue = 0)
|
public float GetRemoteConfigFloat(string key, float defaultValue = 0)
|
||||||
{
|
{
|
||||||
|
if (Application.isEditor)
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat(key, defaultValue);
|
return FireBaseRemoteConfigManager.Instance.GetRemoteConfigFloat(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Firebase.Analytics;
|
using Firebase.Analytics;
|
||||||
|
using Firebase.RemoteConfig;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using WZ;
|
||||||
|
|
||||||
namespace WZ
|
namespace WZ
|
||||||
{
|
{
|
||||||
|
@ -24,22 +26,50 @@ namespace WZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void LogEvent(string eventName)
|
public void LogEvent(string eventName)
|
||||||
{
|
{
|
||||||
List<Parameter> parameterList = new List<Parameter>();
|
var superProperties = GetSuperProperties();
|
||||||
if (superProperties != null)
|
if (superProperties.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var superProperty in superProperties)
|
FirebaseAnalytics.LogEvent(eventName, superProperties.ToArray());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Parameter parameter = new Parameter(superProperty.Key, superProperty.Value.ToString());
|
FirebaseAnalytics.LogEvent(eventName);
|
||||||
parameterList.Add(parameter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FirebaseAnalytics.LogEvent(eventName, parameterList.ToArray());
|
public void LogEvent(string eventName, string key1, object value1)
|
||||||
|
{
|
||||||
|
List<Parameter> parameters = new List<Parameter>();
|
||||||
|
parameters.Add(GetParameter(key1, value1));
|
||||||
|
|
||||||
|
foreach (var superProperty in GetSuperProperties())
|
||||||
|
{
|
||||||
|
parameters.Add(superProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogEvent(string eventName, Dictionary<string, object> dict)
|
||||||
|
{
|
||||||
|
List<Parameter> parameters = new List<Parameter>();
|
||||||
|
foreach (var item in dict)
|
||||||
|
{
|
||||||
|
Parameter parameter = GetParameter(item.Key, item.Value);
|
||||||
|
parameters.Add(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var superProperty in GetSuperProperties())
|
||||||
|
{
|
||||||
|
parameters.Add(superProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void LogEvent(string eventName, Dictionary<string, string> dict)
|
public void LogEvent(string eventName, Dictionary<string, string> dict)
|
||||||
{
|
{
|
||||||
List<Parameter> parameters = new List<Parameter>();
|
List<Parameter> parameters = new List<Parameter>();
|
||||||
|
@ -48,7 +78,13 @@ namespace WZ
|
||||||
Parameter parameter = new Parameter(item.Key, item.Value);
|
Parameter parameter = new Parameter(item.Key, item.Value);
|
||||||
parameters.Add(parameter);
|
parameters.Add(parameter);
|
||||||
}
|
}
|
||||||
Firebase.Analytics.FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
|
||||||
|
foreach (var superProperty in GetSuperProperties())
|
||||||
|
{
|
||||||
|
parameters.Add(superProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
FirebaseAnalytics.LogEvent(eventName, parameters.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -58,7 +94,7 @@ namespace WZ
|
||||||
/// <param name="property"></param>
|
/// <param name="property"></param>
|
||||||
public void SetUserProperty(string name, string property)
|
public void SetUserProperty(string name, string property)
|
||||||
{
|
{
|
||||||
Firebase.Analytics.FirebaseAnalytics.SetUserProperty(name, property);
|
FirebaseAnalytics.SetUserProperty(name, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -95,6 +131,24 @@ namespace WZ
|
||||||
PlayerPrefsUtils.SavePlayerPrefsString(KEY_SUPER_PROPERTIES, json);
|
PlayerPrefsUtils.SavePlayerPrefsString(KEY_SUPER_PROPERTIES, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取公共事件属性,每次上报都带上
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private List<Parameter> GetSuperProperties()
|
||||||
|
{
|
||||||
|
List<Parameter> parameterList = new List<Parameter>();
|
||||||
|
if (superProperties != null)
|
||||||
|
{
|
||||||
|
foreach (var superProperty in superProperties)
|
||||||
|
{
|
||||||
|
Parameter parameter = GetParameter(superProperty.Key, superProperty.Value);
|
||||||
|
parameterList.Add(parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parameterList;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// FireBase收益上报
|
/// FireBase收益上报
|
||||||
|
@ -165,5 +219,35 @@ namespace WZ
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Parameter GetParameter(string key, object value)
|
||||||
|
{
|
||||||
|
Type type = value.GetType();
|
||||||
|
|
||||||
|
// 根据类型进行转换
|
||||||
|
if (type == typeof(string))
|
||||||
|
{
|
||||||
|
return new Parameter(key, value as string);
|
||||||
|
}
|
||||||
|
if (type == typeof(int))
|
||||||
|
{
|
||||||
|
return new Parameter(key, (int)value);
|
||||||
|
}
|
||||||
|
if (type == typeof(float))
|
||||||
|
{
|
||||||
|
return new Parameter(key, (float)value);
|
||||||
|
}
|
||||||
|
if (type == typeof(long))
|
||||||
|
{
|
||||||
|
return new Parameter(key, (long)value);
|
||||||
|
}
|
||||||
|
if (type == typeof(double))
|
||||||
|
{
|
||||||
|
return new Parameter(key, (double)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Parameter(key, value as string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue