update: 更新 Adjust 订阅上报接口

feature/Inventory
胡宇飞 2024-01-23 17:16:18 +08:00
parent 6a59816453
commit 29478301a4
7 changed files with 55 additions and 18 deletions

View File

@ -10,10 +10,14 @@ namespace Guru
public static class AdjustService public static class AdjustService
{ {
public const string Version = "1.5.0"; public const string Version = "1.6.0";
public static readonly string LOG_TAG = "Adjust"; public static readonly string LOG_TAG = "Adjust";
public static readonly float DelayTime = 1f; // 延迟启动时间 public static readonly float DelayTime = 1f; // 延迟启动时间
public const string K_IAP_PURCHASE = "iap_purchase"; // 固定点位事件
public const string K_SUB_PURCHASE = "sub_purchase"; // 固定点位事件
private static string _adId = ""; private static string _adId = "";
public static string AdId public static string AdId
{ {
@ -322,18 +326,32 @@ namespace Guru
/// <param name="productID"></param> /// <param name="productID"></param>
public static void TrackIAPPurchase(double revenue, string productID) public static void TrackIAPPurchase(double revenue, string productID)
{ {
string tokenID = Analytics.GetAdjustEventToken("iap_purchase"); string tokenID = Analytics.GetAdjustEventToken(K_IAP_PURCHASE);
if (string.IsNullOrEmpty(tokenID)) if (string.IsNullOrEmpty(tokenID))
return; return;
#if UNITY_IOS
string platform = "appstore";
#else
string platform = "google_play";
#endif
AdjustEvent adjustEvent = new AdjustEvent(tokenID); AdjustEvent adjustEvent = new AdjustEvent(tokenID);
adjustEvent.setRevenue(revenue,"USD"); adjustEvent.setRevenue(revenue,"USD");
adjustEvent.AddEventParameter("platform", platform); adjustEvent.AddEventParameter("platform", Analytics.IAPPlatform);
adjustEvent.AddEventParameter("product_id", productID);
adjustEvent.AddEventParameter("value", $"{revenue}");
Adjust.trackEvent(adjustEvent);
}
/// <summary>
/// IAP订阅支付事件上报
/// </summary>
/// <param name="revenue"></param>
/// <param name="productID"></param>
public static void TrackSubPurchase(double revenue, string productID)
{
string tokenID = Analytics.GetAdjustEventToken(K_SUB_PURCHASE);
if (string.IsNullOrEmpty(tokenID))
return;
AdjustEvent adjustEvent = new AdjustEvent(tokenID);
adjustEvent.setRevenue(revenue,"USD");
adjustEvent.AddEventParameter("platform", Analytics.IAPPlatform);
adjustEvent.AddEventParameter("product_id", productID); adjustEvent.AddEventParameter("product_id", productID);
adjustEvent.AddEventParameter("value", $"{revenue}"); adjustEvent.AddEventParameter("value", $"{revenue}");
Adjust.trackEvent(adjustEvent); Adjust.trackEvent(adjustEvent);
@ -357,6 +375,9 @@ namespace Guru
} }
#endregion #endregion
#region 关键属性上报 #region 关键属性上报

View File

@ -57,6 +57,7 @@ namespace Guru
//内购成功事件上报 //内购成功事件上报
public static readonly string EventIAPPurchase = "iap_purchase"; public static readonly string EventIAPPurchase = "iap_purchase";
public static readonly string EventSubPurchase = "sub_purchase";
public static readonly string IAPStoreCategory = "Store"; public static readonly string IAPStoreCategory = "Store";
public static readonly string IAPTypeProduct = "product"; public static readonly string IAPTypeProduct = "product";
public static readonly string IAPTypeSubscription = "subscription"; public static readonly string IAPTypeSubscription = "subscription";

View File

@ -297,7 +297,16 @@ namespace Guru
private static double _tch02TargetValue = 0.20d; private static double _tch02TargetValue = 0.20d;
public static double Tch02TargetValue => _tch02TargetValue; // 太极 02 设定值 public static double Tch02TargetValue => _tch02TargetValue; // 太极 02 设定值
private static string IAPPlatform => Application.platform == RuntimePlatform.IPhonePlayer ? "appstore" : "google_play"; public static string IAPPlatform
{
get
{
#if UNITY_IOS
return "appstore";
#endif
return "google_play";
}
}
public static bool EnableTch02Event { get; set; } = false; // 是否使用太极02事件(请手动开启) public static bool EnableTch02Event { get; set; } = false; // 是否使用太极02事件(请手动开启)
/// <summary> /// <summary>
@ -562,12 +571,18 @@ namespace Guru
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <param name="productId"></param> /// <param name="productId"></param>
public static void IAPPurchase(float value, string productId) public static void IAPPurchase(double value, string productId)
{ {
IAPPurchaseReport(EventIAPPurchase, value, productId); IAPPurchaseReport(EventIAPPurchase, value, productId);
} }
private static void IAPPurchaseReport(string eventName, float value, string productId) public static void SubPurchase(double value, string productId)
{
IAPPurchaseReport(EventSubPurchase, value, productId);
}
private static void IAPPurchaseReport(string eventName, double value, string productId)
{ {
LogEvent(eventName, new Dictionary<string, dynamic>() LogEvent(eventName, new Dictionary<string, dynamic>()
{ {

View File

@ -11,9 +11,9 @@ namespace Guru
{ {
public class EventSetting public class EventSetting
{ {
public bool EnableFirebaseAnalytics; public bool EnableFirebaseAnalytics = false;
public bool EnableAdjustAnalytics; public bool EnableAdjustAnalytics = false;
public bool EnableFacebookAnalytics; public bool EnableFacebookAnalytics = false;
} }
private static EventSetting _defaultEventSetting; private static EventSetting _defaultEventSetting;

View File

@ -42,7 +42,7 @@ namespace Guru
if (responseData != null && responseData.data != null) if (responseData != null && responseData.data != null)
{ {
// Analytics.Tch001IAPRev(responseData.data.usdPrice); // Analytics.Tch001IAPRev(responseData.data.usdPrice);
float usdPrice = responseData.data.usdPrice; double usdPrice = responseData.data.usdPrice;
Analytics.Tch001IAPRev(usdPrice); Analytics.Tch001IAPRev(usdPrice);
Analytics.Tch02IAPRev(usdPrice); Analytics.Tch02IAPRev(usdPrice);
AdjustService.TrackIAPPurchase(usdPrice, productId); AdjustService.TrackIAPPurchase(usdPrice, productId);

View File

@ -48,7 +48,7 @@ namespace Guru
if (responseData != null && responseData.data != null) if (responseData != null && responseData.data != null)
{ {
// Analytics.Tch001IAPRev(responseData.data.usdPrice); // Analytics.Tch001IAPRev(responseData.data.usdPrice);
float usdPrice = responseData.data.usdPrice; double usdPrice = responseData.data.usdPrice;
Analytics.Tch001IAPRev(usdPrice); Analytics.Tch001IAPRev(usdPrice);
Analytics.Tch02IAPRev(usdPrice); Analytics.Tch02IAPRev(usdPrice);
AdjustService.TrackIAPPurchase(usdPrice, productId); AdjustService.TrackIAPPurchase(usdPrice, productId);

View File

@ -5,7 +5,7 @@ namespace Guru
[Serializable] [Serializable]
public class OrderResponse public class OrderResponse
{ {
public float usdPrice; public double usdPrice;
public override string ToString() public override string ToString()
{ {