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

View File

@ -31,10 +31,10 @@ namespace Guru
protected override void RequestSuccessCallBack(string response) protected override void RequestSuccessCallBack(string response)
{ {
this.Log("@@@ Send OK!"); UnityEngine.Debug.Log("[SDK] --- Send DeviceData Success");
IPMConfig.IS_UPLOAD_DEVICE_SUCCESS = true; IPMConfig.IS_UPLOAD_DEVICE_SUCCESS = true;
} }
/// <summary> /// <summary>
/// 设置是否打开推送 /// 设置是否打开推送
/// </summary> /// </summary>