Start a new topic

Issue deserializing array of EventBuilder objects

 I am sending a LevelUp event and am having issues with the deserialization of 'reward' items.

We are using the latest DeltaDNA Plug-in for Unity 5.2....

Results (via looking at invalid event)

"reward": {
         "rewardName": "LEVELUP_25",
         "rewardProducts": {
            "items": [

Our code base is as follows:

var rewardItems = new List<EventBuilder>();
foreach (IUnlockableContent rewardContent in rewards)
   EventBuilder itemObj = new EventBuilder();
   itemObj.AddParam("itemAmount", 1);
   itemObj.AddParam("itemName", GetUnlockedItemName(rewardContent));
   itemObj.AddParam("itemType", GetUnlockedItemType(rewardContent));

   rewardItems.Add(new EventBuilder().AddParam("item", itemObj));

EventBuilder itemObj = new EventBuilder().AddParam("items", rewardItems);
rewardsEvent.AddParam("rewardProducts", itemObj);


 Any suggestion pointing to what I am doing wrong? Or is the issue in the Unity Engine Plug-in?



Hello Donald,

What you are seeing is one event but this event is represented by multiple rows.

The row in the events table with eventLevel 0 is the main row, the others will have eventlevel 1 or higher and refer to the main row in the field mainEventId.

This you will see with all "nested" events since it is not possible to store the information in one table any easier way.

I hope this explains what you're seeing.

I am now sending 'valid' 'LevelUp' events - when I look in the DeltaDNA Event Browser I see a 'LevelUp' event created for each Item added to 'rewardProducts' is this expected? (vs. seeing a single 'LevelUp' event with an array of the items).

I have verified that we are only sending a single 'LevelUp' event.

Thanks again.


Thank you for the info, I completely missed seeing the 'ProductBuilder' class which is what I need in this case.



It seems to me like you are adding the list of eventbuilders as one param instead of an eventbuilder with multiple nested events. If you would make rewardItems an eventbuilder then it should work.

Here is an example of a nested event with a reward:

EventBuilder achievementParams = new EventBuilder()
.AddParam("achievementName", "Sunday Showdown Tournament Win")
.AddParam("achievementID", "SS-2014-03-02-01")
.AddParam("reward", new EventBuilder()
     .AddParam("rewardProducts", new ProductBuilder()
          .AddRealCurrency("USD", 5000)
          .AddVirtualCurrency("VIP Points", "GRIND", 20)
          .AddItem("Sunday Showdown Medal", "Victory Badge", 1))

     .AddParam("rewardName", "Medal"));

DDNA.Instance.RecordEvent("achievement", achievementParams);

Login or Signup to post a comment