Merge branch 'feature/analytics_1.1.1' into release/V1.1.0

Signed-off-by: huyufei <yufei.hu@castbox.fm>

# Conflicts:
#	Runtime/GuruAnalytics/Plugins/Android/U3DAnalytics-1.10.4.aar.meta
#	Runtime/GuruAnalytics/Plugins/Android/U3DAnalytics-1.10.5.aar.meta
#	Runtime/GuruAnalytics/Plugins/Android/U3DAnalytics-1.11.1.aar.meta
#	Runtime/GuruAnalytics/Plugins/Android/guru-analytics-1.1.1.aar
#	Runtime/GuruAnalytics/README.md
#	Runtime/GuruAnalytics/Runtime/Script/GuruAnalytics.cs
#	Runtime/GuruAnalytics/Runtime/Script/IAnalyticsAgent.cs
#	Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentAndroid.cs
#	Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentIOS.cs
#	Runtime/GuruAnalytics/Runtime/Script/Impl/AnalyticsAgentMock.cs
#	Runtime/GuruCore/Runtime/Analytics/Analytics.Custom.cs
#	Runtime/GuruCore/Runtime/Analytics/Analytics.cs
#	Runtime/GuruCore/Runtime/Firebase/FirebaseUtil.cs
#	Runtime/GuruCore/Runtime/Reporter/CrashlyticsAgent.cs
胡宇飞 2024-07-31 20:58:52 +08:00
commit 23c1b8f4fc
28 changed files with 516 additions and 2524 deletions

View File

