Sign In Register

How can we help you today?

Start a new topic
Answered

Determine the LogEvent that LogEventRequest/LogEventResponse is straddling?

I'm looking to add some functionality to ALL custom events in a single place...and GameSparks gives me the handy LogEventRequest and LogEventResponse scripts where I can add pre and post hooks to any custom event. Yay!!!


 I was interested in adding some logging (in my case of timing information) to each custom event - and as part of the code I want to add to LogEventRequest/LogEventResponse, I want to Spark.getLog().Debug some data that I can look at later.   However, what gets added to runtime.log includes the script name of "LogEventResponse" (which makes sense).  However - what I am interested in is the name of the script that actually precedes the LogEventResponse (the script event that was actually called by the client).  


Any thoughts?  


my goal is NOT to go in and touch the source to each custom EventLog script to add functionality if I can help it..




Best Answer

Hi Jeff


You can use Spark.getData().eventKey; to get the shortcode for the script and put that in the log message.


Regards

Katie 


Answer

Hi Jeff


You can use Spark.getData().eventKey; to get the shortcode for the script and put that in the log message.


Regards

Katie 

worked perfect!! 

(I had to pull it out in LogEventRequest and tuck it into player scriptData and pull it out later in LogEventResponse - but I was already doing that for other data)


Thanks for the quick response!!!


I'm interested to get event name in LogEventResponse.

Spark.getData().eventKey does not work.

I wouldn't want to store it in player scriptData to avoid overload.

Is there another solution to pass info from LogEventRequest to LogEventResponse ?

Hi Eric,


You can pass it from the request to the response with the following.

 

//LogEventRequest
Spark.setScriptData("eventKey", Spark.getData().eventKey);

//LogEventResponse
var eventKey= Spark.getScriptData("eventKey");

  

Try that and let us know how you get on.


Regards,

Liam

Hi Liam,


Thanks a lot, was using Spark.getData() instead of Spark.setScriptData();

Login to post a comment