update: 升级自打点版本和接口

deeplink
胡宇飞 2024-03-28 18:00:46 +08:00
parent a240dc4e2c
commit fac01f8109
10 changed files with 98 additions and 28 deletions

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 4438c644309264b1babdb7f1fd0431b6
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

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 979b8da6b92542e990e6038f43f1835d
timeCreated: 1710317078

View File

@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 93255faba714a477da458107e107b535
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

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 7d0a7721c57840829fad465c4c33e846
timeCreated: 1710317052

View File

@ -1,21 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace Guru namespace Guru
{ {
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
public class GuruAnalytics public class GuruAnalytics
{ {
// Plugin Version // Plugin Version
public const string Version = "1.9.0"; public const string Version = "1.10.1";
public static readonly string Tag = "[ANA]"; public static readonly string Tag = "[ANA]";
private static readonly string ActionName = "logger_error"; private static readonly string ActionName = "logger_error";
@ -93,6 +93,7 @@ namespace Guru
/// <param name="screenName"></param> /// <param name="screenName"></param>
public static void SetScreen(string screenName) public static void SetScreen(string screenName)
{ {
if (string.IsNullOrEmpty(screenName)) return;
CacheUserProperty($"screen_name", screenName); CacheUserProperty($"screen_name", screenName);
Agent?.SetScreen(screenName); Agent?.SetScreen(screenName);
} }
@ -103,6 +104,7 @@ namespace Guru
/// <param name="id"></param> /// <param name="id"></param>
public static void SetAdId(string id) public static void SetAdId(string id)
{ {
if (string.IsNullOrEmpty(id)) return;
CacheUserProperty($"ad_id", id); CacheUserProperty($"ad_id", id);
Agent?.SetAdId(id); Agent?.SetAdId(id);
} }
@ -114,6 +116,7 @@ namespace Guru
/// <param name="value"></param> /// <param name="value"></param>
public static void SetUserProperty(string key, string value) public static void SetUserProperty(string key, string value)
{ {
if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) return;
CacheUserProperty(key, value); // 添加用户属性 CacheUserProperty(key, value); // 添加用户属性
Agent?.SetUserProperty(key, value); Agent?.SetUserProperty(key, value);
} }
@ -123,6 +126,7 @@ namespace Guru
/// <param name="id"></param> /// <param name="id"></param>
public static void SetFirebaseId(string id) public static void SetFirebaseId(string id)
{ {
if (string.IsNullOrEmpty(id)) return;
CacheUserProperty($"firebase_id", id); CacheUserProperty($"firebase_id", id);
Agent?.SetFirebaseId(id); Agent?.SetFirebaseId(id);
} }
@ -133,6 +137,7 @@ namespace Guru
/// <param name="id"></param> /// <param name="id"></param>
public static void SetAdjustId(string id) public static void SetAdjustId(string id)
{ {
if (string.IsNullOrEmpty(id)) return;
CacheUserProperty($"adjust_id", id); CacheUserProperty($"adjust_id", id);
Agent?.SetAdjustId(id); Agent?.SetAdjustId(id);
} }
@ -143,6 +148,7 @@ namespace Guru
/// <param name="deviceId"></param> /// <param name="deviceId"></param>
public static void SetDeviceId(string deviceId) public static void SetDeviceId(string deviceId)
{ {
if (string.IsNullOrEmpty(deviceId)) return;
CacheUserProperty($"device_id", deviceId); CacheUserProperty($"device_id", deviceId);
Agent?.SetDeviceId(deviceId); Agent?.SetDeviceId(deviceId);
} }
@ -150,18 +156,15 @@ namespace Guru
public static void SetAndroidID(string androidId) public static void SetAndroidID(string androidId)
{ {
if (string.IsNullOrEmpty(androidId)) return;
CacheUserProperty(Analytics.PropertyAndroidID, androidId); CacheUserProperty(Analytics.PropertyAndroidID, androidId);
} }
public static void SetIDFV(string idfv) public static void SetIDFV(string idfv)
{ {
if (string.IsNullOrEmpty(idfv)) return;
CacheUserProperty(Analytics.PropertyIDFV, idfv); CacheUserProperty(Analytics.PropertyIDFV, idfv);
} }
public static void SetIDFA(string idfa)
{
CacheUserProperty(Analytics.PropertyIDFA, idfa);
}
/// <summary> /// <summary>
@ -170,6 +173,7 @@ namespace Guru
/// <param name="uid"></param> /// <param name="uid"></param>
public static void SetUid(string uid) public static void SetUid(string uid)
{ {
if (string.IsNullOrEmpty(uid)) return;
CacheUserProperty($"uid", uid); CacheUserProperty($"uid", uid);
Agent?.SetUid(uid); Agent?.SetUid(uid);
} }
@ -375,7 +379,11 @@ namespace Guru
{ {
Analytics.LogCrashlytics($"{Tag} --- Json:{msg} Ex:{ex}"); Analytics.LogCrashlytics($"{Tag} --- Json:{msg} Ex:{ex}");
} }
}
string sap = "msg\":";
OnLoggerErrorEvent((int)AnalyticsCode.Unknown,
msg.Substring(msg.IndexOf(sap, StringComparison.Ordinal) + sap.Length));
}
/// <summary> /// <summary>
/// 上报错误信息 /// 上报错误信息

View File

@ -1,8 +1,10 @@
using System;
using UnityEngine;
namespace Guru namespace Guru
{ {
using System;
using UnityEngine;
public class AnalyticsAgentAndroid: IAnalyticsAgent public class AnalyticsAgentAndroid: IAnalyticsAgent
{ {
@ -15,6 +17,8 @@ namespace Guru
#endif #endif
private static bool _isDebug = false; private static bool _isDebug = false;
public static bool UseWorker = true; public static bool UseWorker = true;
public static bool UseCronet = false;
public static string BaseUrl = "";
#region 工具方法 #region 工具方法
@ -71,13 +75,14 @@ namespace Guru
#endregion #endregion
#region 接口实现 #region 接口实现
public void Init(string appId, string deviceInfo, bool isDebug = false) public void Init(string appId, string deviceInfo, bool isDebug = false)
{ {
_isDebug = isDebug; _isDebug = isDebug;
string bundleId = Application.identifier; string bundleId = Application.identifier;
CallStatic("init", appId, deviceInfo, bundleId, UseWorker, isDebug); // 调用接口 CallStatic("init", appId, deviceInfo, bundleId, UseWorker, isDebug, UseCronet, BaseUrl); // 调用接口
} }
public void SetScreen(string screenName) public void SetScreen(string screenName)
{ {
if (string.IsNullOrEmpty(screenName)) return; if (string.IsNullOrEmpty(screenName)) return;
@ -94,7 +99,6 @@ namespace Guru
if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) return; if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) return;
CallStatic("setUserProperty", key, value); CallStatic("setUserProperty", key, value);
} }
public void SetFirebaseId(string id) public void SetFirebaseId(string id)
{ {
if (string.IsNullOrEmpty(id)) return; if (string.IsNullOrEmpty(id)) return;