Sourav Das Sourav Das - 1 year ago 78
Javascript Question

How to Log User Experience in Angular/Ionic Mobile App with SQL Server

I am developing an Ionic Application and i want to know which users logged in, which views they went and what errors they faced.

I implemented the same in the .NET Application using NLog. Is there any way in Javascript to post entries in SQL Server or what are the alternatives.

PS: Tried Google Analytics but it is very slow in updating. I need a real time solution for simple usage.


Answer Source

There is not a straight forward answer to your question.

Ionic/Angular are front-end applications which generally make calls to exposed endpoints, which in turn, communicate with the database, in your case SQL.

My suggestion:

1) Setup an endpoint on your backend and write some simple logic to accept a message (error msg, which user is logged in, event that happened) to be written to the database.

2) Create a factory/service that will make an aJax call to that endpoint (you'll need to pass your message to this factory from the UI)

3) Use something like $log in Angular to pass the message you want to database to the factory.

You cannot simple hit SQL from Angular and honestly, it is a really bad idea (if you could).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download