Saving and Querying Event Data Sent by LogEventRequest
D
Dan Pereira
started a topic
over 6 years ago
My app needs to store session data that is static, meaning it won't change after it is sent from unity to gamesparks. I have created an event with the appropriate fields, I can send the event request and I can see the request was successfully sent in both the unity console and in the player admin dashboard. How can I now query those events? It seems I need to add some cloud code to add the data to a collection, but I don't see any examples of adding data to a metaCollection as they are read only. Once this data is stored it never needs to change. This leads me to a few questions:
1. If the event is showing up on the player admin dashboard, isn't it already in a collection that can be queried? In the NoSQL collections dropdown I see no collections related to my events. If I need to create a collection in cloud code, how do I save the event data to a metaCollection? Is this efficient, seems like the data is being stored twice?
2. What is the proper workflow for storing usage data sent by LogEventRequest and then being able to query that data. The data is potentially too large to attach to a player collection and will be read only once it is stored.
Best Answer
C
Customer Support
said
over 6 years ago
Hi Dan,
I understand the data you are storing is static but the data itself will be coming in on a Live game therefore the collection will need to be a runtime collection, a meta collection can not be written too when in Live mode. In the portal under Configurator -> Cloud Code, you'll see your custom event under Events, this is where you can add the custom script to add the data to the collection. This tutorial here will explain the basics of setting up an event and getting / storing data from that event: https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/using-cloud-code.html
I understand the data you are storing is static but the data itself will be coming in on a Live game therefore the collection will need to be a runtime collection, a meta collection can not be written too when in Live mode. In the portal under Configurator -> Cloud Code, you'll see your custom event under Events, this is where you can add the custom script to add the data to the collection. This tutorial here will explain the basics of setting up an event and getting / storing data from that event: https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/using-cloud-code.html
Dan Pereira
My app needs to store session data that is static, meaning it won't change after it is sent from unity to gamesparks. I have created an event with the appropriate fields, I can send the event request and I can see the request was successfully sent in both the unity console and in the player admin dashboard. How can I now query those events? It seems I need to add some cloud code to add the data to a collection, but I don't see any examples of adding data to a metaCollection as they are read only. Once this data is stored it never needs to change. This leads me to a few questions:
1. If the event is showing up on the player admin dashboard, isn't it already in a collection that can be queried? In the NoSQL collections dropdown I see no collections related to my events. If I need to create a collection in cloud code, how do I save the event data to a metaCollection? Is this efficient, seems like the data is being stored twice?
2. What is the proper workflow for storing usage data sent by LogEventRequest and then being able to query that data. The data is potentially too large to attach to a player collection and will be read only once it is stored.
Hi Dan,
I understand the data you are storing is static but the data itself will be coming in on a Live game therefore the collection will need to be a runtime collection, a meta collection can not be written too when in Live mode. In the portal under Configurator -> Cloud Code, you'll see your custom event under Events, this is where you can add the custom script to add the data to the collection. This tutorial here will explain the basics of setting up an event and getting / storing data from that event: https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/using-cloud-code.html
Retrieving data is very similar to saving. You setup an event then in cloud code, write a script that searches for a particular document in the collection (you use Spark.runtimeCollection for this: https://docs.gamesparks.com/api-documentation/cloud-code-api/spark.html#runtimecollection) then set this data to return using Spark.setScriptData: https://docs.gamesparks.com/api-documentation/cloud-code-api/spark.html#setscriptdata.
Hope this helps,
- Steve
Customer Support
Hi Dan,
I understand the data you are storing is static but the data itself will be coming in on a Live game therefore the collection will need to be a runtime collection, a meta collection can not be written too when in Live mode. In the portal under Configurator -> Cloud Code, you'll see your custom event under Events, this is where you can add the custom script to add the data to the collection. This tutorial here will explain the basics of setting up an event and getting / storing data from that event: https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/using-cloud-code.html
Retrieving data is very similar to saving. You setup an event then in cloud code, write a script that searches for a particular document in the collection (you use Spark.runtimeCollection for this: https://docs.gamesparks.com/api-documentation/cloud-code-api/spark.html#runtimecollection) then set this data to return using Spark.setScriptData: https://docs.gamesparks.com/api-documentation/cloud-code-api/spark.html#setscriptdata.
Hope this helps,
- Steve
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics