131 lines
3.9 KiB
C#
131 lines
3.9 KiB
C#
using System;
|
||
using Newtonsoft.Json.Linq;
|
||
using UnityEngine;
|
||
|
||
namespace tysdk
|
||
{
|
||
public partial class TYSdkFacade : MonoBehaviour
|
||
{
|
||
/*================================================
|
||
|
||
_____ _ _____ _
|
||
| ____|_ _____ _ __ | |_ |_ _| __ __ _ ___| | __
|
||
| _| \ \ / / _ \ '_ \| __| | || '__/ _` |/ __| |/ /
|
||
| |___ \ V / __/ | | | |_ | || | | (_| | (__| <
|
||
|_____| \_/ \___|_| |_|\__| |_||_| \__,_|\___|_|\_\
|
||
|
||
=================================================*/
|
||
|
||
public void EventTrack(int type, string name, string content)
|
||
{
|
||
#if UNITY_IOS || UNITY_ANDROID
|
||
UnityBridgeFunc.GAReportParams(type, name, content);
|
||
#endif
|
||
}
|
||
}
|
||
|
||
public enum GATrackType
|
||
{
|
||
GA_TRACK = 1, //默认类型
|
||
GA_CION = 2, //金流相关事件
|
||
GA_PAY = 3, //支付相关事件
|
||
GA_GAME = 4, //游戏行为
|
||
GA_LOGIN = 5, //登录注册相关事件
|
||
GA_PUSH = 6, //推送相关事件
|
||
GA_ADBOX = 7, //adbox相关事件
|
||
GA_PREFORMANCE = 8, //性能上报相关事件
|
||
GA_SDK = 9, //SDK相关事件
|
||
GA_ABTest = 10, //abtest相关事件
|
||
}
|
||
|
||
public class GAEvent : IDisposable
|
||
{
|
||
|
||
private GATrackType eventType;
|
||
private string eventName;
|
||
bool AFSend = true;
|
||
public static string ABTestValue = "0";
|
||
private JObject content = new JObject();
|
||
|
||
public GAEvent(GATrackType eventType, string eventName, bool AFSend = true)
|
||
{
|
||
this.eventType = eventType;
|
||
this.eventName = eventName;
|
||
this.AFSend = AFSend;
|
||
}
|
||
|
||
public GAEvent AddContent(string key, string value)
|
||
{
|
||
content[key] = value;
|
||
return this;
|
||
}
|
||
|
||
public GAEvent AddContent(string key, int value)
|
||
{
|
||
content[key] = value;
|
||
return this;
|
||
}
|
||
|
||
public GAEvent AddContent(string key, bool value)
|
||
{
|
||
content[key] = value;
|
||
return this;
|
||
}
|
||
|
||
public GAEvent AddContent(string key, float value)
|
||
{
|
||
content[key] = value;
|
||
return this;
|
||
}
|
||
|
||
public void Dispose()
|
||
{
|
||
content["ABTestValue"] = ABTestValue;
|
||
TYSdkFacade.Instance.EventTrack((int)eventType, eventName, content.ToString());
|
||
}
|
||
|
||
/*
|
||
*GA_TRACK(默认类型)
|
||
*GA_CION(金流相关事件)
|
||
*GA_PAY(支付相关事件)
|
||
*GA_GAME(游戏行为)
|
||
*GA_LOGIN(登录注册相关事件)
|
||
*GA_PUSH(推送相关事件)
|
||
*GA_ADBOX(adbox相关事件)
|
||
*GA_PREFORMANCE(性能上报相关事件)
|
||
*GA_SDK(SDK相关事件)
|
||
*GA_ABTest(abtest相关事件)
|
||
*GA_PROFILE(设置用户特征
|
||
*/
|
||
//TOD SDK
|
||
public static GAEvent TackEvent(string eventName, bool afSend = true)
|
||
{
|
||
return new GAEvent(GATrackType.GA_TRACK, eventName, afSend);
|
||
}
|
||
|
||
public static GAEvent PushEvent(string eventName, bool afSend = true)
|
||
{
|
||
return new GAEvent(GATrackType.GA_PUSH, eventName, afSend);
|
||
}
|
||
|
||
public static GAEvent CionEvent(string eventName, bool afSend = true)
|
||
{
|
||
return new GAEvent(GATrackType.GA_CION, eventName, afSend);
|
||
}
|
||
|
||
public static GAEvent PayEvent(string eventName, bool afSend = true)
|
||
{
|
||
return new GAEvent(GATrackType.GA_PAY, eventName, afSend);
|
||
}
|
||
|
||
public static GAEvent GameEvent(string eventName, bool afSend = true)
|
||
{
|
||
return new GAEvent(GATrackType.GA_GAME, eventName, afSend);
|
||
}
|
||
|
||
public static GAEvent LoginEvent(string eventName, bool afSend = true)
|
||
{
|
||
return new GAEvent(GATrackType.GA_LOGIN, eventName, afSend);
|
||
}
|
||
}
|
||
} |