Skip to content

Commit

Permalink
Adding Missing LineItemName (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
SCastanedaMunoz authored Jun 12, 2023
1 parent 7c1d17e commit 0d32fc5
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ object EventProcessor {

@JvmStatic
fun serializeLoadEvent(placementName: String, loadId: String, data: Map<String, String>, error: ChartboostMediationAdException?,
loadConsumer: LoadEventConsumer<String, String, String, String, Double, String, String>) {
loadConsumer: LoadEventConsumer<String, String, String, String, Double, String, String, String>) {
val errorMessage = error?.toString() ?: ""

val partnerId = getAuctionData("partner_id", data)
val auctionId = getAuctionData("auction-id", data)
val lineItemName = getAuctionData("line_item_name", data)
val lineItemId = getAuctionData("line_item_id", data)

val price = try {
Expand All @@ -35,7 +36,7 @@ object EventProcessor {
0.0
}

loadConsumer.accept(placementName, loadId, auctionId, partnerId, price, lineItemId, errorMessage)
loadConsumer.accept(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, errorMessage)
}

fun interface EventConsumer<PlacementName>{
Expand All @@ -46,7 +47,7 @@ object EventProcessor {
fun accept(placementName: PlacementName, errorMessage: ErrorMessage)
}

fun interface LoadEventConsumer<PlacementName, LoadId, AuctionId, PartnerId, Price, LineItemId, Error> {
fun accept(placementName: PlacementName, loadId: LoadId, auctionId: AuctionId, partnerId: PartnerId, price: Price, lineItemId: LineItemId, error: Error)
fun interface LoadEventConsumer<PlacementName, LoadId, AuctionId, PartnerId, Price, LineItemName, LineItemId, Error> {
fun accept(placementName: PlacementName, loadId: LoadId, auctionId: AuctionId, partnerId: PartnerId, price: Price, lineItemName:LineItemName, lineItemId: LineItemId, error: Error)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package com.chartboost.mediation.unity
* Interface for sending real-time Banner events
*/
interface IBannerEventListener {
fun DidLoadBanner(placementName: String, loadId: String, auctionId: String, partnerId: String, price: Double, lineItemId: String, error: String)
fun DidLoadBanner(placementName: String, loadId: String, auctionId: String, partnerId: String, price: Double, lineItemName: String, lineItemId: String, error: String)
fun DidClickBanner(placementName: String)
fun DidRecordImpression(placementName: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.chartboost.mediation.unity
*/
@Deprecated("IInterstitialEventListener has been deprecated, utilize the new Fullscreen API instead")
interface IInterstitialEventListener {
fun DidLoadInterstitial(placementName: String, loadId: String, auctionId: String, partnerId: String, price: Double, lineItemId: String, error: String)
fun DidLoadInterstitial(placementName: String, loadId: String, auctionId: String, partnerId: String, price: Double, lineItemName: String, lineItemId: String, error: String)
fun DidShowInterstitial(placementName: String, error: String)
fun DidCloseInterstitial(placementName: String, error: String)
fun DidClickInterstitial(placementName: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.chartboost.mediation.unity
*/
@Deprecated("IRewardedEventListener has been deprecated, utilize the new fullscreen API instead.")
interface IRewardedEventListener {
fun DidLoadRewarded(placementName: String, loadId: String, auctionId: String, partnerId: String, price: Double, lineItemId: String, error: String)
fun DidLoadRewarded(placementName: String, loadId: String, auctionId: String, partnerId: String, price: Double, lineItemName: String, lineItemId: String, error: String)
fun DidShowRewarded(placementName: String, error: String)
fun DidCloseRewarded(placementName: String, error: String)
fun DidClickRewarded(placementName: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class UnityBridge {
val interstitialAd = HeliumInterstitialAd(UnityPlayer.currentActivity, placementName, object : HeliumFullscreenAdListener {
override fun onAdCached(placementName: String, loadId: String, winningBidInfo: Map<String, String>, error: ChartboostMediationAdException?) {
serializeLoadEvent(placementName, loadId, winningBidInfo, error,
LoadEventConsumer { eventPlacementName: String, eventLoadId: String, auctionId: String, partnerId: String, price: Double, eventLineItemId:String, eventError: String ->
interstitialEventsListener?.DidLoadInterstitial(eventPlacementName, eventLoadId, auctionId, partnerId, price, eventLineItemId, eventError)
LoadEventConsumer { eventPlacementName: String, eventLoadId: String, auctionId: String, partnerId: String, price: Double, lineItemName:String, lineItemId:String, eventError: String ->
interstitialEventsListener?.DidLoadInterstitial(eventPlacementName, eventLoadId, auctionId, partnerId, price, lineItemName, lineItemId, eventError)
}
)
}
Expand Down Expand Up @@ -108,8 +108,8 @@ class UnityBridge {
val rewardedAd = HeliumRewardedAd(UnityPlayer.currentActivity, placementName, object : HeliumFullscreenAdListener {
override fun onAdCached(placementName: String, loadId: String, winningBidInfo: Map<String, String>, error: ChartboostMediationAdException?) {
serializeLoadEvent(placementName, loadId, winningBidInfo, error,
LoadEventConsumer { eventPlacementName: String, eventLoadId: String, auctionId: String, partnerId: String, price: Double, eventLineItemId:String, eventError: String ->
rewardedEventListener?.DidLoadRewarded(eventPlacementName, eventLoadId, auctionId, partnerId, price, eventLineItemId, eventError)
LoadEventConsumer { eventPlacementName: String, eventLoadId: String, auctionId: String, partnerId: String, price: Double, lineItemName:String, lineItemId:String, eventError: String ->
rewardedEventListener?.DidLoadRewarded(eventPlacementName, eventLoadId, auctionId, partnerId, price, lineItemName, lineItemId, eventError)
}
)
}
Expand Down Expand Up @@ -165,8 +165,8 @@ class UnityBridge {
val bannerAd = HeliumBannerAd(UnityPlayer.currentActivity, placementName, wantedSize, object : HeliumBannerAdListener {
override fun onAdCached(placementName: String, loadId: String, winningBidInfo: Map<String, String>, error: ChartboostMediationAdException?) {
serializeLoadEvent(placementName, loadId, winningBidInfo, error,
LoadEventConsumer { eventPlacementName: String, eventLoadId: String, auctionId: String, partnerId: String, price: Double, eventLineItemId:String, eventError: String ->
bannerEventsListener?.DidLoadBanner(eventPlacementName, eventLoadId, auctionId, partnerId, price, eventLineItemId, eventError)
LoadEventConsumer { eventPlacementName: String, eventLoadId: String, auctionId: String, partnerId: String, price: Double, lineItemName:String, lineItemId:String, eventError: String ->
bannerEventsListener?.DidLoadBanner(eventPlacementName, eventLoadId, auctionId, partnerId, price, lineItemName, lineItemId, eventError)
}
)
}
Expand Down
4 changes: 3 additions & 1 deletion com.chartboost.mediation/Runtime/Data/BidInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public struct BidInfo
[JsonProperty("auction-id")] public readonly string AuctionId;
[JsonProperty("partner-id")] public readonly string PartnerId;
[JsonProperty("price")] public readonly double Price;
[JsonProperty("line_item_name")] public readonly string LineItemName;
[JsonProperty("line_item_id")] public readonly string LineItemId;

public BidInfo(string auctionId, string partnerId, double price, string lineItemId)
public BidInfo(string auctionId, string partnerId, double price, string lineItemName, string lineItemId)
{
AuctionId = auctionId;
PartnerId = partnerId;
Price = price;
LineItemName = lineItemName;
LineItemId = lineItemId;
}
}
Expand Down
4 changes: 2 additions & 2 deletions com.chartboost.mediation/Runtime/Events/EventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static void ProcessChartboostMediationPlacementEvent(string placementName
}, null);
}

public static void ProcessChartboostMediationLoadEvent(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error, ChartboostMediationPlacementLoadEvent bidEvent)
public static void ProcessChartboostMediationLoadEvent(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error, ChartboostMediationPlacementLoadEvent bidEvent)
{
if (bidEvent == null)
return;
Expand All @@ -122,7 +122,7 @@ public static void ProcessChartboostMediationLoadEvent(string placementName, str
{
try
{
var bidInfo = new BidInfo(auctionId, partnerId, price, lineItemId);
var bidInfo = new BidInfo(auctionId, partnerId, price, lineItemName, lineItemId);
bidEvent(placementName, loadId, bidInfo, error);
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ private BannerEventListener() : base(GetQualifiedClassName("IBannerEventListener

public static readonly BannerEventListener Instance = new BannerEventListener();

private void DidLoadBanner(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemId, error, _instance.DidLoadBanner);
private void DidLoadBanner(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, error, _instance.DidLoadBanner);

private void DidClickBanner(string placementName)
=> EventProcessor.ProcessChartboostMediationPlacementEvent(placementName, null, _instance.DidClickBanner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ private InterstitialEventListener() : base(GetQualifiedClassName("IInterstitialE

public static readonly InterstitialEventListener Instance = new InterstitialEventListener();

private void DidLoadInterstitial(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemId, error, _instance.DidLoadInterstitial);
private void DidLoadInterstitial(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, error, _instance.DidLoadInterstitial);

private void DidShowInterstitial(string placementName, string error)
=> EventProcessor.ProcessChartboostMediationPlacementEvent(placementName, error, _instance.DidShowInterstitial);
Expand Down Expand Up @@ -44,8 +44,8 @@ private RewardedVideoEventListener() : base(GetQualifiedClassName("IRewardedEven

public static readonly RewardedVideoEventListener Instance = new RewardedVideoEventListener();

private void DidLoadRewarded(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemId, error, _instance.DidLoadRewarded);
private void DidLoadRewarded(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, error, _instance.DidLoadRewarded);

private void DidShowRewarded(string placementName, string error)
=> EventProcessor.ProcessChartboostMediationPlacementEvent(placementName, error, _instance.DidShowRewarded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed partial class ChartboostMediationIOS
private delegate void ExternChartboostMediationILRDEvent(string impressionDataJson);
private delegate void ExternChartboostMediationPartnerInitializationDataEvent(string partnerInitializationData);
private delegate void ExternChartboostMediationPlacementEvent(string placementName, string error);
private delegate void ExternChartboostMediationPlacementLoadEvent(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error);
private delegate void ExternChartboostMediationPlacementLoadEvent(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error);

private static readonly Dictionary<int, ILater> WaitingProxies = new Dictionary<int, ILater>();

Expand Down Expand Up @@ -122,8 +122,8 @@ private static void FullscreenAdEvents(long adHashCode, int eventType, string co

#region Banner Callbacks
[MonoPInvokeCallback(typeof(ExternChartboostMediationPlacementLoadEvent))]
private static void ExternDidLoadBanner(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemId, error, _instance.DidLoadBanner);
private static void ExternDidLoadBanner(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, error, _instance.DidLoadBanner);

[MonoPInvokeCallback(typeof(ExternChartboostMediationPlacementEvent))]
private static void ExternDidClickBanner(string placementName, string error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private static extern void _setRewardedCallbacks(ExternChartboostMediationPlacem

#region Interstitial Callbacks
[MonoPInvokeCallback(typeof(ExternChartboostMediationPlacementLoadEvent))]
private static void ExternDidLoadInterstitial(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemId, error, _instance.DidLoadInterstitial);
private static void ExternDidLoadInterstitial(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, error, _instance.DidLoadInterstitial);

[MonoPInvokeCallback(typeof(ExternChartboostMediationPlacementEvent))]
private static void ExternDidShowInterstitial(string placementName, string error)
Expand All @@ -47,8 +47,8 @@ private static void ExternDidRecordImpressionInterstitial(string placementName,

#region Rewarded Callbacks
[MonoPInvokeCallback(typeof(ExternChartboostMediationPlacementLoadEvent))]
private static void ExternDidLoadRewarded(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemId, error, _instance.DidLoadRewarded);
private static void ExternDidLoadRewarded(string placementName, string loadId, string auctionId, string partnerId, double price, string lineItemName, string lineItemId, string error)
=> EventProcessor.ProcessChartboostMediationLoadEvent(placementName, loadId, auctionId, partnerId, price, lineItemName, lineItemId, error, _instance.DidLoadRewarded);

[MonoPInvokeCallback(typeof(ExternChartboostMediationPlacementEvent))]
private static void ExternDidShowRewarded(string placementName, string error)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
typedef void (*ChartboostMediationILRDEvent)(const char* impressionData);
typedef void (*ChartboostMediationPartnerInitializationDataEvent)(const char* partnerInitializationData);
typedef void (*ChartboostMediationPlacementEvent)(const char* placementName, const char* error);
typedef void (*ChartboostMediationPlacementLoadEvent)(const char* placementName, const char* loadId, const char* auctionId, const char* partnerId, double price, const char* lineItemId, const char* error);
typedef void (*ChartboostMediationPlacementLoadEvent)(const char* placementName, const char* loadId, const char* auctionId, const char* partnerId, double price, const char* lineItemName, const char* lineItemId, const char* error);

// Fullscreen Events
typedef void (*ChartboostMediationFullscreenAdLoadResultEvent)(int hashCode, const void* adHashCode, const char *loadId, const char *winningBidJson, const char *metricsJson, const char *code, const char *message);
Expand Down Expand Up @@ -84,24 +84,13 @@ const void serializePlacementLoadWithError(NSString *placementName, NSString *re
if (placementLoadEvent == nil)
return;

NSString* partnerId = [winningBidInfo objectForKey:@"partner-id"];
NSString* auctionId = [winningBidInfo objectForKey:@"auction-id"];
NSNumber* price = [winningBidInfo objectForKey:@"price"];
NSString* lineItemId = [winningBidInfo objectForKey:@"line_item_id"];

if (partnerId == nil)
partnerId = @"";

if (auctionId == nil)
auctionId = @"";

if (lineItemId == nil)
lineItemId = @"";

if (price == nil)
price = 0;
NSString* partnerId = [winningBidInfo objectForKey:@"partner-id"] ?: @"";
NSString* auctionId = [winningBidInfo objectForKey:@"auction-id"] ?: @"";
NSNumber* price = [winningBidInfo objectForKey:@"price"] ?: 0;
NSString* lineItemName = [winningBidInfo objectForKey:@"line_item_name"] ?: @"";
NSString* lineItemId = [winningBidInfo objectForKey:@"line_item_id"] ?: @"";

placementLoadEvent(placementName.UTF8String, requestIdentifier.UTF8String, auctionId.UTF8String, partnerId.UTF8String, [price doubleValue], lineItemId.UTF8String, error.localizedDescription.UTF8String);
placementLoadEvent(placementName.UTF8String, requestIdentifier.UTF8String, auctionId.UTF8String, partnerId.UTF8String, [price doubleValue], lineItemName.UTF8String, lineItemId.UTF8String, error.localizedDescription.UTF8String);
}

static NSMutableDictionary * storedAds;
Expand Down
Loading

0 comments on commit 0d32fc5

Please sign in to comment.