Web service statistics

I need to add some statistics and have two goals here:
Goal 1: Mark the time of the last completed data upload. I would like to report the time (in seconds) since the last completed upload (in the footer of the dashboard). We have some users with network issues and I wish to confirm that the page is actually updating properly.
Goal 2: Report the HTTP load time for the page data. This should be less than one second, but I wish to confirm it.

As a result of these goals, I need to store (1) the time that the web-service update started and (2) the time the update completed. I plan to store these values in dataslots. I have tried to do this but have two issues:

  1. I do not know the entry point in the GenericJSON_ReactStudio.plugin where the update process is initiated at the beginning of each update.
  2. I have found the entry point for completion of the load (readDataSheetFromServiceAsync) and put console.log statements there, but I do not believe this method is being called, since I do not see any reports to the console in the Chrome Dev Tools console.
    Do you have recommendations where to put this code?

I tried the following code in the Transformation script of a text block, but the value I am seeing reported is only 0.015-0.019sec, which is clearly wrong, since it should be around 10 seconds:

const old_time_str =this.props.appActions.dataSlots.ds_time_of_last_update_msec;
const old_time_num =parseFloat(old_time_str);
const now_time_num = Date.now();
const delta        = (now_time_num - old_time_num)/1000.0;
const text         = `Time since last update = ${delta.toFixed(3)}s;`
const now_time_str = now_time_num.toFixed(3)
// Note: assigned value directly (instead of updateDataSlot()) to avoid infinite loop
this.props.appActions.dataSlots.ds_time_of_last_update_msec = now_time_str
return text;

Hi Kevin,

readDataSheetFromServiceAsync is called in React Studio when data sheet is loaded, e.g. when you press Reload data from service -button in the data sheet editor. It’s not written to the exported project.

GenericJSON_ReactStudio.plugin/Contents/Resources/templates-web/DataSheetLoad.js file contains the actual update code written by writeReactWebCodeForDataSheetLoad method in Main.js.


Thank you!! I will try that.

Okay. That helps alot. I’m slowly starting to get the way the template code works.