1019 lines
32 KiB
C#
1019 lines
32 KiB
C#
/*create by :闫婷婷
|
||
* date :2020/6/1
|
||
*/
|
||
//#define ADJUST_TEST
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Runtime.InteropServices;
|
||
using com.adjust.sdk;
|
||
using com.adjust.sdk.imei;
|
||
using com.adjust.sdk.oaid;
|
||
using GameAnalyticsSDK;
|
||
using GameAnalyticsSDK.Events;
|
||
using GameAnalyticsSDK.Wrapper;
|
||
using LitJson;
|
||
using Newtonsoft.Json;
|
||
using Umeng;
|
||
using UnityEngine;
|
||
|
||
|
||
|
||
public class JoypacAnalyticsManager : MonoBehaviour
|
||
{
|
||
#region NativeCode
|
||
#if UNITY_IOS
|
||
[DllImport("__Internal")] public static extern void InitOnlineParams(string _appkey, bool _logEnable);
|
||
|
||
#endif
|
||
#endregion
|
||
|
||
private static JoypacAnalyticsManager s_instance;
|
||
public static JoypacAnalyticsManager Instance
|
||
{
|
||
get
|
||
{
|
||
if (s_instance == null)
|
||
{
|
||
s_instance = GameObject.FindObjectOfType<JoypacAnalyticsManager>();
|
||
if (s_instance == null)
|
||
{
|
||
GameObject Joypac = new GameObject();
|
||
Joypac.name = "JoypacAnalyticsManager";
|
||
s_instance = Joypac.AddComponent<JoypacAnalyticsManager>();
|
||
DontDestroyOnLoad(Joypac);
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning("A JoypacAnalyticsManager object already exists in this scene - you should never have more than one per scene!");
|
||
}
|
||
}
|
||
return s_instance;
|
||
}
|
||
}
|
||
|
||
|
||
static bool push1 = false;
|
||
|
||
public static bool Push1
|
||
{
|
||
get { return push1; }
|
||
set { push1 = value; }
|
||
}
|
||
|
||
static bool push2 = false;
|
||
|
||
public static bool Push2
|
||
{
|
||
get { return push2; }
|
||
set { push2 = value; }
|
||
}
|
||
|
||
static bool push3 = false;
|
||
|
||
public static bool Push3
|
||
{
|
||
get { return push3; }
|
||
set { push3 = value; }
|
||
}
|
||
|
||
|
||
public string aPPAdsShowCome = "";
|
||
|
||
public string aPPAdsShowAdType = "";
|
||
|
||
public void AdEvent(string name, string extras, string from, string AdsShowCome, string AdsShowAdType)
|
||
{
|
||
// Debug.Log(string.Format("<color=#ff0000>{0}</color>", name));
|
||
aPPAdsShowCome = AdsShowCome;
|
||
aPPAdsShowAdType = AdsShowAdType;
|
||
|
||
PlayerPrefs.SetString(StaticStringsEvent.aPPAdsShowCome, AdsShowCome);
|
||
PlayerPrefs.SetString(StaticStringsEvent.aPPAdsShowAdType, AdsShowAdType);
|
||
|
||
// AppFunShow(name,extras);
|
||
AppFunClick(name, from);
|
||
}
|
||
|
||
public string ToJson(object jsonObject)
|
||
{
|
||
if (null == jsonObject)
|
||
{
|
||
return null;
|
||
}
|
||
|
||
return "[" + JsonConvert.SerializeObject(jsonObject) + "]";
|
||
}
|
||
|
||
public void ReYun(VolcanoReYunJson json)
|
||
{
|
||
#if JOYPAC_ReYun&&!UNITY_EDITOR
|
||
|
||
setEvent(json.eventname,json.values);
|
||
#endif
|
||
}
|
||
|
||
public void setEvent(string eventName, Dictionary<string, object> values)
|
||
{
|
||
Debug.Log("setEvent========coming");
|
||
//ryattrs
|
||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||
values.Add("ryattrs", JsonConvert.SerializeObject(values));
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
|
||
string finderJson = currAdSingleTemp.getFinderDeviceInfo();//"{\"ver\":10005,\"dtu\":\"yyb\",\"ssid\":\"2c50bc0f-9d14-4cd5-9332-b8c95169c4f0\",\"bd_did\":\"BQQKVB6DZQD5TPA5BQ63AGODTXC6EWUY7V6KISXZWV6QSJM56EYA01\",\"a_uuid\":\"b76ad092-b93a-457d-8bef-fbb27da56a11\"}";
|
||
|
||
Debug.Log("setEvent========coming finderJson=="+ finderJson);
|
||
if (!string.IsNullOrEmpty(finderJson))
|
||
{
|
||
|
||
Dictionary<string, object> jsonTemp = new Dictionary<string, object>();
|
||
|
||
jsonTemp = JsonMapper.ToObject<Dictionary<string, object>>(finderJson);//
|
||
//公共参数
|
||
Debug.Log("setEvent========coming jsonTemp==" + jsonTemp.Count);
|
||
values.Add("ver", jsonTemp["ver"]);
|
||
values.Add("dtu", jsonTemp["dtu"]);
|
||
values.Add("ssid", jsonTemp["ssid"]);
|
||
values.Add("bd_did", jsonTemp["bd_did"]);
|
||
values.Add("a_uuid", jsonTemp["a_uuid"]);
|
||
}
|
||
|
||
// JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
|
||
|
||
currAdSingleTemp.reyunKeyEvent(eventName, JsonConvert.SerializeObject(values));
|
||
#endif
|
||
|
||
#if UNITY_IOS && !UNITY_EDITOR
|
||
|
||
JoypacAdClient.Instance.ReyunEvent(eventName, JsonConvert.SerializeObject(values));
|
||
#endif
|
||
|
||
}
|
||
public void Volcano(VolcanoReYunJson json)
|
||
{
|
||
// ReYUNTracking.Instance.setEvent(json.eventname, json.values.toJson());
|
||
Debug.Log("VolcanoVolcano" + json.eventname + " " + JsonConvert.SerializeObject(json.values));
|
||
#if UNITY_IOS && JOYPAC_Volcano_OS&&!UNITY_EDITOR
|
||
JoypacAdClient.Instance.UploadEvent(json.eventname, JsonConvert.SerializeObject(json.values));
|
||
#endif
|
||
|
||
|
||
|
||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||
#if JOYPAC_Volcano
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
|
||
currAdSingleTemp.reportRangersAppLogEventMap(ToJson(json));
|
||
|
||
#elif JOYPAC_Volcano_OS
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
|
||
currAdSingleTemp.finderGlobalonEventV3(json.eventname,ToJson(json.values));
|
||
|
||
#endif
|
||
#endif
|
||
}
|
||
|
||
|
||
|
||
|
||
public void AppFunShow(string name, string extras)
|
||
{
|
||
Debug.Log(string.Format("<color=#ff0000>{0}</color>", name + " " + extras + " App_Fun_Show "));
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "App_Fun_Show";
|
||
temp.values.Add("name", name);
|
||
temp.values.Add("extras", extras);
|
||
Volcano(temp);
|
||
temp.eventname = "event_13";
|
||
ReYun(temp);
|
||
}
|
||
|
||
public void AppFunClick(string name, string from)
|
||
{
|
||
Debug.Log(string.Format("<color=#ff0000>{0}</color>", name + " " + from + " AppFunClick "));
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "App_Fun_Click";
|
||
temp.values.Add("name", name);
|
||
temp.values.Add("from", from);
|
||
Volcano(temp);
|
||
temp.eventname = "event_14";
|
||
ReYun(temp);
|
||
|
||
}
|
||
|
||
public void AppOperation(string name, string from, string action, string data, string extras)
|
||
{
|
||
|
||
Debug.Log(string.Format("<color=#ff0000>{0}</color>", action + " " + from + " " + data));
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "App_Operation";
|
||
temp.values.Add("name", name);
|
||
temp.values.Add("from", from);
|
||
temp.values.Add("action", action);
|
||
temp.values.Add("data", data);
|
||
temp.values.Add("extras", extras);
|
||
Volcano(temp);
|
||
temp.eventname = "event_15";
|
||
ReYun(temp);
|
||
|
||
}
|
||
public void APPAdsShow(Dictionary<string, object> adSource)
|
||
{
|
||
Debug.Log("APPAdsShow========coming");
|
||
|
||
|
||
Debug.Log("APPAdsShow========coming adSource" + adSource.Count);
|
||
|
||
if (PlayerPrefs.GetInt("ADJUST_FIRSTAD", 0) == 0)
|
||
{
|
||
LogEventToken(ConstStringKey.ADJUST_FIRSTAD);
|
||
PlayerPrefs.SetInt("ADJUST_FIRSTAD", 1);
|
||
}
|
||
|
||
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "APP_Ads_Show";
|
||
temp.values.Add("Come", aPPAdsShowCome);
|
||
temp.values.Add("AdType", aPPAdsShowAdType);
|
||
temp.values.Add("AdSourceId", adSource["AdSourceId"]);
|
||
temp.values.Add("From", adSource["From"]);
|
||
temp.values.Add("price_int", adSource["price_int"]);
|
||
temp.values.Add("price_string", adSource["price_string"]);
|
||
temp.values.Add("currency", adSource["currency"]);
|
||
#if JOYPAC_Volcano_OS
|
||
Volcano(temp);
|
||
#endif
|
||
temp.eventname = "event_4";
|
||
#if UNITY_ANDROID && JOYPAC_ReYun
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
|
||
currAdSingleTemp.reyun_report_ad_show(aPPAdsShowCome, aPPAdsShowAdType, adSource["AdSourceId"].ToString(), adSource["From"].ToString(), adSource["price_int"].ToString(), adSource["price_string"].ToString(), adSource["currency"].ToString());
|
||
// ReYun(temp);
|
||
#endif
|
||
|
||
#if JOYPAC_ReYun && UNITY_IOS&&!UNITY_EDITOR
|
||
ReYun(temp);
|
||
#endif
|
||
}
|
||
public void APPAdsClick(Dictionary<string, object> adSource)
|
||
{
|
||
|
||
Debug.Log("APPAdsClick========coming");
|
||
|
||
|
||
Debug.Log("APPAdsClick========coming adSource" + adSource.Count);
|
||
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "APP_Ads_Click";
|
||
temp.values.Add("Come", aPPAdsShowCome);
|
||
temp.values.Add("AdType", aPPAdsShowAdType);
|
||
temp.values.Add("AdSourceId", adSource["AdSourceId"]);
|
||
temp.values.Add("From", adSource["From"]);
|
||
|
||
#if JOYPAC_Volcano_OS
|
||
Volcano(temp);
|
||
#endif
|
||
temp.eventname = "event_2";
|
||
#if UNITY_ANDROID && JOYPAC_ReYun
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
|
||
currAdSingleTemp.reyun_report_ad_click(aPPAdsShowCome, aPPAdsShowAdType, adSource["AdSourceId"].ToString(), adSource["From"].ToString());
|
||
// ReYun(temp);
|
||
#endif
|
||
|
||
#if JOYPAC_ReYun && UNITY_IOS && !UNITY_EDITOR
|
||
ReYun(temp);
|
||
#endif
|
||
}
|
||
public void AppAdsReward(Dictionary<string, object> adSource)
|
||
{
|
||
Debug.Log("AppAdsReward========coming");
|
||
|
||
|
||
Debug.Log("AppAdsReward========coming adSource" + adSource.Count);
|
||
|
||
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "App_Ads_Reward";
|
||
temp.values.Add("Come", aPPAdsShowCome);
|
||
temp.values.Add("AdType", aPPAdsShowAdType);
|
||
temp.values.Add("AdSourceId", adSource["AdSourceId"]);
|
||
temp.values.Add("From", adSource["From"]);
|
||
Volcano(temp);
|
||
temp.eventname = "event_30";
|
||
ReYun(temp);
|
||
}
|
||
|
||
|
||
public void App_Banner_Show(Dictionary<string, object> adSource)
|
||
{
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "App_Banner_Show";
|
||
temp.values.Add("Come", "Banner");
|
||
temp.values.Add("AdType", "Banner");
|
||
temp.values.Add("AdSourceId", adSource["AdSourceId"]);
|
||
temp.values.Add("From", adSource["From"]);
|
||
temp.values.Add("price_int", adSource["price_int"]);
|
||
temp.values.Add("price_string", adSource["price_string"]);
|
||
temp.values.Add("currency", adSource["currency"]);
|
||
|
||
#if UNITY_IOS && JOYPAC_Volcano_OS
|
||
Volcano(temp);
|
||
#endif
|
||
|
||
#if ANDROID_CN
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
currAdSingleTemp.reyun_report_ad_show("Banner", "Banner", adSource["AdSourceId"].ToString(), adSource["From"].ToString(), adSource["price_int"].ToString(), adSource["price_string"].ToString(), adSource["currency"].ToString());
|
||
#elif ANDROID_GP
|
||
Volcano(temp);
|
||
ReYun(temp);
|
||
#endif
|
||
temp.eventname = "event_4";
|
||
|
||
#if JOYPAC_ReYun && UNITY_IOS && !UNITY_EDITOR
|
||
ReYun(temp);
|
||
#endif
|
||
}
|
||
public void App_Banner_Click(Dictionary<string, object> adSource)
|
||
{
|
||
VolcanoReYunJson temp = new VolcanoReYunJson();
|
||
temp.eventname = "App_Banner_Click";
|
||
temp.values.Add("Come", "Banner");
|
||
temp.values.Add("AdType", "Banner");
|
||
temp.values.Add("AdSourceId", adSource["AdSourceId"]);
|
||
temp.values.Add("From", adSource["From"]);
|
||
temp.values.Add("price_int", adSource["price_int"]);
|
||
temp.values.Add("price_string", adSource["price_string"]);
|
||
temp.values.Add("currency", adSource["currency"]);
|
||
|
||
#if UNITY_IOS && JOYPAC_Volcano_OS
|
||
Volcano(temp);
|
||
#endif
|
||
|
||
#if ANDROID_CN
|
||
JoyPacCurrentcyAdSingle currAdSingleTemp = new JoyPacCurrentcyAdSingle();
|
||
currAdSingleTemp.reyun_report_ad_click("Banner", "Banner", adSource["AdSourceId"].ToString(), adSource["From"].ToString());
|
||
#elif ANDROID_GP
|
||
Volcano(temp);
|
||
ReYun(temp);
|
||
#endif
|
||
temp.eventname = "event_2";
|
||
#if JOYPAC_ReYun && UNITY_IOS && !UNITY_EDITOR
|
||
ReYun(temp);
|
||
#endif
|
||
}
|
||
|
||
static public void DesignEvent_ECPM(double ecpm, string currency, string eventToken)
|
||
{
|
||
//#if UNITY_ANDROID
|
||
//adjust新增事件:跟踪收入
|
||
AdjustEvent adjustEvent = new AdjustEvent(eventToken);
|
||
adjustEvent.setRevenue(ecpm, currency);
|
||
Adjust.trackEvent(adjustEvent);
|
||
//#endif
|
||
}
|
||
|
||
public void LogEventToken(string _eventToken)
|
||
{
|
||
if (string.IsNullOrEmpty(_eventToken)) return;
|
||
|
||
Adjust.trackEvent(new AdjustEvent(_eventToken));
|
||
Debug.Log("Joypac LogEventWithLabel Adjust: " + _eventToken);
|
||
}
|
||
|
||
|
||
private static bool updateEventToGA = false;
|
||
public void Init()
|
||
{
|
||
//LogTool.DebugLog("[JoypacAnalyticsManager]:init");
|
||
#if UNITY_EDITOR
|
||
return;
|
||
#endif
|
||
|
||
InitUmeng();
|
||
InitGA();
|
||
InitAdjust();
|
||
#if REYUN
|
||
InitReyun ();
|
||
#endif
|
||
#if BUGLY
|
||
InitBugly ();
|
||
#endif
|
||
InitFirebase();
|
||
LogFirstDeviceInfo();
|
||
}
|
||
#region Inits
|
||
|
||
private void InitUmeng()
|
||
{
|
||
#if UNITY_IOS
|
||
Analytics.StartWithAppKeyAndChannelId(DynamicStringsKey.Instance.UMENG_APPKEY, DynamicStringsKey.Instance.UMENG_CHANNELID);
|
||
Analytics.SetLogEnabled(false);
|
||
InitOnlineParams(DynamicStringsKey.Instance.UMENG_APPKEY, false);
|
||
#elif UNITY_ANDROID
|
||
JoyPacUmengBridge.getInstance().initOnlineConfig();
|
||
#endif
|
||
}
|
||
private void InitGA()
|
||
{
|
||
if (UnityEngine.Object.FindObjectOfType(typeof(GameAnalytics)) == null)
|
||
{
|
||
GameObject ga = new GameObject();
|
||
ga.name = "GameAnalytics";
|
||
ga.transform.parent = transform;
|
||
ga.AddComponent<GA_SpecialEvents>();
|
||
ga.AddComponent<GameAnalytics>();
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning("A GameAnalytics object already exists in this scene - you should never have more than one per scene!");
|
||
}
|
||
GameAnalytics.Initialize();
|
||
GA_Wrapper.SetBuild(Application.version);
|
||
GA_Wrapper.Initialize(DynamicStringsKey.Instance.GA_gameKey, DynamicStringsKey.Instance.GA_secretKey);
|
||
LogTool.DebugLog("GA: init :GA_gameKey=" + DynamicStringsKey.Instance.GA_gameKey + "GA_secretKey=" + DynamicStringsKey.Instance.GA_secretKey + " Application.version=" + Application.version);
|
||
}
|
||
private void InitAdjust()
|
||
{
|
||
//LogTool.DebugLog("[JoypacAnalyticsManager]:Adjust init ");
|
||
if (UnityEngine.Object.FindObjectOfType(typeof(Adjust)) == null)
|
||
{
|
||
GameObject ga = new GameObject();
|
||
ga.name = "Adjust";
|
||
//ga.transform.parent = transform;
|
||
ga.AddComponent<Adjust>();
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning("A GameAnalytics object already exists in this scene - you should never have more than one per scene!");
|
||
}
|
||
#if UNITY_ANDROID
|
||
AdjustImei.ReadImei();
|
||
AdjustOaid.ReadOaid();
|
||
#endif
|
||
AdjustConfig config = new AdjustConfig(DynamicStringsKey.Instance.ADJUST_APP_TOKEN, AdjustEnvironment.Production, true);
|
||
config.setLogLevel(AdjustLogLevel.Suppress);
|
||
config.setLogDelegate(msg => LogTool.DebugLog(msg));
|
||
config.setNeedsCost(true);
|
||
if (ConstStringKey.ADJUST_APP_SECRET != 1 || ConstStringKey.ADJUST_APP_INFO1 == 1 || ConstStringKey.ADJUST_APP_INFO2 == 1 || ConstStringKey.ADJUST_APP_INFO3 == 1 || ConstStringKey.ADJUST_APP_INFO4 == 1)
|
||
{
|
||
Debug.LogError("必填项没有手动修改!!【测试期间可忽略】");
|
||
}
|
||
config.setAppSecret(ConstStringKey.ADJUST_APP_SECRET, ConstStringKey.ADJUST_APP_INFO1, ConstStringKey.ADJUST_APP_INFO2, ConstStringKey.ADJUST_APP_INFO3, ConstStringKey.ADJUST_APP_INFO4);
|
||
#if DEVELOPMENT_BUILD || ADJUST_TEST
|
||
config.setEventSuccessDelegate(EventSuccessCallback);
|
||
config.setEventFailureDelegate(EventFailureCallback);
|
||
config.setSessionSuccessDelegate(SessionSuccessCallback);
|
||
config.setSessionFailureDelegate(SessionFailureCallback);
|
||
config.setDeferredDeeplinkDelegate(DeferredDeeplinkCallback);
|
||
#endif
|
||
config.setAttributionChangedDelegate(AttributionChangedCallback);
|
||
Adjust.start(config);
|
||
}
|
||
#if REYUN
|
||
private void InitReyun () {
|
||
#if UNITY_IOS
|
||
Tracking.Instance.init (DynamicStringsKey.Instance.REYUN_APPKEY, DynamicStringsKey.Instance.REYUN_CHANNELID);
|
||
#endif
|
||
}
|
||
#endif
|
||
|
||
#if BUGLY
|
||
private void InitBugly () {
|
||
#if UNITY_IOS
|
||
BuglyAgent.InitWithAppId (DynamicStringsKey.Instance.BUGLY_APP_ID);
|
||
BuglyAgent.EnableExceptionHandler ();
|
||
#endif
|
||
}
|
||
#endif
|
||
|
||
public static bool isFirebaseInitSucc = false;
|
||
private void InitFirebase()
|
||
{
|
||
#if USER_FIREBASE
|
||
Firebase.FirebaseApp.CheckAndFixDependenciesAsync ().ContinueWith (task => {
|
||
var dependencyStatus = task.Result;
|
||
if (dependencyStatus == Firebase.DependencyStatus.Available) {
|
||
// Create and hold a reference to your FirebaseApp,
|
||
// where app is a Firebase.FirebaseApp property of your application class.
|
||
// app = Firebase.FirebaseApp.DefaultInstance;
|
||
|
||
// Set a flag here to indicate whether Firebase is ready to use by your app.
|
||
|
||
LogTool.DebugLog(GetType() + "firebase init succ callback.");
|
||
StartCoroutine(FirebaseLogInit());
|
||
|
||
}
|
||
else
|
||
{
|
||
UnityEngine.Debug.LogError(GetType() + System.String.Format(
|
||
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
|
||
// Firebase Unity SDK is not safe to use here.
|
||
}
|
||
});
|
||
#endif
|
||
}
|
||
#endregion
|
||
#if USER_FIREBASE
|
||
IEnumerator FirebaseLogInit()
|
||
{
|
||
LogTool.DebugLog("FirebaseLogInit start");
|
||
yield return new WaitForSeconds(1);
|
||
isFirebaseInitSucc = true;
|
||
StaticOnlineParams.Init();
|
||
LogTool.DebugLog("FirebaseLogInit end");
|
||
|
||
}
|
||
#endif
|
||
#region Events
|
||
|
||
|
||
private void LogFirstDeviceInfo()
|
||
{
|
||
#if UNITY_IOS
|
||
string LogFirstDeviceInfoKey = "LogFirstDeviceInfoKey";
|
||
if (CryptoPrefs.GetInt(LogFirstDeviceInfoKey, 0) == 0)
|
||
{
|
||
CryptoPrefs.SetInt(LogFirstDeviceInfoKey, 1);
|
||
ReyunLogEventToken(JoypacUtils.isIpad ? StaticStringsEvent.DEVICEINFO_IPAD : StaticStringsEvent.DEVICEINFO_IPHONE);
|
||
AdjustLogEventToken(JoypacUtils.isIpad ? ConstStringKey.Instance.DEVICEINFO_IPAD_TOKEN : ConstStringKey.Instance.DEVICEINFO_IPHONE_TOKEN);
|
||
}
|
||
#endif
|
||
}
|
||
//默认只上报joypac,此函数只上报游戏内DesignEvent打点。产品设计的自定义打点。
|
||
static JoypacLogType _logType = JoypacLogType.JoypacSdk | JoypacLogType.GA;
|
||
|
||
|
||
/// <summary>
|
||
/// Designs the event.设计事件调用接口
|
||
/// </summary>
|
||
/// <param name="onlyFirst">参数含义:true 同一个Event只有第一次传入才上报,false 同一个Event无论第几次传入都会上报,默认false </param>
|
||
static public void DesignEvent(string sort, string type, string position, bool onlyFirst = false, string extra = "")
|
||
{
|
||
//如果已购买去广告,并且去广告后激励视频直接给奖励,则不再上报激励视频相关打点
|
||
if (JoypacUtils.IfRemoveAds() == true && JoypacUtils.NoAdsAndNoRewardVideo())
|
||
{
|
||
if (sort == StaticStringsEvent.Ad)
|
||
{
|
||
LogTool.DebugLog("joypac: vip dont log event sort== 'Ad'");
|
||
return;
|
||
}
|
||
}
|
||
if (onlyFirst)
|
||
{
|
||
if (CryptoPrefs.HasKey(GetString(sort, type, position, extra)))
|
||
{
|
||
LogTool.DebugLog(GetString(sort, type, position, extra) + " not first ", LogTool.Color.lightblue);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
CryptoPrefs.SetInt(GetString(sort, type, position, extra), 1);
|
||
}
|
||
}
|
||
LogTool.DebugLog(" _logType = " + _logType + " " + GetString(sort, type, position, extra), LogTool.Color.lightblue);
|
||
#if UNITY_EDITOR
|
||
return;
|
||
#endif
|
||
#if REYUN
|
||
if ((_logType & JoypacLogType.Reyun) > 0)
|
||
{
|
||
LogTool.Error("Reyun dont have DesignEvent");
|
||
//string str = GetString(sort, type, position,extra);
|
||
//if (!string.IsNullOrEmpty(str))
|
||
//if (str.Length >= 40)
|
||
//{
|
||
// LogTool.DebugLog("Error Reyun str.Length>=40");
|
||
//}
|
||
//else
|
||
//{
|
||
// Tracking.Instance.setEvent(str);
|
||
//}
|
||
|
||
}
|
||
#endif
|
||
if ((_logType & JoypacLogType.Adjust) > 0)
|
||
{
|
||
LogTool.Error("Adjust dont have DesignEvent");
|
||
//string str = GetString( sort, type, position,extra);
|
||
//if (!string.IsNullOrEmpty(str))
|
||
//if (str.Length >= 40)
|
||
//{
|
||
// LogTool.DebugLog("Adjust str.Length>=40");
|
||
//}
|
||
//else
|
||
//{
|
||
// Adjust.trackEvent(new AdjustEvent(str));
|
||
//}
|
||
|
||
}
|
||
if ((_logType & JoypacLogType.GA) > 0)
|
||
{
|
||
string str = GetString(sort, type, position, extra);
|
||
if (!string.IsNullOrEmpty(str))
|
||
GameAnalytics.NewDesignEvent(str);
|
||
}
|
||
|
||
#if USER_FIREBASE
|
||
|
||
if ((_logType & JoypacLogType.Firebase) > 0 && JoypacAnalyticsManager.isFirebaseInitSucc == true)
|
||
{
|
||
string str = GetString(sort, type, position,extra);
|
||
if (!string.IsNullOrEmpty(str))
|
||
if (str.Length >= 40)
|
||
{
|
||
LogTool.Error("Error Firebase str.Length>=40");
|
||
}
|
||
else
|
||
{
|
||
Firebase.Analytics.FirebaseAnalytics.LogEvent(str);
|
||
}
|
||
|
||
}
|
||
#endif
|
||
if ((_logType & JoypacLogType.JoypacSdk) > 0)
|
||
{
|
||
if (string.IsNullOrEmpty(sort) || string.IsNullOrEmpty(type) || string.IsNullOrEmpty(position))
|
||
{
|
||
LogTool.Error("Error sort=" + sort + " type=" + type + " position=" + position);
|
||
return;
|
||
}
|
||
|
||
JoypacEventLog(sort, type, position, extra);
|
||
|
||
//Tool.Log("Joypac LogEventWithLabel Firebase: " + _eventName + " label:" + _label);
|
||
}
|
||
|
||
#if UNITY_IOS
|
||
|
||
if ((_logType & JoypacLogType.Umeng) > 0)
|
||
{
|
||
string str = GetString(sort, type, position, extra);
|
||
if (!string.IsNullOrEmpty(str))
|
||
if (str.Length >= 40)
|
||
{
|
||
LogTool.Error("Error Umeng str.Length>=40");
|
||
}
|
||
else
|
||
{
|
||
Analytics.Event(str);
|
||
}
|
||
|
||
//Tool.Log("Joypac LogEventWithLabel Umeng: " + _eventName + " label:" + _label);
|
||
}
|
||
|
||
#elif UNITY_ANDROID
|
||
if ((_logType & JoypacLogType.Umeng) > 0)
|
||
{
|
||
string str = GetString(sort, type, position, extra);
|
||
if (string.IsNullOrEmpty(str))
|
||
{
|
||
if (str.Length >= 40)
|
||
{
|
||
LogTool.Error("Error Umeng str.Length>=40");
|
||
}
|
||
else
|
||
{
|
||
JoyPacUmengBridge.getInstance().uMengEventWithLabel(str, "");
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//JLog.Log("Joypac LogEventWithLabel Umeng: " + _eventName + " label:" + _label);
|
||
}
|
||
#endif
|
||
|
||
}
|
||
static string GetString(string sort, string type, string position, string extra = "")
|
||
{
|
||
string str;
|
||
if (string.IsNullOrEmpty(extra))
|
||
{
|
||
str = string.Format("{0}:{1}:{2}", sort, type, position);
|
||
}
|
||
else
|
||
{
|
||
str = string.Format("{0}:{1}:{2}:{3}", sort, type, position, extra);
|
||
}
|
||
return str;
|
||
}
|
||
|
||
public void ReyunLogEventToken(string _eventToken)
|
||
{
|
||
#if REYUN
|
||
if (string.IsNullOrEmpty(_eventToken)) return;
|
||
|
||
Tracking.Instance.setEvent(_eventToken);
|
||
LogTool.DebugLog("Joypac LogEventWithLabel Reyun: " + _eventToken);
|
||
#endif
|
||
}
|
||
public void AdjustLogEventToken(string _eventToken)
|
||
{
|
||
if (string.IsNullOrEmpty(_eventToken)) return;
|
||
|
||
Adjust.trackEvent(new AdjustEvent(_eventToken));
|
||
LogTool.DebugLog("Joypac LogEventWithLabel Adjust: " + _eventToken);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region adjust
|
||
public void AttributionChangedCallback(AdjustAttribution attribution)
|
||
{
|
||
LogTool.DebugLog("adjust:Attribution changed");
|
||
JoypacAdjustAttribution joypacAdjustAttribution = new JoypacAdjustAttribution(attribution);
|
||
string json = JsonUtility.ToJson(joypacAdjustAttribution);
|
||
LogTool.DebugLog("adjust:attribution to json =" + json);
|
||
ReceiveAdJustData(json);
|
||
|
||
// ...
|
||
|
||
#if JOYPAC_Volcano_OS && UNITY_IOS //&& !UNITY_EDITOR
|
||
JoypacAdjustFinder joypacAdjustFinder = new JoypacAdjustFinder(attribution);
|
||
string jsonFinder = JsonUtility.ToJson(joypacAdjustFinder);
|
||
Debug.Log(jsonFinder);
|
||
JoypacAdClient.Instance.ProfileSet(jsonFinder);
|
||
|
||
#endif
|
||
}
|
||
#if DEVELOPMENT_BUILD || ADJUST_TEST
|
||
public void EventSuccessCallback(AdjustEventSuccess eventSuccessData)
|
||
{
|
||
LogTool.DebugLog("adjust:Event tracked successfully!");
|
||
|
||
if (eventSuccessData.Message != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Message: " + eventSuccessData.Message);
|
||
}
|
||
if (eventSuccessData.Timestamp != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Timestamp: " + eventSuccessData.Timestamp);
|
||
}
|
||
if (eventSuccessData.Adid != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Adid: " + eventSuccessData.Adid);
|
||
}
|
||
if (eventSuccessData.EventToken != null)
|
||
{
|
||
LogTool.DebugLog("adjust:EventToken: " + eventSuccessData.EventToken);
|
||
}
|
||
if (eventSuccessData.CallbackId != null)
|
||
{
|
||
LogTool.DebugLog("adjust:CallbackId: " + eventSuccessData.CallbackId);
|
||
}
|
||
if (eventSuccessData.JsonResponse != null)
|
||
{
|
||
LogTool.DebugLog("adjust:JsonResponse: " + eventSuccessData.GetJsonResponse());
|
||
}
|
||
}
|
||
|
||
public void EventFailureCallback(AdjustEventFailure eventFailureData)
|
||
{
|
||
LogTool.DebugLog("adjust:Event tracking failed!");
|
||
|
||
if (eventFailureData.Message != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Message: " + eventFailureData.Message);
|
||
}
|
||
if (eventFailureData.Timestamp != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Timestamp: " + eventFailureData.Timestamp);
|
||
}
|
||
if (eventFailureData.Adid != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Adid: " + eventFailureData.Adid);
|
||
}
|
||
if (eventFailureData.EventToken != null)
|
||
{
|
||
LogTool.DebugLog("adjust:EventToken: " + eventFailureData.EventToken);
|
||
}
|
||
if (eventFailureData.CallbackId != null)
|
||
{
|
||
LogTool.DebugLog("adjust:CallbackId: " + eventFailureData.CallbackId);
|
||
}
|
||
if (eventFailureData.JsonResponse != null)
|
||
{
|
||
LogTool.DebugLog("adjust:JsonResponse: " + eventFailureData.GetJsonResponse());
|
||
}
|
||
|
||
LogTool.DebugLog("adjust:WillRetry: " + eventFailureData.WillRetry.ToString());
|
||
}
|
||
|
||
public void SessionSuccessCallback(AdjustSessionSuccess sessionSuccessData)
|
||
{
|
||
LogTool.DebugLog("adjust:Session tracked successfully!");
|
||
|
||
if (sessionSuccessData.Message != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Message: " + sessionSuccessData.Message);
|
||
}
|
||
if (sessionSuccessData.Timestamp != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Timestamp: " + sessionSuccessData.Timestamp);
|
||
}
|
||
if (sessionSuccessData.Adid != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Adid: " + sessionSuccessData.Adid);
|
||
}
|
||
if (sessionSuccessData.JsonResponse != null)
|
||
{
|
||
LogTool.DebugLog("adjust:JsonResponse: " + sessionSuccessData.GetJsonResponse());
|
||
}
|
||
}
|
||
|
||
public void SessionFailureCallback(AdjustSessionFailure sessionFailureData)
|
||
{
|
||
LogTool.DebugLog("adjust:Session tracking failed!");
|
||
|
||
if (sessionFailureData.Message != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Message: " + sessionFailureData.Message);
|
||
}
|
||
if (sessionFailureData.Timestamp != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Timestamp: " + sessionFailureData.Timestamp);
|
||
}
|
||
if (sessionFailureData.Adid != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Adid: " + sessionFailureData.Adid);
|
||
}
|
||
if (sessionFailureData.JsonResponse != null)
|
||
{
|
||
LogTool.DebugLog("adjust:JsonResponse: " + sessionFailureData.GetJsonResponse());
|
||
}
|
||
|
||
LogTool.DebugLog("adjust:WillRetry: " + sessionFailureData.WillRetry.ToString());
|
||
}
|
||
|
||
private void DeferredDeeplinkCallback(string deeplinkURL)
|
||
{
|
||
LogTool.DebugLog("adjust:Deferred deeplink reported!");
|
||
|
||
if (deeplinkURL != null)
|
||
{
|
||
LogTool.DebugLog("adjust:Deeplink URL: " + deeplinkURL);
|
||
}
|
||
else
|
||
{
|
||
LogTool.DebugLog("adjust:Deeplink URL is null!");
|
||
}
|
||
}
|
||
#endif
|
||
public static void JoypacEventLog(string event_sort, string event_type, string event_position, string event_extra)
|
||
{
|
||
#if UNITY_EDITOR
|
||
LogTool.DebugLog("JoypacAnalyticsManager:" + " " + event_sort + " type:" + event_type + " position:" + event_position + " event_extra:" + event_extra);
|
||
return;
|
||
#endif
|
||
#if UNITY_IOS
|
||
JoypacAdClient.Instance.eventLog(event_sort, event_type, event_position, event_extra);
|
||
#elif UNITY_ANDROID
|
||
JoypacSDKAdapter.Instance.joypacEventLog(event_sort, event_type, event_position, event_extra);
|
||
#endif
|
||
}
|
||
public static void ReceiveAdJustData(string json)
|
||
{
|
||
#if UNITY_EDITOR
|
||
LogTool.DebugLog("JoypacAnalyticsManager:" + " ReceiveAdJustData=" + json);
|
||
return;
|
||
#endif
|
||
#if UNITY_IOS
|
||
JoypacAdClient.Instance.ReceiveAdJustData(json);
|
||
#elif UNITY_ANDROID
|
||
JoypacSDKAdapter.Instance.ReceiveAdJustData(json);
|
||
#endif
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
|
||
public enum JoypacLogType
|
||
{
|
||
GA = 1,
|
||
Umeng = 1 << 1,
|
||
Adjust = 1 << 2,
|
||
Reyun = 1 << 3,
|
||
Firebase = 1 << 4,
|
||
JoypacSdk = 1 << 5,
|
||
|
||
}
|
||
[Serializable]
|
||
public class JoypacAdjustAttribution
|
||
{
|
||
[SerializeField]
|
||
public string trackerToken = "";
|
||
[SerializeField]
|
||
public string adgroup = "";
|
||
[SerializeField]
|
||
public string creative = "";
|
||
[SerializeField]
|
||
public string adid = "";
|
||
[SerializeField]
|
||
public string clickLabel = "";
|
||
[SerializeField]
|
||
public string network = "";
|
||
[SerializeField]
|
||
public string trackerName = "";
|
||
public JoypacAdjustAttribution(AdjustAttribution attribution)
|
||
{
|
||
trackerToken = attribution.trackerToken;
|
||
adgroup = attribution.adgroup;
|
||
creative = attribution.creative;
|
||
adid = attribution.adid;
|
||
clickLabel = attribution.clickLabel;
|
||
network = attribution.network;
|
||
trackerName = attribution.trackerName;
|
||
}
|
||
|
||
}
|
||
|
||
[Serializable]
|
||
public class JoypacAdjustFinder
|
||
{
|
||
|
||
[SerializeField]
|
||
public string adjust_trackerToken = "";
|
||
[SerializeField]
|
||
public string adjust_adgroup = "";
|
||
[SerializeField]
|
||
public string adjust_creative = "";
|
||
[SerializeField]
|
||
public string adjust_adid = "";
|
||
[SerializeField]
|
||
public string adjust_clickLabel = "";
|
||
[SerializeField]
|
||
public string adjust_network = "";
|
||
[SerializeField]
|
||
public string adjust_trackerName = "";
|
||
[SerializeField]
|
||
public string adjust_campaign = "";
|
||
[SerializeField]
|
||
public string adjust_costType = "";
|
||
//finder不支持double
|
||
[SerializeField]
|
||
public float adjust_costAmount = 0.0f;
|
||
[SerializeField]
|
||
public string adjust_costCurrency = "";
|
||
[SerializeField]
|
||
public string version = "";
|
||
|
||
public JoypacAdjustFinder(AdjustAttribution attribution)
|
||
{
|
||
|
||
adjust_trackerToken = attribution.trackerToken;
|
||
adjust_adgroup = attribution.adgroup;
|
||
adjust_creative = attribution.creative;
|
||
adjust_adid = attribution.adid;
|
||
adjust_clickLabel = attribution.clickLabel;
|
||
adjust_network = attribution.network;
|
||
adjust_trackerName = attribution.trackerName;
|
||
adjust_campaign = attribution.campaign;
|
||
adjust_costType = attribution.costType;
|
||
if (attribution.costAmount != null)
|
||
{
|
||
adjust_costAmount = (float)attribution.costAmount;
|
||
}
|
||
adjust_costCurrency = attribution.costCurrency;
|
||
version = Application.version;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
public class VolcanoReYunJson
|
||
{
|
||
public string eventname;
|
||
public Dictionary<string, object> values = new Dictionary<string, object>();
|
||
|
||
|
||
}
|
||
|
||
public class VolcanoReYunJson1
|
||
{
|
||
public string eventname;
|
||
public Dictionary<string, object> values = new Dictionary<string, object>();
|
||
|
||
|
||
}
|
||
|
||
|
||
public class ADListenerJson
|
||
{
|
||
|
||
public string AdSourceId;
|
||
public string From;
|
||
public string price_int;
|
||
public string currency;
|
||
|
||
|
||
}
|
||
|
||
|
||
|