@ -53,9 +53,12 @@ namespace Guru
/// </summary>
/// <param name="appToken"></param>
/// <param name="fbAppId">MIR 追踪 AppID</param>
/// <param name="onInitComplete"></param>
/// <param name="deviceId"></param>
/// <param name="onInitComplete">初始化完成的时候会返回 AdjustId </param>
/// <param name="onDeeplinkCallback"></param>
public static void StartService(string appToken, string fbAppId = "", Action<string> onInitComplete = null, Action<string> onDeeplinkCallback = null)
/// <param name="firebaseId"></param>
public static void StartService(string appToken, string fbAppId = "", string firebaseId = "", string deviceId = "",
Action<string> onInitComplete = null, Action<string> onDeeplinkCallback = null)
{
if (string.IsNullOrEmpty(appToken))
{
@ -65,7 +68,7 @@ namespace Guru
_onInitComplete = onInitComplete;
InstallEvent(IPMConfig.FIREBASE_ID, IPMConfig.IPM_DEVICE_ID); // 注入启动参数
InstallEvent(firebaseId, deviceId); // 注入启动参数
AdjustEnvironment environment = GetAdjustEnvironment();
AdjustConfig config = new AdjustConfig(appToken, environment);

View File

@ -8,18 +8,20 @@ Sample Dependencies.xml:
<androidPackage spec="androidx.core:core:1.7.0" />
<!-- <androidPackage spec="androidx.appcompat:appcompat:1.5.1" />-->
<androidPackage spec="androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" />
<androidPackage spec="androidx.work:work-runtime:2.7.1" />
<androidPackage spec="androidx.work:work-runtime-ktx:2.7.1" />
<androidPackage spec="androidx.work:work-rxjava2:2.7.1" />
<androidPackage spec="androidx.work:work-runtime:2.8.1" />
<androidPackage spec="androidx.work:work-runtime-ktx:2.8.1" />
<androidPackage spec="androidx.work:work-rxjava2:2.8.1" />
<androidPackage spec="androidx.lifecycle:lifecycle-process:2.4.0" />
<androidPackage spec="com.jakewharton.timber:timber:4.7.1" />
<androidPackage spec="com.google.code.gson:gson:2.8.5" />
<androidPackage spec="androidx.room:room-runtime:2.4.3" />
<androidPackage spec="androidx.room:room-rxjava2:2.4.3" />
<androidPackage spec="androidx.room:room-runtime:2.6.1" />
<androidPackage spec="androidx.room:room-rxjava2:2.6.1" />
<androidPackage spec="com.squareup.retrofit2:retrofit:2.7.1" />
<androidPackage spec="com.squareup.retrofit2:converter-gson:2.7.1" />
<androidPackage spec="com.squareup.retrofit2:adapter-rxjava2:2.7.1" />
<androidPackage spec="com.squareup.okhttp3:okhttp:4.9.3" />
<androidPackage spec="com.squareup.okhttp3:okhttp:4.12.0" />
<androidPackage spec="com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0" />
<androidPackage spec="com.google.net.cronet:cronet-okhttp:0.1.0" />
<!-- <androidPackage spec="com.mapzen:on-the-road:0.8.1" />-->
<!-- <androidPackage spec="com.squareup.retrofit2:retrofit:2.7.1" />-->
</androidPackages>

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 8009d3bf70bb4438599a32f6ea601f9d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f6d79ccb59bc4a5791121a696d6695b0
timeCreated: 1721722422

View File

@ -1,6 +1,3 @@
namespace Guru
{
using System;
@ -11,10 +8,25 @@ namespace Guru
using UnityEngine;
using System.Diagnostics.CodeAnalysis;
/// <summary>
/// 自打点初始化配置
/// </summary>
public class GuruAnalyticsInitConfig
{
public bool usingExtraSettings = false;
public string baseUrl = "";
public string[] uploadIpAddress = null;
public bool enableErrorLog = false;
public bool isDebug = false;
public Action onInitComplete = null;
}
public class GuruAnalytics
{
// Plugin Version
private const string Version = "1.11.1";
private const string Version = "1.12.0";
public static readonly string Tag = "[ANU]";
private static readonly string ActionName = "logger_error";
@ -105,20 +117,37 @@ namespace Guru
/// <summary>
/// 初始化接口
/// </summary>
public static void Init(string appId, string deviceInfo, Action onInitComplete, bool isDebug = false,
bool enableErrorLog = false)
public static void Init(string appId, string deviceInfo, GuruAnalyticsInitConfig initConfig, Action onInitComplete = null)
{
Debug.Log($"{Tag} --- Guru Analytics [{Version}] initialing...");
if (_instance == null)
{
_instance = new GuruAnalytics();
_instance.Agent.Init(appId, deviceInfo, onInitComplete, isDebug);
_instance.EnableErrorLog = enableErrorLog;
#if UNITY_ANDROID
if (initConfig.usingExtraSettings && Instance.Agent is AnalyticsAgentAndroid androidAgent)
{
// 强制转换为 Android 的自打点初始化接口
androidAgent.InitAndroidConfig(appId, deviceInfo,
initConfig.baseUrl, initConfig.uploadIpAddress, // <--- Android 附加参数
onInitComplete,initConfig.isDebug);
}
else
{
// 外部(云控)如果关闭使用 Android 自打点附加参数, 则使用正常的启动接口
_instance.Agent.Init(appId, deviceInfo, onInitComplete, initConfig.isDebug);
}
#else
// iOS 使用正常的启动接口
_instance.Agent.Init(appId, deviceInfo, onInitComplete, initConfig.isDebug);
#endif
_instance.EnableErrorLog = initConfig.enableErrorLog;
_instance._isReady = true;
}
}
/// <summary>
/// 设置视图名称
/// </summary>
@ -450,92 +479,6 @@ namespace Guru
}
}
/**
private void ParseWithRaw(string raw)
{
var code = (int)AnalyticsCode.Unknown;
string info;
//------- message send to unity ----------
Debug.Log($"{Tag} get callback errorInfo:\n{raw}");
var patten = "msg\":\"";
if (raw.Contains(patten))
{
info = raw.Substring(raw.IndexOf(patten, StringComparison.Ordinal) + patten.Length);
if (!string.IsNullOrEmpty(info))
{
if (info.StartsWith("\"")) info = info.Substring(1, info.Length - 1);
if (info.EndsWith("\"}}")) info = info.Replace("\"}}", "");
}
else
{
info = "msg is null";
}
}
else
{
info = "no msg property";
}
try
{
var idx = raw.IndexOf(patten, StringComparison.Ordinal) + patten.Length;
string act = raw.Substring(idx, ActionName.Length);
if (act == ActionName)
{
patten = "code\":";
var patten2 = ",\"msg";
idx = raw.IndexOf(patten, StringComparison.Ordinal);
var idx2 = raw.IndexOf(patten2, StringComparison.Ordinal);
var len = idx2 - (idx + patten.Length);
if (len > 0)
{
string c = raw.Substring(idx + patten.Length, len);
int.TryParse(c, out code);
}
// Catch target code to report errors
switch ((AnalyticsCode)code)
{
case AnalyticsCode.Network_Lost:
case AnalyticsCode.ERROR_API:
case AnalyticsCode.ERROR_RESPONSE:
case AnalyticsCode.ERROR_CACHE_CONTROL:
case AnalyticsCode.ERROR_DELETE_EXPIRED:
case AnalyticsCode.ERROR_LOAD_MARK:
case AnalyticsCode.ERROR_DNS:
case AnalyticsCode.ERROR_ZIP:
OnLoggerErrorEvent(code, info);
return;
}
return;
}
}
catch (Exception ex)
{
Debug.LogError($"{Tag} Catch ex: {ex}\tJson:{raw}");
Analytics.LogCrashlytics(raw, false);
Analytics.LogCrashlytics($"{Tag} --- Json:{raw} Ex:{ex}");
OnLoggerErrorEvent(code, info);
return;
}
if (raw.Contains("msg"))
{
Analytics.LogCrashlytics(raw, false);
Analytics.LogCrashlytics($"{Tag} --- format error:{raw}");
OnLoggerErrorEvent(code, raw.Substring(raw.IndexOf("msg\":", StringComparison.Ordinal) + 5));
}
}
**/
private void ReportCodeInfo(int code, string info)
{
var ac = (AnalyticsCode)code;
@ -558,11 +501,13 @@ namespace Guru
case AnalyticsCode.ERROR_ZIP:
case AnalyticsCode.ERROR_DNS_CACHE:
case AnalyticsCode.CRONET_INTERCEPTOR:
case AnalyticsCode.EVENT_LOOKUP:
case AnalyticsCode.EVENT_SESSION_ACTIVE:
canCatch = true;
break;
}
if (code > 100 && code <= 200)
if (!canCatch && code is > 100 and <= 200)
{
// 100 < code <= 200
canCatch = true;
@ -601,6 +546,8 @@ namespace Guru
}
/// <summary>
/// 网络状态枚举
/// </summary>
@ -608,21 +555,24 @@ namespace Guru
{
Unknown = -1,
DELETE_EXPIRED = 12,
UPLOAD_FAIL = 14,
NETWORK_LOST = 22,
CRONET_INIT_FAIL = 26,
CRONET_INIT_EXCEPTION = 27,
DELETE_EXPIRED = 12, // 删除过期事件
UPLOAD_FAIL = 14, // 上报事件失败
NETWORK_LOST = 22, // 网络状态不可用
CRONET_INIT_FAIL = 26, // 开启Cronet失败
CRONET_INIT_EXCEPTION = 27, // 开启Cronet报错
ERROR_API = 101,
ERROR_RESPONSE = 102,
ERROR_CACHE_CONTROL = 103,
ERROR_DELETE_EXPIRED = 104,
ERROR_LOAD_MARK = 105,
ERROR_DNS = 106,
ERROR_ZIP = 107,
ERROR_DNS_CACHE = 108,
CRONET_INTERCEPTOR = 109,
ERROR_API = 101, // 调用api出错
ERROR_RESPONSE = 102, // api返回结果错误
ERROR_CACHE_CONTROL = 103, // 设置cacheControl出错
ERROR_DELETE_EXPIRED = 104, // 删除过期事件出错
ERROR_LOAD_MARK = 105, // 从数据库取事件以及更改事件状态为正在上报出错
ERROR_DNS = 106, // dns 错误
ERROR_ZIP = 107, // zip 错误
ERROR_DNS_CACHE = 108, // zip 错误
CRONET_INTERCEPTOR = 109, // cronet拦截器
EVENT_LOOKUP = 1003,
EVENT_SESSION_ACTIVE = 1004,
}
}

View File

@ -17,7 +17,7 @@ namespace Guru
void SetUid(string uid);
bool IsDebug { get; }
bool EnableErrorLog { get; set; }
void LogEvent(string eventName, string parameters, int priority = -1);
void LogEvent(string eventName, string parameters, int priority = 0);
void ReportEventSuccessRate(); // 上报任务成功率
void SetTch02Value(double value); // 设置太极02数值
void InitCallback(string objName, string method); // 设置回调对象参数

View File

@ -6,6 +6,7 @@ namespace Guru
{
using System;
using UnityEngine;
using System.Collections.Generic;
public class AnalyticsAgentAndroid: IAnalyticsAgent
{
@ -18,14 +19,10 @@ namespace Guru
#endif
private static bool _isDebug = false;
public static bool UseWorker = true;
public static bool UseCronet = false;
public static string BaseUrl = "";
#region 工具方法
/// <summary>
/// 调用静态方法
/// </summary>
@ -80,18 +77,70 @@ namespace Guru
#region 接口实现
public async void Init(string appId, string deviceInfo, Action onInitComplete, bool isDebug = false)
/// <summary>
/// 默认的启动参数
/// </summary>
/// <param name="appId"></param>
/// <param name="deviceInfo"></param>
/// <param name="onInitComplete"></param>
/// <param name="isDebug"></param>
public void Init(string appId, string deviceInfo, Action onInitComplete, bool isDebug = false)
{
_isDebug = isDebug;
string bundleId = Application.identifier;
// public static void init(String appId, String deviceInfo, String bundleId, boolean isDebug, boolean useWorker, boolean useCronet, String baseUrl)
bool useWorker = true;
bool useCronet = false;
string baseUrl = "";
string[] uploadIpAddress = null;
CallSDKInit(appId, deviceInfo, bundleId, baseUrl, uploadIpAddress , useWorker, useCronet, isDebug); // 调用接口
onInitComplete?.Invoke();
}
// TODO: 将来把 CallStatic 转为异步实现
CallStatic("init", appId, deviceInfo, bundleId, isDebug, UseWorker, UseCronet, BaseUrl); // 调用接口
/// <summary>
/// 面向 Android 启动专用的 API
/// </summary>
/// <param name="appId"></param>
/// <param name="deviceInfo"></param>
/// <param name="baseUrl"></param>
/// <param name="uploadIpAddress"></param>
/// <param name="onInitComplete"></param>
/// <param name="isDebug"></param>
public void InitAndroidConfig(string appId, string deviceInfo, string baseUrl, string[]uploadIpAddress,Action onInitComplete = null, bool isDebug = false)
{
_isDebug = isDebug;
string bundleId = Application.identifier;
bool useWorker = true;
bool useCronet = false;
CallSDKInit(appId, deviceInfo, bundleId, baseUrl, uploadIpAddress , useWorker, useCronet, _isDebug); // 调用接口
onInitComplete?.Invoke();
}
/********* Android API **********
public static void init(String appId,
String deviceInfo,
String bundleId,
boolean debug,
boolean useWorker,
boolean enabledCronet,
String baseUrl,
List<String> uploadIpAddress)
*/
private void CallSDKInit(string appId,
string deviceInfo,
string bundleId,
string baseUrl = "",
string[] uploadIpAddress = null,
bool useWorker = true,
bool useCronet = false,
bool isDebug = false)
{
CallStatic("init", appId, deviceInfo, bundleId, isDebug, useWorker, useCronet, baseUrl, string.Join(",", uploadIpAddress)); // 调用接口
}
public void SetScreen(string screenName)
{
if (string.IsNullOrEmpty(screenName)) return;
@ -134,10 +183,7 @@ namespace Guru
}
public bool IsDebug => CallStatic<bool>("isDebug");
public void LogEvent(string eventName, string parameters, int priority = -1)
{
CallStatic("logEvent", eventName, parameters, priority);
}
public void LogEvent(string eventName, string parameters, int priority = 0) => CallStatic("logEvent", eventName, parameters, priority);
public void ReportEventSuccessRate() => CallStatic("reportEventRate");
public void SetTch02Value(double value) => CallStatic("setTch02Value", value);
public void InitCallback(string objName, string method) => CallStatic("initCallback", objName, method);

View File

@ -125,7 +125,7 @@ namespace Guru
public bool IsDebug => _isDebug;
public void LogEvent(string eventName, string data, int priority = -1)
public void LogEvent(string eventName, string data, int priority = 0)
{
#if UNITY_IOS
unityLogEvent(eventName, data);

View File

@ -92,7 +92,7 @@ namespace Guru
public bool IsDebug => _isDebug;
public void LogEvent(string eventName, string parameters, int priority = -1)
public void LogEvent(string eventName, string parameters, int priority = 0)
{
if (_isShowLog)
{

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 82693d012b64748c8ac997389b0426a7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,143 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Guru
{
public class GuruAnalyticsDemo: MonoBehaviour
{
[SerializeField] private bool _isDebug = true;
[SerializeField] private Button _btnInitSDK;
[SerializeField] private Button _btnStatus;
[SerializeField] private Button _btnUserProperties;
[SerializeField] private Button _btnEvents;
[SerializeField] private Button _btnEvents2;
[SerializeField] private Button _btnReport;
[SerializeField] private Button _btnTestCrash;
// ----------- All Status IDs -----------
private static readonly string AdjustID = "e35b41522140fa2db9089ef3c78eb8f9";
private static readonly string FirebaseID = "b7ab5fc399a7bc8725c004943fa82837";
private static readonly string UID = "BS-YYYYF";
private static readonly string AdID = "dda3cc2b-5a5e-44cb-8a59-4a0b1b3780fd";
private static readonly string DeviceID = "e2fb3c5a4c36473648c989bd86a41153";
private static readonly string AppID = "";
private static readonly string DeviceInfo = "";
private static readonly string ScreenName = "MainMenu";
private void Awake()
{
_btnInitSDK.onClick.AddListener(OnClickInit);
_btnStatus.onClick.AddListener(OnClickStatus);
_btnUserProperties.onClick.AddListener(OnClickUserProperties);
_btnEvents.onClick.AddListener(OnClickEvents);
_btnEvents2.onClick.AddListener(OnClickEvents2);
_btnReport.onClick.AddListener(OnClickReport);
_btnTestCrash.onClick.AddListener(OnClickTestCrash);
#if !UNITY_IOS
_btnTestCrash.gameObject.SetActive(false);
#endif
}
#region Button Callbacks
private void OnClickInit()
{
Debug.Log($"---- [DEMO] Call Analytics init");
GuruAnalytics.Init(AppID, DeviceInfo, OnGuruAnalyticsInitComplete, _isDebug);
}
private void OnGuruAnalyticsInitComplete()
{
}
private void OnClickStatus()
{
Debug.Log($"---- [DEMO] Report Stats IDs: UID:{UID} DeviceID:{DeviceID} FirebaseID:{FirebaseID} AdID:{AdID} AdjustID:{AdjustID}");
GuruAnalytics.Instance.SetUid(UID);
GuruAnalytics.Instance.SetDeviceId(DeviceID);
GuruAnalytics.Instance.SetFirebaseId(FirebaseID);
GuruAnalytics.Instance.SetAdId(AdID);
GuruAnalytics.Instance.SetAdjustId(AdjustID);
}
private void OnClickUserProperties()
{
string item_category = "main";
int level = 7;
Debug.Log($"---- [DEMO] Call SetUserProperty: item_category:{item_category} level:{level}");
GuruAnalytics.Instance.SetUserProperty("item_category", item_category);
GuruAnalytics.Instance.SetUserProperty("level", level.ToString());
}
private void OnClickEvents()
{
Debug.Log($"---- [DEMO] Report Screen: {ScreenName}");
GuruAnalytics.Instance.SetScreen(ScreenName);
string eventName = "user_get_coin";
Dictionary<string, dynamic> data = new Dictionary<string, dynamic>()
{
{ "level", 7 },
{ "user_coin", 105L },
{ "win_rate", 21.25f },
{ "b_level", 7 },
{ "result", "retry" }
};
string s = "---- Data ----\n";
foreach (var k in data.Keys)
{
s += $"-- K:{k} V:{data[k]}\n";
}
Debug.Log(s);
Debug.Log($"---- [DEMO] Call LogEvent");
GuruAnalytics.Instance.LogEvent(eventName, data);
}
private void OnClickEvents2()
{
string eventName = "user_data_loaded";
GuruAnalytics.Instance.LogEvent(eventName);
}
private void OnClickReport()
{
GuruAnalytics.Instance.ReportEventSuccessRate();
}
private void OnClickTestCrash()
{
#if UNITY_IOS
Debug.Log($"--> OnClickTestCrash");
GuruAnalytics.TestCrash();
#endif
}
#endregion
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 8fde2a18f7d347408a6b869ee03e7de9
timeCreated: 1672712830

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: ea095a004daab4fc096aa297c21fca99
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,6 +6,7 @@ namespace Guru
fail,
timeout,
exit,
replay
}
//打点常量定义

View File

@ -25,47 +25,46 @@ namespace Guru
private const string VALUE_ONLY_FOR_IOS = "idfa_only_for_ios";
public static bool IsDebug { get; set; } = false;
private static bool _isGuruAnalyticInitOnce = false;
/// <summary>
/// 初始化Guru自打点系统 (请优先于 Firebase 初始化调用)
/// </summary>
public static void InstallGuruAnalytics(bool isDebug = false, bool enableErrorLog = false)
public static void InitGuruAnalyticService(GuruAnalyticsInitConfig initConfig, string firebaseId)
{
if (_isGuruAnalyticInitOnce) return;
try
{
Debug.Log($"{TAG} --- InstallGuruAnalytics baseUrl: {initConfig.baseUrl} enableErrorLog: {initConfig.enableErrorLog} firebaseId:{firebaseId}");
try
{
#if UNITY_EDITOR
IsDebug = true;
IsDebug = true;
#else
IsDebug = isDebug;
#endif
string appId = IPMConfig.IPM_X_APP_ID;
string deviceInfo = new DeviceInfoData().ToString();
GuruAnalytics.Init(appId, deviceInfo, OnGuruAnalyticsInitComplete, IsDebug, enableErrorLog); // 初始化(带Header)
string appId = IPMConfig.IPM_X_APP_ID;
string deviceInfo = new DeviceInfoData().ToString();
_hasGotFirebaseId = false;
_hasGotAdId = false;
_hasGotAdjustId = false;
_hasGotDeviceId = false;
_hasGotUid = false;
_lastReportRateDate = DateTime.Now;
_reportSuccessInterval = 120; // 2分钟上报一次
_hasGotFirebaseId = false;
_hasGotAdId = false;
_hasGotAdjustId = false;
_hasGotDeviceId = false;
_hasGotUid = false;
_lastReportRateDate = DateTime.Now;
_reportSuccessInterval = 120; // 2分钟上报一次
UpdateAllValues();
if(!string.IsNullOrEmpty(firebaseId))
GuruAnalytics.Instance.SetFirebaseId(firebaseId); // 在自打点初始化之前, 需要调用一下设置 FirebaseId
_isGuruAnalyticInitOnce = true;
}
catch (Exception ex)
{
LogCrashlytics(ex);
}
GuruAnalytics.Init(appId, deviceInfo, initConfig); // Android 初始化
UpdateAllValues();
}
catch (Exception ex)
{
LogCrashlytics(ex);
}
}
#region 各ID上报信息
#region 各ID上报信息
/// <summary>
/// 设置用户ID
@ -250,6 +249,8 @@ namespace Guru
/// </summary>
private static void UpdateAllValues()
{
Debug.Log($"{TAG} --- UpdateAllValues");
SetUid();
SetDeviceId();
SetAdjustId();
@ -297,9 +298,16 @@ namespace Guru
GuruAnalytics.Instance.SetUserProperty(key, value);
UpdateAllValues(); // 同步所有的ID
}
catch (Exception e)
catch (Exception ex)
{
Crashlytics.LogException(e);
if (IsFirebaseReady)
{
Crashlytics.LogException(ex);
}
else
{
Debug.LogException(ex);
}
}
}
@ -319,7 +327,14 @@ namespace Guru
}
catch (Exception e)
{
Crashlytics.LogException(e);
if (IsFirebaseReady)
{
Crashlytics.LogException(e);
}
else
{
Debug.LogWarning(e);
}
}
}
@ -343,7 +358,14 @@ namespace Guru
}
catch (Exception e)
{
Crashlytics.LogException(e);
if (IsFirebaseReady)
{
Crashlytics.LogException(e);
}
else
{
Debug.LogWarning(e);
}
}
}

View File

@ -1,6 +1,7 @@
using System.Threading;
using System.Collections;
using UnityEngine;
namespace Guru
{
@ -39,7 +40,6 @@ namespace Guru
};
}
}
private static EventSetting DefaultEventSetting => EventSetting.GetDefaultSetting();
private static bool _isInitOnce; //Analytics是否初始化完成
@ -48,26 +48,6 @@ namespace Guru
public static bool IsDebugMode => PlatformUtil.IsDebug();
private static bool IsFirebaseReady => FirebaseUtil.IsFirebaseInitialized;
private static bool IsReady
{
get
{
//Analytics没有初始化不上报打点
if (!_isInitOnce) return false;
//Firebase服务没有初始化完成不上报打点
if (!IsFirebaseReady) return false;
#if !UNITY_EDITOR
//开发环境打点不上报
if (IsDebugMode && !EnableDebugAnalytics)
return false;
#endif
return true;
}
}
private static AdjustEventDriver _adjustEventDriver;
private static FBEventDriver _fbEventDriver;
private static FirebaseEventDriver _firebaseEventDriver;
@ -76,7 +56,15 @@ namespace Guru
#region 初始化
public static void InitAnalytics()
/// <summary>
/// 初始化打点模块
/// </summary>
/// <param name="baseUrl"></param>
/// <param name="uploadIpAddress"></param>
/// <param name="isEnable"></param>
/// <param name="enableErrorLog"></param>
/// <param name="firebaseId"></param>
public static void Init(string baseUrl = "", string[] uploadIpAddress = null, bool isEnable = false, bool enableErrorLog = false, string firebaseId = "")
{
if (_isInitOnce) return;
_isInitOnce = true;
@ -85,21 +73,21 @@ namespace Guru
_fbEventDriver = new FBEventDriver();
_firebaseEventDriver = new FirebaseEventDriver();
_guruEventDriver = new GuruEventDriver();
// ------- 初始化自打点 ----------
InstallGuruAnalytics(IsDebug);
}
/// <summary>
/// 外部拉起 Firebase 初始化完成回调
/// </summary>
public static void OnFirebaseInitCompleted()
{
Debug.Log($"[SDK] --- Analytics Init After FirebaseReady:{IsFirebaseReady}");
// -------- 初始化 Crashlytics ----------
// --- 初始化 Crashlytics ---
CrashlyticsAgent.Init();
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
FirebaseAnalytics.SetSessionTimeoutDuration(new TimeSpan(0, 30, 0));
// --- 上报用户事件 ---
SetUserProperty(FirebaseAnalytics.UserPropertySignUpMethod, "Google");
SetUserProperty(PropertyDeviceID, IPMConfig.IPM_DEVICE_ID);
// SetUserProperty(PropertyFirstOpenTime, FirstOpenTime);
@ -118,7 +106,7 @@ namespace Guru
_adjustEventDriver.TriggerFlush();
}
private static void OnGuruAnalyticsInitComplete()
public static void OnGuruAnalyticsInitComplete()
{
_guruEventDriver.TriggerFlush();
}
@ -152,13 +140,13 @@ namespace Guru
/// <summary>
/// Firebase上报用户ID
/// </summary>
/// <param name="userID">通过Auth认证地用户ID</param>
public static void SetUserIDProperty(string userID)
/// <param name="uid">通过Auth认证地用户ID</param>
public static void SetFirebaseUserId(string uid)
{
Log.I(TAG,$"SetUserIDProperty -> userID:{userID}");
if (!IsReady) return;
FirebaseAnalytics.SetUserId(userID);
if (!IsFirebaseReady) return;
Log.I(TAG,$"SetUserIDProperty -> userID:{uid}");
FirebaseAnalytics.SetUserId(uid);
Crashlytics.SetUserId(uid);
}
/// <summary>
@ -168,7 +156,7 @@ namespace Guru
{
if (!_isInitOnce)
{
throw new Exception($"[{TAG}][SDK] Analytics did not initialized, Call <Analytics.{nameof(InitAnalytics)}()> first!");
throw new Exception($"[{TAG}][SDK] Analytics did not initialized, Call <Analytics.{nameof(Init)}()> first!");
}
if (IsDebug && !EnableDebugAnalytics)
@ -200,6 +188,25 @@ namespace Guru
}
/// <summary>
/// Firebase 上报用户属性
/// </summary>
/// <param name="propertyName"></param>
/// <param name="propertyValue"></param>
private static void FirebaseSetUserProperty(string propertyName, string propertyValue)
{
if (IsFirebaseReady)
{
FirebaseAnalytics.SetUserProperty(propertyName, propertyValue);
}
else
{
Debug.Log($"{TAG} --- Firebase not ready, call Firebase Init first!");
}
}
#endregion
#region 打点上报
@ -217,7 +224,7 @@ namespace Guru
{
if (!_isInitOnce)
{
throw new Exception($"[{TAG}][SDK] Analytics did not initialized, Call <Analytics.{nameof(InitAnalytics)}()> first!");
throw new Exception($"[{TAG}][SDK] Analytics did not initialized, Call <Analytics.{nameof(Init)}()> first!");
}
if (IsDebug && !EnableDebugAnalytics)

View File

@ -27,7 +27,7 @@ namespace Guru
return ((MonoBehaviour)this).StartDelayed(delay, callback);
}
public Coroutine StartDelayed(int framesOfDelay, Action callback)
public Coroutine StartDelayedWithFrame(int framesOfDelay, Action callback)
{
return ((MonoBehaviour)this).StartDelayed(framesOfDelay, callback);
}

