update: 新增首通关卡接口, 支付订单 ID 获取接口

Signed-off-by: huyufei <yufei.hu@castbox.fm>
deeplink
胡宇飞 2024-05-13 17:00:07 +08:00
parent 171e67ac77
commit bb3a1310b3
3 changed files with 32 additions and 23 deletions

View File

@ -25,6 +25,9 @@ namespace Guru
public static readonly string EventIAPReturnTrue = "iap_ret_true";
public static readonly string EventIAPReturnFalse = "iap_ret_false";
// 关卡打点
public static readonly string EventLevelFirstEnd = "level_first_end";
//横幅广告打点事件
public static readonly string EventBadsLoad = "bads_load";
public static readonly string EventBadsLoaded = "bads_loaded";

View File

@ -238,25 +238,24 @@ namespace Guru
/// <summary>
/// 第一次通关打点
/// </summary>
private static void LevelFirstEnd(string itemCategory, string itemID, string levelName, int level,
ELevelResult result, int? duration = null, int? step = null, int? score = null)
public static void LevelFirstEnd(string levelType, string levelName, int level,
string result, int? duration = null, Dictionary<string, object> extra = null)
{
var dict = new Dictionary<string, object>()
{
{ ParameterItemCategory, itemCategory },
{ ParameterItemId, itemID },
{ ParameterItemCategory, levelType },
{ ParameterLevelName, levelName },
{ ParameterLevel, level },
{ ParameterSuccess, result == ELevelResult.success ? 1 : 0 },
{ ParameterResult, result.ToString() },
{ ParameterSuccess, result == "success" ? 1 : 0 },
{ ParameterResult, result },
};
if (duration != null)
dict[ParameterDuration] = duration.Value;
if(step != null)
dict[ParameterStep] = step.Value;
if(score != null)
dict[ParameterScore] = score.Value;
if (extra != null)
dict.AddRange(extra, isOverride: true);
LogEvent(EventLevelFirstEnd, dict);
}
#endregion
@ -604,6 +603,7 @@ namespace Guru
{
{ ParameterItemCategory, itemCategory },
{ ParameterItemName, productID },
{ ParameterResult, failReason }
});
}

View File

@ -37,9 +37,22 @@ namespace Guru
public bool IsInitialized => _storeController != null && _storeExtensionProvider != null;
private Product _curPurchasingProduct = null;
private ProductInfo _curProductInfo = null;
private string _curProductCategory = "";
public string CurrentBuyingProductId
{
get
{
if (_curProductInfo != null)
{
return _curProductInfo.Id;
}
return "";
}
}
private IAPModel _model;
/// <summary>
/// 是否是首次购买
@ -532,11 +545,11 @@ namespace Guru
#endif
if (string.IsNullOrEmpty(category)) category = info.Category;
_storeController.InitiatePurchase(product);
_curPurchasingProduct = product;
_curProductInfo = info;
_curProductCategory = category;
Analytics.IAPClick(_curProductCategory, product.definition.id);
Analytics.IAPImp(_curProductCategory, product.definition.id);
// Analytics.IAPImp(_curProductCategory, product.definition.id); // <--- Client should report this Event
OnBuyStart?.Invoke(productName);
return (T)this;
@ -569,7 +582,7 @@ namespace Guru
SetIsIAPUser(success); // 设置用户属性标记
// 只有实际发生购买后才会有订单上报. 启动时的 Restore 操作自动调用支付成功. 这里做一个判定, 过滤掉订单的物品
if (_curPurchasingProduct != null)
if (_curProductInfo != null)
{
ReportPurchaseResult(purchaseEvent); // 订单上报
@ -619,14 +632,7 @@ namespace Guru
ProductInfo info = GetInfoById(productId);
//上报点位,用户购买失败的原因
if (failureReason == PurchaseFailureReason.UserCancelled)
{
Analytics.IAPClose(_curProductCategory, product.definition.id);
}
else
{
Analytics.IAPRetFalse(_curProductCategory, product.definition.id, failureReason.ToString());
}
Analytics.IAPRetFalse(_curProductCategory, product.definition.id, failureReason.ToString());
LogI($"{Tag} --- OnPurchaseFailed :: failureReason = {failureReason}");
// 失败的处理逻辑
@ -639,7 +645,7 @@ namespace Guru
private void ClearCurPurchasingProduct()
{
_curPurchasingProduct = null;
_curProductInfo = null;
_curProductCategory = "";
}