Custom Data Source - request and response timings

Closed
Sengupta asked on October 22, 2021

Hi there
My understanding is Flexmonster calls customizeAPIRequest just before the request is sent to the server.
Is there something equivalent when Flexmonster receives a response from the server?
The reason is we want to know how long it takes for FM API calls to make a return trip. So that we can isolate the bottleneck responsible for the application to slow down. 
Is there some kind of tracing/logging in Flexmonster? That might be an quick solution.

5 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 22, 2021

Hi,
 
Thank you for raising this support ticket.
 
We suggest checking out the following JSFiddle: https://jsfiddle.net/flexmonster/hpmdzo1j/. It features the "proxy" function responsible for receiving requests and returning responses from Flexmonster. It uses simple Ajax calls to reach the server. You can add any desired logic within this function. For example, the mentioned JSFiddle displays time in milliseconds spent on each request.
 
Alternatively, use the Network tab of your browser developer tools to get detailed insights about the time spent on each request made by Flexmonster.
 
Please let us know if it helps.
Feel free to contact us if additional questions arise.
 
Kind regards,
Illia

Public
Sengupta April 21, 2022

Hi Illia,
Following your code https://jsfiddle.net/flexmonster/hpmdzo1j/, how do I handle the error?
error: (xhr, status, error) => {
...
...
...
done(xhr, status, error); // Is this correct?
},

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster April 22, 2022

Hello,
 
Thank you for contacting us.
 
To handle the error, make sure you have added the third argument to pivotEndpoint function:

function pivotEndpoint(requestStringified, done, errorHandler) {
// ...
}

Then you can customize the error, for example:

error: (xhr, status, error) => {
   // ...
   errorHandler({
      message: "status: " + status + "\nmessage: " + error
   });
}

You are welcome to check the updated JSFiddle for reference: https://jsfiddle.net/flexmonster/hpmdzo1j/14/ 
 
Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster May 2, 2022

Hello,
 
Hope you are doing well.
 
We were wondering if you had a chance to test a suggested approach. Could you please confirm if it works well for you?
 
Looking forward to hearing your feedback.
 
Kind regards,
Nadia

Public
Sengupta May 3, 2022

@Nadia 
Yes, it's working. Many thanks
Regards
Anirban

This question is now closed