View File

@ -1,33 +1,55 @@
using Firebase.Auth;
using Firebase.Extensions;
using UnityEngine;
namespace Guru
{
using System;
using Firebase.Auth;
using Firebase.Extensions;
using UnityEngine;
public static partial class FirebaseUtil
{
public static FirebaseUser CurrentUser => FirebaseAuth.DefaultInstance.CurrentUser;
private static FirebaseUser FirebaseUser => FirebaseAuth.DefaultInstance.CurrentUser;
private static readonly WaitForSeconds _wait = new WaitForSeconds(10);
private const float LOGIN_RETRY_MAX_TIME = 60; // 最大请求间隔时间
private const float LOGIN_RETRY_INTERVAL = 10; // 最大请求间隔时间
public static void AuthUser(Action onSuccessHandler = null)
private static float _retryDelayTime = 10; // 登录重试时间
/// <summary>
/// 登录 Firebase 用户
/// </summary>
/// <param name="authToken"></param>
/// <param name="onLoginResult"></param>
/// <param name="autoRetry"></param>
private static void LoginFirebaseWithToken(Action<bool> onLoginResult = null, string authToken = "", bool autoRetry = true)
{
//FirebaseAuth获取用户验证并同步用户数据
if (CurrentUser != null)
// #1 Firebase 已获取用户
if (FirebaseUser != null)
{
Log.I(LOG_TAG, $"[Auth] user existsUserId:{CurrentUser.UserId}");
OnFirebaseAuthResult?.Invoke(true);
onSuccessHandler?.Invoke();
Log.I(LOG_TAG, $"[Auth] user existsUserId:{FirebaseUser.UserId}");
onLoginResult?.Invoke(true);
return;
}
string authToken = IPMConfig.IPM_FIREBASE_TOKEN;
if (string.IsNullOrEmpty(authToken)) authToken = IPMConfig.IPM_FIREBASE_TOKEN;
Log.I(LOG_TAG, $"[Auth] Firebase Token:{authToken}");
if (string.IsNullOrEmpty(authToken) || !NetworkUtil.IsNetAvaliable)
{
CoroutineHelper.Instance.StartDelayed(_wait, ()=> AuthUser(onSuccessHandler));
OnFirebaseAuthResult?.Invoke(false);
// Token 为空 或 网络不可用
if (autoRetry)
{
// 继续重试
DelayCallFirebaseLogin(Mathf.Min(_retryDelayTime, LOGIN_RETRY_MAX_TIME), onLoginResult, authToken);
_retryDelayTime += LOGIN_RETRY_INTERVAL; // 最大重试间隔 60s
}
else
{
// 不再重试
onLoginResult?.Invoke(false);
}
return;
}
@ -38,21 +60,34 @@ namespace Guru
if (task.IsCanceled || task.IsFaulted)
{
Log.E(LOG_TAG,"[Auth] SignInWithCustomTokenAsync encountered an error: " + task.Exception);
OnFirebaseAuthResult?.Invoke(false);
CoroutineHelper.Instance.StartDelayed(_wait, () => AuthUser(onSuccessHandler));
if (autoRetry)
{
DelayCallFirebaseLogin(_retryDelayTime, onLoginResult, authToken); // 自动重试
}
else
{
onLoginResult?.Invoke(false); // 不再重试
}
return;
}
// ----- User is NULL -----
if (CurrentUser == null)
{
OnFirebaseAuthResult?.Invoke(false);
CoroutineHelper.Instance.StartDelayed(_wait, ()=> AuthUser(onSuccessHandler));
return;
}
// ----- Success -----
OnFirebaseAuthResult?.Invoke(true); // 最后判定是成功的
onSuccessHandler?.Invoke();
// ----- Check Result -----
bool success = FirebaseUser != null;
onLoginResult?.Invoke(success);
_retryDelayTime = LOGIN_RETRY_INTERVAL;
});
}
/// <summary>
/// 延迟调用 Firebase 登录请求
/// </summary>
/// <param name="delaySeconds"></param>
/// <param name="callback"></param>
/// <param name="token"></param>
private static void DelayCallFirebaseLogin(float delaySeconds, Action<bool> callback, string token = "")
{
var delay = new WaitForSeconds(delaySeconds);
CoroutineHelper.Instance.StartDelayed(delay, ()=> LoginFirebaseWithToken(callback, token));
}
}
}

