96 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			96 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using AnyThinkAds.ThirdParty.LitJson;
 | |
| using ThinkingData.Analytics;
 | |
| 
 | |
| namespace WZ
 | |
| {
 | |
|     public class ShuShuEvent : D_MonoSingleton<ShuShuEvent>
 | |
|     {
 | |
|         /// <summary>
 | |
|         /// 设置用户属性
 | |
|         /// </summary>
 | |
|         public void UserSet(Dictionary<string, object> dic)
 | |
|         {
 | |
|             LoggerUtils.Debug("[shushu] userset:"+JsonMapper.ToJson(dic));
 | |
|             TDAnalytics.UserSet(dic);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 设置公共事件属性
 | |
|         /// </summary>
 | |
|         /// <param name="superProperties"></param>
 | |
|         public void SetSuperProperties(Dictionary<string, object> superProperties)
 | |
|         {
 | |
|             LoggerUtils.Debug("[shushu] public:"+JsonMapper.ToJson(superProperties));
 | |
|             TDAnalytics.SetSuperProperties(superProperties);//设置公共事件属性
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 发送事件
 | |
|         /// </summary>
 | |
|         public void Track(string eventName)
 | |
|         {
 | |
|             TDAnalytics.Track(eventName);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 发送事件
 | |
|         /// </summary>
 | |
|         public void Track(string eventName, string key1, object value1)
 | |
|         {
 | |
|             var extraInfo = new Dictionary<string, object>();
 | |
|             if (key1 != null && value1 != null)
 | |
|             {
 | |
|                 extraInfo[key1] = value1;
 | |
|             }
 | |
| 
 | |
|             Track(eventName, extraInfo);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 发送事件
 | |
|         /// </summary>
 | |
|         public void Track(string eventName, Dictionary<string, object> properties)
 | |
|         {
 | |
|             TDAnalytics.Track(eventName, properties);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 发送事件
 | |
|         /// </summary>
 | |
|         public void Track(string eventName, Dictionary<string, string> properties)
 | |
|         {
 | |
|             var newProperties = properties.ToDictionary(
 | |
|                 pair => pair.Key,
 | |
|                 pair => (object)pair.Value
 | |
|             );
 | |
|             TDAnalytics.Track(eventName, newProperties);
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 数数收益上报
 | |
|         /// </summary>
 | |
|         /// <param name="ad_platform">聚合平台名称</param>
 | |
|         /// <param name="ad_source">广告平台名称</param>
 | |
|         /// <param name="ad_unit_name">广告位ID</param>
 | |
|         /// <param name="ad_format">广告格式</param>
 | |
|         /// <param name="revenue">单次展示收益</param>
 | |
|         /// <param name="position">广告展示点位</param>
 | |
|         /// <param name="number">第几次展示该格式的广告</param>
 | |
|         public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number)
 | |
|         {
 | |
|             Dictionary<string, object> properties = new Dictionary<string, object>();
 | |
|             properties.Add("ad_platform", ad_platform);
 | |
|             properties.Add("ad_source", ad_source);
 | |
|             properties.Add("ad_unit_name", ad_unit_name);
 | |
|             properties.Add("ad_format", ad_format);
 | |
|             properties.Add("value", revenue);
 | |
|             properties.Add("currency", "USD");
 | |
|             properties.Add("position", position);
 | |
|             properties.Add("number", number);
 | |
| 
 | |
|             TDAnalytics.Track("ad_impression", properties);
 | |
|         }
 | |
|     }
 | |
| } |