Skip to content

Commit

Permalink
EID RTB Update & Additional Logging (#50)
Browse files Browse the repository at this point in the history
* Needed to remove test files from unity so it will compile.

* Added "atype" for EIDs.UIDs and added logging for Bid Requests and Bid Responses.

* Changing logging to UnityLogging and fixing things Jason pointed out.

* Changed to string interpolation.
  • Loading branch information
jonathansligh-nimbus authored Sep 24, 2024
1 parent 2cd8d2b commit 0768e31
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
6 changes: 3 additions & 3 deletions com.adsbynimbus.nimbus/Editor/IOSPostBuildProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public static void OnPostprocessBuild(BuildTarget target, string path) {
private static void CopyPodfile(string pathToBuiltProject) {
var podfile = new IOSBuildDependencies();
var destPodfilePath = pathToBuiltProject + "/Podfile";
Debug.Log($"Copying generating pod file to {destPodfilePath}");
Debug.unityLogger.Log($"Copying generating pod file to {destPodfilePath}");
if (!File.Exists(destPodfilePath)) {
File.WriteAllText(destPodfilePath, podfile.BuildDependencies());
}
else {
Debug.Log("Podfile already exists");
Debug.unityLogger.Log("Podfile already exists");
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ private static void AddSkaAdNetworkIdsToPlist(string path) {
}
}

Debug.Log($"Writing SkAdNetwork ids to {path}");
Debug.unityLogger.Log($"Writing SkAdNetwork ids to {path}");
plist.WriteToFile(plistPath);
}
}
Expand Down
16 changes: 9 additions & 7 deletions com.adsbynimbus.nimbus/Editor/NimbusManagerCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ private void OnGUI() {

_asset.Sanitize();
if (_asset.apiKey.IsNullOrEmpty()) {
Debug.LogError("Apikey cannot be empty, object NimbusAdsManager not created");
Debug.unityLogger.LogError("Nimbus",
"Apikey cannot be empty, object NimbusAdsManager not created");
return;
}

if (_asset.publisherKey.IsNullOrEmpty()) {
Debug.LogError("Publisher cannot be empty, object NimbusAdsManager not created");
Debug.unityLogger.LogError("Nimbus",
"Publisher cannot be empty, object NimbusAdsManager not created");
return;
}

Expand Down Expand Up @@ -241,7 +243,7 @@ private bool ValidateApsData() {
#endif

if (appId.IsNullOrEmpty()) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
"APS SDK has been included, the APS App ID cannot be empty, object NimbusAdsManager not created");
return false;
}
Expand All @@ -257,21 +259,21 @@ private bool ValidateApsData() {
#endif

if (slotData == null || slotData.Length == 0) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, APS placement slots for {platform} need to be entered, object NimbusAdsManager not created");
return false;
}

var seenAdTypes = new Dictionary<AdUnitType, bool>();
foreach (var apsSlot in slotData) {
if (apsSlot.SlotId.IsNullOrEmpty()) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, the APS slot id for {platform} cannot be empty, object NimbusAdsManager not created");
return false;
}

if (apsSlot.AdUnitType == AdUnitType.Undefined) {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, Ad Unit type for {platform} cannot be Undefined, object NimbusAdsManager not created");
return false;
}
Expand All @@ -280,7 +282,7 @@ private bool ValidateApsData() {
seenAdTypes.Add(apsSlot.AdUnitType, true);
}
else {
Debug.LogError(
Debug.unityLogger.LogError("Nimbus",
$"APS SDK has been included, APS cannot contain duplicate ad type {apsSlot.AdUnitType} for {platform}, object NimbusAdsManager not created");
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
#if !UNITY_EDITOR && !UNITY_IOS && !UNITY_ANDROID
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down Expand Up @@ -32,4 +33,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
#endif
4 changes: 3 additions & 1 deletion com.adsbynimbus.nimbus/Runtime/Plugins/RTB.Tests/Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if !UNITY_EDITOR && !UNITY_IOS && !UNITY_ANDROID
using System;
using System.Diagnostics;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -400,3 +401,4 @@ public ValidateBidRequestTableData(string name, BidRequest request, bool wantErr
}
}
}
#endif
3 changes: 3 additions & 0 deletions com.adsbynimbus.nimbus/Runtime/Plugins/RTB/Request/Eid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class Eid {
public class Uid {
[JsonProperty("id", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Id;

[JsonProperty("atype", DefaultValueHandling = DefaultValueHandling.Ignore)]
public int aType;

[JsonProperty("ext", DefaultValueHandling = DefaultValueHandling.Ignore)]
public UidExt UidExt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Nimbus.ScriptableObjects;
using OpenRTB.Request;
using static System.String;
using UnityEngine;

#if !UNITY_EDITOR
using System.Text;
Expand Down Expand Up @@ -53,6 +54,7 @@ public async Task<string> MakeRequestAsync(BidRequest bidRequest) {
#else
// This will throw an exception if the bid request is missing required data from Nimbus
var body = JsonConvert.SerializeObject(bidRequest);
Debug.unityLogger.Log("Nimbus", $"BID REQUEST: {body}");
HttpContent jsonBody = new StringContent(body, Encoding.UTF8, "application/json");
var serverResponse = await Client.PostAsync(_nimbusEndpoint, jsonBody, _ctx.Token);
if (_ctx.Token.IsCancellationRequested) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ await Task.Run(async () => {
_adEvents.FireOnAdErrorEvent(this);
return;
}
Debug.unityLogger.Log("Nimbus",$"BID RESPONSE: {response}");
_adWasReturned = true;
RawBidResponse = response;
BidResponse = JsonConvert.DeserializeObject<BidResponse>(response);
Expand Down
3 changes: 2 additions & 1 deletion com.adsbynimbus.nimbus/Runtime/Scripts/NimbusManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Nimbus.Internal;
using Nimbus.Internal.Network;
using Nimbus.Internal.RequestBuilder;
Expand Down Expand Up @@ -277,7 +278,7 @@ public async void RequestRefreshingBannerAdAndLoad(CancellationTokenSource sourc
/// </param>
public void ShowLoadedAd(NimbusAdUnit adUnit) {
if (adUnit == null) {
Debug.unityLogger.LogError("",
Debug.unityLogger.LogError("Nimbus",
"there was no ad to render, likely there was no fill meaning that demand did not want to spend");
return;
}
Expand Down

0 comments on commit 0768e31

Please sign in to comment.