Merge branch 'hotfix/1.0.13' into dev

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

# Conflicts:
#	Runtime/GuruCore/Runtime/Analytics/Analytics.TemplateDefine.cs
main
胡宇飞 2024-07-01 14:25:18 +08:00
commit 2a895b370e
3 changed files with 98 additions and 27 deletions

View File

@ -1,5 +1,4 @@
using System.Data.Odbc;
using JetBrains.Annotations;
namespace Guru
{
@ -296,10 +295,10 @@ namespace Guru
/// <param name="orderId"></param>
/// <param name="orderType"></param>
/// <param name="timestamp"></param>
/// <param name="isSandbox"></param>
public static void Tch001IAPRev(double value, string productId, string orderId, string orderType, string timestamp, bool isSandbox = false)
/// <param name="isTest"></param>
public static void Tch001IAPRev(double value, string productId, string orderId, string orderType, string timestamp, bool isTest = false)
{
TchRevEvent(EventTchAdRev001Impression, IAPPlatform, value, orderType, productId, orderId, timestamp, isSandbox? "true" : "false");
TchRevEvent(EventTchAdRev001Impression, IAPPlatform, value, orderType, productId, orderId, timestamp, isTest);
}
/// <summary>
@ -313,10 +312,10 @@ namespace Guru
/// <param name="timestamp"></param>
/// <param name="isSandbox"></param>
// public static void Tch02IAPRev(double value, string productId, string orderId, string orderType, string timestamp)
public static void Tch02IAPRev(double value, string productId, string orderId, string orderType, string timestamp, bool isSandbox = false)
public static void Tch02IAPRev(double value, string productId, string orderId, string orderType, string timestamp, bool isTest = false)
{
if (!EnableTch02Event) return;
TchRevEvent(EventTchAdRev02Impression, IAPPlatform, value, orderType, productId, orderId, timestamp, isSandbox? "true" : "false");
TchRevEvent(EventTchAdRev02Impression, IAPPlatform, value, orderType, productId, orderId, timestamp, isTest);
}
/// <summary>
@ -365,9 +364,9 @@ namespace Guru
/// <param name="productId"></param>
/// <param name="orderId"></param>
/// <param name="timestamp"></param>
/// <param name="sandbox"></param>
/// <param name="isTest"></param>
private static void TchRevEvent(string evtName, string platform, double value,
string orderType = "", string productId = "", string orderId = "", string timestamp = "", string sandbox = "")
string orderType = "", string productId = "", string orderId = "", string timestamp = "", bool isTest = false)
{
var data = new Dictionary<string, dynamic>()
{
@ -376,7 +375,10 @@ namespace Guru
{ ParameterCurrency, USD },
};
string sandbox = isTest ? "true" : "false";
//--------- Extra data for IAP receipt ---------------
if(!string.IsNullOrEmpty(orderType)) data["order_type"] = orderType;
if(!string.IsNullOrEmpty(productId)) data["product_id"] = productId;
if(!string.IsNullOrEmpty(orderId)) data["order_id"] = orderId;
@ -631,22 +633,38 @@ namespace Guru
string scene = orderData.scene;
bool isFree = orderData.isFree;
string offerId = orderData.offerId;
string transactionId = "";
string productToken = "";
string receipt = "";
if (orderData is GoogleOrderData gdata)
{
productToken = gdata.token;
}
else if (orderData is AppleOrderData adata)
{
receipt = adata.receipt;
}
// TCH 001
Tch001IAPRev(usdPrice, productId, orderId, orderType, orderDate, isTest);
// TCH 020
Tch02IAPRev(usdPrice, productId, orderId, orderType, orderDate, isTest);
// Facebook Track IAP Purchase
FBPurchase(usdPrice, USD, "iap", IAPPlatform);
if (orderData.orderType == 1)
{
// sub_pruchase : Firebase + Guru + Adjust
SubPurchase(usdPrice, productId, orderId, orderDate, isTest);
SubPurchase(usdPrice, productId, orderId, orderDate, productToken, receipt);
}
else
{
// iap_purchase : Firebase + Guru + Adjust
IAPPurchase(usdPrice, productId, orderId, orderDate, isTest);
IAPPurchase(usdPrice, productId, orderId, orderDate, productToken, receipt);
}
// IAP Ret true : Firebase + Guru + Adjust
@ -665,20 +683,34 @@ namespace Guru
/// <param name="productId"></param>
/// <param name="orderId"></param>
/// <param name="orderDate"></param>
public static void IAPPurchase(double value, string productId, string orderId, string orderDate, bool isSandbox = false)
/// <param name="purchaseToken"></param>
/// <param name="receipt"></param>
public static void IAPPurchase(double value, string productId, string orderId, string orderDate,
string purchaseToken = "", string receipt = "")
{
IAPPurchaseReport(EventIAPPurchase, value, productId, orderId, "IAP", orderDate, isSandbox);
IAPPurchaseReport(EventIAPPurchase, value, productId, orderId, "IAP", orderDate, purchaseToken, receipt);
}
public static void SubPurchase(double value, string productId, string orderId, string orderDate, bool isSandbox = false)
/// <summary>
/// SUB 订阅上报
/// </summary>
/// <param name="value"></param>
/// <param name="productId"></param>
/// <param name="orderId"></param>
/// <param name="orderDate"></param>
/// <param name="purchaseToken"></param>
/// <param name="receipt"></param>
public static void SubPurchase(double value, string productId, string orderId, string orderDate,
string purchaseToken = "", string receipt = "")
{
IAPPurchaseReport(EventSubPurchase, value, productId, orderId, "SUB", orderDate, isSandbox);
IAPPurchaseReport(EventSubPurchase, value, productId, orderId, "SUB", orderDate, purchaseToken, receipt);
}
private static void IAPPurchaseReport(string eventName, double value, string productId, string orderId, string orderType, string orderDate, bool isSandbox = false)
private static void IAPPurchaseReport(string eventName, double value, string productId,
string orderId, string orderType, string orderDate, string purchaseToken = "", string receipt = "")
{
LogEvent(eventName, new Dictionary<string, dynamic>()
var dict = new Dictionary<string, dynamic>()
{
[ParameterPlatform] = IAPPlatform,
[ParameterValue] = value,
@ -686,13 +718,14 @@ namespace Guru
[ParameterProductId] = productId,
["order_id"] = orderId,
["order_type"] = orderType,
["trans_ts"] = orderDate,
["sandbox"] = isSandbox? "true": "false"
}, new EventSetting()
{
EnableFirebaseAnalytics = true,
EnableAdjustAnalytics = true,
});
["trans_ts"] = orderDate
};
// 上报Firebase + 自打点
LogEvent(eventName, dict, new EventSetting() { EnableFirebaseAnalytics = true });
// 上报 Adjust 支付事件
LogAdjustRevenueEvent(eventName, value, productId, orderId, purchaseToken, receipt, dict);
}
#endregion