View File

@ -5,6 +5,8 @@ namespace Guru
{
public static partial class FirebaseUtil
{
public static void InitCrashlytics()
{
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID))
@ -17,6 +19,7 @@ namespace Guru
/// </summary>
public static void SetUserID(string userID)
{
if (!IsFirebaseInitialized) return;
Crashlytics.SetUserId(userID);
}
@ -26,6 +29,7 @@ namespace Guru
/// </summary>
public static void SetCustomData(string key, string value)
{
if (!IsFirebaseInitialized) return;
Crashlytics.SetCustomKey(key, value);
}
@ -34,6 +38,7 @@ namespace Guru
/// </summary>
public static void LogMessage(string message)
{
if (!IsFirebaseInitialized) return;
Crashlytics.Log(message);
}
@ -42,6 +47,7 @@ namespace Guru
/// </summary>
public static void LogException(Exception exception)
{
if (!IsFirebaseInitialized) return;
Crashlytics.LogException(exception);
}
}

View File

@ -1,10 +1,12 @@
using System;
using System.Collections;
using Firebase.Messaging;
using UnityEngine;
namespace Guru
{
using System;
using System.Collections;
using Firebase.Messaging;
using UnityEngine;
public static partial class FirebaseUtil
{
private static int _messageRetry = 5;
@ -17,7 +19,7 @@ namespace Guru
_isAutoFetchFcmToken = value;
}
public static void InitializeMessage()
private static void InitializeMessage()
{
if (_isAutoFetchFcmToken)
{
@ -48,7 +50,7 @@ namespace Guru
if (task.IsFaulted || task.IsCanceled)
{
CoroutineHelper.Instance.StartDelayed(_wait, GetFCMToken);
CoroutineHelper.Instance.StartDelayed(10, GetFCMToken);
}
else
{
@ -84,14 +86,14 @@ namespace Guru
}
}
private static void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token)
private static void OnTokenReceived(object sender, TokenReceivedEventArgs token)
{
#if UNITY_IOS
DeviceUtil.SetiOSBadge();
#endif
}
public static void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e)
public static void OnMessageReceived(object sender, MessageReceivedEventArgs e)
{
#if UNITY_IOS
DeviceUtil.SetiOSBadge();

View File

@ -96,7 +96,7 @@ namespace Guru
|| _remoteConfigInstance.Info.LastFetchStatus != LastFetchStatus.Success)
{
Log.E(LOG_TAG, "Firebase RemoteConfig Fetch Failure");
CoroutineHelper.Instance.StartDelayed(_wait, FetchRemoteValue);
CoroutineHelper.Instance.StartDelayed(10, FetchRemoteValue);
return;
}

