Start a new topic

levelUp event JSON structure in unity

The JSON schema for levelUp event is special, the reward object has two properties: one is the products and the other is reward name, if it was only the products using a ProductBuilder it could be filled however for the reward key we should add another subkey for rewardName

How can we do this in unity? other than creating the JSON structure by hand using SimpleJSON?


Hello Ashkan Saeedi,


Thank you for posting your question here.


The following code snippet shows how to send a levelUp event in Unity:

    

EventBuilder levelUpParams = new EventBuilder()
	.AddParam("levelUpName", "Silver level")
		.AddParam("reward", new EventBuilder()
		          .AddParam("rewardProducts", new ProductBuilder()
			          .AddRealCurrency("USD",500)
			          .AddVirtualCurrency("GOLD", "GRIND", 20)
			          .AddItem("Silver Medal", "Silver Badge", 1))
		          .AddParam("rewardName", "Medal"));

DDNA.Instance.RecordEvent("levelUp", levelUpParams);

    

The thing that makes this an unusual event is the productBuilder as a parameter and then adding the rewardName to the same EventBuilder.


As you can see it is not necessary to create a JSON string yourself.


I hope this answers your question!

Great! I thought in each event builder the SDK adds the implicit paramters that you send automatically so was afraid of creating a nested EventBuilder. Maybe a good thing to mention in the unity integration doc.

Many thanks

Login or Signup to post a comment