View File

@ -250,6 +250,44 @@ namespace Guru
}
}
/// <summary>
/// 上报 Adjust 事件
/// </summary>
/// <param name="eventName"></param>
/// <param name="productId"></param>
/// <param name="receipt"></param>
/// <param name="data"></param>
/// <param name="usdPrice"></param>
/// <param name="transactionId"></param>
/// <param name="purchaseToken"></param>
/// <returns></returns>
internal static bool LogAdjustRevenueEvent(string eventName, double usdPrice,
string productId = "", string transactionId = "", string purchaseToken = "", string receipt = "",
Dictionary<string, object> data = null )
{
AdjustEvent adjustEvent = Analytics.CreateAdjustEvent(eventName);
if (adjustEvent != null)
{
adjustEvent.setRevenue(usdPrice, USD);
if (!string.IsNullOrEmpty(productId)) adjustEvent.setProductId(productId);
if (!string.IsNullOrEmpty(transactionId)) adjustEvent.setTransactionId(transactionId);
if (!string.IsNullOrEmpty(purchaseToken)) adjustEvent.setPurchaseToken(purchaseToken);
if (!string.IsNullOrEmpty(receipt)) adjustEvent.setReceipt(receipt);
if (data != null && data.Count > 0)
{
foreach (var kv in data)
{
adjustEvent.AddEventParameter(kv.Key, kv.Value.ToString());
}
}
Adjust.trackEvent(adjustEvent);
return true;
}
return false;
}
#endregion
#region 通用打点

View File

@ -31,7 +31,7 @@ namespace Guru
protected override void RequestSuccessCallBack(string response)
{
this.Log("@@@ Send OK!");
UnityEngine.Debug.Log("[SDK] --- Send DeviceData Success");
IPMConfig.IS_UPLOAD_DEVICE_SUCCESS = true;
}