View File

@ -1,160 +1,214 @@
using System;
using Firebase;
using Firebase.Analytics;
using Firebase.Extensions;
using UnityEngine;
namespace Guru
{
using System;
using Firebase;
using Firebase.Analytics;
using Firebase.Extensions;
using UnityEngine;
public static partial class FirebaseUtil
{
private static readonly string LOG_TAG = "Firebase";
private static bool _isReady = false;
public static bool IsReady => _isReady;
public static bool IsReady => _isReady && IsFirebaseInitialized;
public static DependencyStatus DependencyStatus = DependencyStatus.UnavailableOther;
private static DependencyStatus DependencyStatus = DependencyStatus.UnavailableOther;
public static bool IsFirebaseInitialized => DependencyStatus == DependencyStatus.Available;
public static Action<bool> onInitComplete;
public static Action<bool> OnFirebaseAuthResult;
public static Action<bool> OnUserAuthResult;
// TODO: 需要从 FirebaseUtils 内拿走
public static Action<string> OnAdjustDeeplinkCallback = null;
private static Action<bool> _onCheckAndFixDepsHandler;
private static Action<string> _onGetFirebaseIdHandler;
private static Action<bool> _onGetGuruUIDHandler;
private static Action<bool> _onFirebaseLoginResult;
public static void InitFirebase(Action callback)
/// <summary>
/// 初始化 Firebase
/// </summary>
/// <param name="onDepsCheckResult">Firebase 自身解决依赖结果回调</param>
/// <param name="onGetFirebaseId">异步获取到 FirebaseId 回调</param>
/// <param name="onGetGuruUIDResult">Firebase 授权回调</param>
/// <param name="onFirebaseLoginResult"></param>
public static void Init(Action<bool> onDepsCheckResult, Action<string> onGetFirebaseId = null,
Action<bool> onGetGuruUIDResult = null, Action<bool> onFirebaseLoginResult = null)
{
_isReady = false;
// Analytics.InitAnalytics(); // 打点提前初始化
_onCheckAndFixDepsHandler = onDepsCheckResult;
_onGetFirebaseIdHandler = onGetFirebaseId;
_onGetGuruUIDHandler = onGetGuruUIDResult;
_onFirebaseLoginResult = onFirebaseLoginResult;
// Loom.StartUp(); // 确保主线程开启
// 初始化 Fireabse 依赖
// 初始化 Firebase 依赖
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
DependencyStatus = task.Result;
if (DependencyStatus == DependencyStatus.Available)
{
_isReady = true;
InitializeFirebaseComp();
callback?.Invoke();
OnFirebaseDepsCheckSuccess(); // Deps 处理通过
}
else
{
Log.E(LOG_TAG, "Could not resolve all Firebase dependencies: " + DependencyStatus);
}
onInitComplete?.Invoke(_isReady);
_onCheckAndFixDepsHandler?.Invoke(_isReady);
});
}
private static void InitializeFirebaseComp()
/// <summary>
/// Deps 处理通过
/// 初始化各模块
/// </summary>
private static void OnFirebaseDepsCheckSuccess()
{
InitCrashlytics(); // 老项目沿用此逻辑
InitRemoteConfig(); // 老项目沿用此逻辑
// TODO: 需要从 FirebaseUtils 内拿走
InitAdjustService(); // 初始化 adjust 服务
InitializeMessage(); // 初始化 Messaging 服务
GetFirebaseIdAsync(); // 开始获取 FirebaseId
if (IPMConfig.IPM_UID.IsNullOrEmpty())
{
Log.I(LOG_TAG, "没有存储UID时从中台获取匿名认证授权");
//没有存储UID时从中台获取匿名认证授权
new AuthUserRequest()
.SetRetryTimes(-1)
.SetSuccessCallBack(() =>
{
OnUserAuthResult?.Invoke(true);
AuthUser(InitializeMessage);
}).SetFailCallBack(() =>
{
OnUserAuthResult?.Invoke(false);
})
.Send();
}
else
{
InitializeMessage();
int currentTimeStamp = TimeUtil.GetCurrentTimeStampSecond();
if(currentTimeStamp - IPMConfig.IPM_TOKEN_TIME >= IPMConfig.TOKEN_VALID_TIME)
{
//中台Token失效从中台重新获取Token
new RefreshTokenRequest().SetRetryTimes(-1).Send();
}
if(currentTimeStamp - IPMConfig.IPM_FIREBASE_TOKEN_TIME >= IPMConfig.FIREBASE_TOKEN_VALID_TIME)
{
//中台firebaseToken失效从中台重新获取firebaseToken
new RefreshFirebaseTokenRequest()
.SetRetryTimes(-1)
.SetSuccessCallBack(()=> AuthUser(InitializeMessage))
.Send();
}
else
{
AuthUser(InitializeMessage);
}
}
StartVerifyTokenAndAuthAsync(); //开始验证授权和Token
}
#region 启动 Adjust 服务
#region FirebaseId
// TODO: 需要从 FirebaseUtils 内拿走
/// <summary>
/// 启动 Adjust 服务
/// </summary>
private static void InitAdjustService()
private static void GetFirebaseIdAsync()
{
// 异步获取 FirebaseID
FirebaseAnalytics.GetAnalyticsInstanceIdAsync()
.ContinueWithOnMainThread(task =>
{
if (task.IsCompleted && !string.IsNullOrEmpty(task.Result))
string fid = task.Result;
if (task.IsCompleted && !string.IsNullOrEmpty(fid))
{
// 保存本地ID备份
string fid = task.Result;
IPMConfig.FIREBASE_ID = fid; // 保存FirebaseID
Debug.Log($"[SDK] --- Get FirebaseID: {fid}");
}
else
{
UnityEngine.Debug.LogError($"Fetch FirebaseID failed on start!");
Debug.LogError($"[SDK] --- Fetch FirebaseID failed on start!");
}
// 启动 AdjustService
string appToken = GuruSettings.Instance.AdjustSetting?.GetAppToken() ?? "";
string fbAppId = GuruSettings.Instance.IPMSetting.FacebookAppId;
if (!string.IsNullOrEmpty(IPMConfig.ADJUST_ID))
ReportAdjustId(IPMConfig.ADJUST_ID); // 二次启动后,若有值则立即上报属性
AdjustService.StartService(appToken, fbAppId, OnGetAdjustId, OnAdjustDeeplinkCallback);
_onGetFirebaseIdHandler?.Invoke(fid);
});
}
private static void OnGetAdjustId(string adjustId)
#endregion
#region Token and Auth
/// <summary>
/// 异步验证所有 Token 有效期
/// </summary>
private static void StartVerifyTokenAndAuthAsync()
{
// 获取 ADID
if (string.IsNullOrEmpty(adjustId))
if (string.IsNullOrEmpty(IPMConfig.IPM_UID))
{
adjustId = "not_set";
Log.I(LOG_TAG, "没有存储UID时从中台获取匿名认证授权");
// 没有存储UID时从中台获取匿名认证授权
StartGuruLoginWithDeviceId(success =>
{
_onGetGuruUIDHandler?.Invoke(success);
if (success) {
// 用户 UID 不为空
StartLoginWithFirebase();
}
});
}
else
{
IPMConfig.ADJUST_ID = adjustId;
// 检查中台 Token 是否过期
if (IsGuruTokenExpired())
{
RefreshGuruToken();
}
// 检查中台 Firebase Token 是否过期
if (IsFirebaseTokenExpired())
{
RefreshFirebaseToken(StartLoginWithFirebase); // 重新获取 Firebase Token
}
else
{
StartLoginWithFirebase();
}
}
ReportAdjustId(adjustId);
Analytics.OnAdjustInitComplete();
}
private static void ReportAdjustId(string adjustId)
/// <summary>
/// 使用设备 ID 进行中台匿名认证
/// </summary>
private static void StartGuruLoginWithDeviceId(Action<bool> onLoginResult = null)
{
FirebaseAnalytics.SetUserProperty("adjust_id", adjustId); // 仅上报 Firebase 用户属性
Debug.Log($"[SDK] --- Firebase + Adjust ID: {adjustId}");
// 没有存储UID时从中台获取匿名认证授权
var request = new AuthUserRequest()
.SetRetryTimes(-1) // 不成功的话会一直请求
.SetSuccessCallBack(() =>
{
onLoginResult?.Invoke(true);
}).SetFailCallBack(() =>
{
onLoginResult?.Invoke(false);
});
request.Send();
}
/// <summary>
/// Firebase Token 是否过期
/// </summary>
/// <returns></returns>
private static bool IsFirebaseTokenExpired()
{
int currentTimeStamp = TimeUtil.GetCurrentTimeStampSecond();
return currentTimeStamp - IPMConfig.IPM_TOKEN_TIME >= IPMConfig.TOKEN_VALID_TIME;
}
private static void RefreshFirebaseToken(Action onFirebaseTokenRefreshed = null)
{
//中台firebaseToken失效从中台重新获取firebaseToken
var request = new RefreshFirebaseTokenRequest()
.SetRetryTimes(-1)
.SetSuccessCallBack(()=> onFirebaseTokenRefreshed?.Invoke());
request.Send();
}
/// <summary>
/// Guru Token 是否过期
/// </summary>
/// <returns></returns>
private static bool IsGuruTokenExpired()
{
int currentTimeStamp = TimeUtil.GetCurrentTimeStampSecond();
return currentTimeStamp - IPMConfig.IPM_FIREBASE_TOKEN_TIME >= IPMConfig.FIREBASE_TOKEN_VALID_TIME;
}
private static void RefreshGuruToken()
{
//中台Token失效从中台重新获取Token
var request = new RefreshTokenRequest()
.SetRetryWaitSeconds(10)
.SetRetryTimes(-1); // 不成功的话会一直请求
request.Send();
}
#endregion
#region Firebase 用户登录
/// <summary>
/// 开始登录 Firebase
/// </summary>
private static void StartLoginWithFirebase()
{
LoginFirebaseWithToken(OnFirebaseLoginComplete, IPMConfig.IPM_FIREBASE_TOKEN); // 成功后进行 Firebase 认证
}
/// <summary>
/// Firebase 认证用户完成
/// </summary>
/// <param name="success"></param>
private static void OnFirebaseLoginComplete(bool success)
{
_onFirebaseLoginResult?.Invoke(success);
}
#endregion
}
}

