Skip to main content

Hi everyone,

 

My system is RESTful API, we have developped a SPA (Single Page Application) that use these APIs and some users are calling directly our APIs without using the SPA.

 

I don’t know where should I put the logging to Amplitude on the SPA or on the API?

Should I log also the read operation or only the write operation?

 

Thanks for your help!

Johnny

Hey @JohnnyMax 

The ideal approach would be to instrument both the events ( SPA and API ) and have an event property (e.g source = ‘SPA’ vs source  = ‘API’ ) to identify your system usage better.

Assuming the SPA can be instrumented using JS SDK and the API events using the HTTP API.

Let me know if I have interpreted your use case correctly. Hope this helps.


Hi Johnny,
 
I always think it's best to keep a log of as much as possible so I would log both operations, their payload and any relevant data for future reference, if needs be. Unless I am misinterpreting too, I agree with Saish here! I would have an EP that would state whether it is from the SPA or the APIs. I would also instrument the JS SDK on the SPA (or any relevant SDK such as Java, perhaps!). You can then determine from which "side" the events come from, API or SPA. 
 
I hope this helps! If you need more help or I misunderstood, do let me know and I will be here to help!


Reply