View File

@ -44,8 +44,7 @@ namespace Guru
this.Log(response);
this.Log(responseData.data.ToString());
Analytics.SetUserIDProperty(responseData.data.uid);
Crashlytics.SetUserId(responseData.data.uid);
Analytics.SetFirebaseUserId(responseData.data.uid);
IPMConfig.IPM_UID = responseData.data.uid;
IPMConfig.IPM_UID_INT = responseData.data.uidInt;

View File

@ -29,8 +29,7 @@ namespace Guru
this.Log(responseData.data.ToString());
IPMConfig.IPM_TOKEN = responseData.data.token;
IPMConfig.IPM_TOKEN_TIME = TimeUtil.GetCurrentTimeStampSecond();
PlayerPrefs.SetString("IPM_TOKEN", responseData.data.token);
this.Log("@@@ Send OK!");
this.Log($"[SDK] --- RefreshTokenRequest Success: {responseData.data.token}");
}
}
}

View File

@ -13,7 +13,7 @@ namespace Guru
protected abstract UnityWebRequest CreateRequest();
protected abstract void RequestSuccessCallBack(string response);
private readonly WaitForSeconds _waitTime = new WaitForSeconds(5);
private WaitForSeconds _waitTime = new WaitForSeconds(5);
private int _retryTimes = 3;
private int _timeOut = 90;
@ -28,6 +28,12 @@ namespace Guru
return this;
}
public RequestBase SetRetryWaitSeconds(int waitSeconds)
{
_waitTime = new WaitForSeconds(waitSeconds);;
return this;
}
public RequestBase SetTimeOut(int timeOut)
{
_timeOut = timeOut;