Sessions in Azure Application Insights - azure

I have spent several hours reading various articles on Azure Application Insights (AAI). I'm trying to determine how AAI determines what a session is and where I can find a count of unique sessions (first time visitors) vs. returning visitors. Actually, I know where to find a count of unique sessions but I don't see where I can find a count of returning visitors.

Application Insights defines session as a period of time between the first and the last telemetry item with the same session ID. Session IDs are generated by the various flavors of Application Insights instrumentation code running in the applications. For example, in web apps this is done by the JavaScript code running in a browser and automatically tracking page views.
In particular, the JavaScript code generates a new session ID when the browser loads a page for the first time. This session ID is reused for as long as any telemetry items (page views, events, etc.) are tracked by the app within 30 minutes. If no telemetry is tracked in 30 minutes, it assumes user stopped interacting with the app and the session expires. When telemetry tracking resumes after the timeout, a new session ID will be generated indicating beginning of a new user session.
To analyze the number of returning users, you can chart "Users (Unique)" and "New Users (Unique)" metrics as described here.

Related

When is the ideal time to store user session data for e-commerce platforms such as products viewed?

We have a an ecommerce platform where we need to store user session data in a database such as products viewed and products liked. When is the right time to call an API to store this data?
I don't want to call an API every time they open a new product.
I've experimented with DOM methods such as visibilitychange but on our website, every product is opened in a new tab so it's not ideal.
Should we use some background scripts such as service workers?

PHP + MySQL + Socket.io - Realtime online status of friends

I have created a realtime chat application similar to facebook using PHP/MySQL and node.js (socket.io) but i am now facing the following problem.
Scenario The logged in user has a list of friends similar to facebook and when any of his friends becomes away, offline, online etc. i would like his friends list to be updated with this in realtime without reloading the entire friends list with for example ajax polling every x seconds.
Every action the logged in user makes on the website like for example the change of page, new chat window, search or whatever i have a column named last_active that updates with the current unix_timestamp.
This is done to keep track of the user being online or away. If the timestamp is bigger than 300 seconds the user i away.
Every thirty seconds the database updates the column last_online with unix_timestamp for the logged in user.
This is done to keep track of the user being online. If the timestamp is bigger than 35 seconds we can assume he has closed the window and will be seen as offline and not away.
The user can also set his online status manually to busy, invisible etc. and this is set to the column custom_status for the logged in user.
Everything above is working as it should provided that the user always reload the page to see what online status his friends have but i would like this to be updated in realtime and not when reloading the entire page or using ajax polling to reload the entire friends list.
I was thinking about comparing the current online status on the client side and when a change occurs emit this to socket.io. I then loop through all connected clients and emit the users new online status to all connected friends.
But i guess there will be performance issues with this when say for example 1000 users are connected?
How would you handle this?

How to track last login date for IBM Domino web user?

Does IBM Domino track the last login date for web users(UserName/Password and internet certificate)? I know the access logs contains this information but wanted to know if there may be something built into Domino (maybe in Address Book). Trying to come up with a method to disable web accounts that have not accessed a domino server in a specified time period.
Thanks,
Kev
The User Activity area in the Database Properties picks up from the log.nsf, which is where this information is stored. But, typically, the log.nsf will only have a few days' worth of information. When I've had this requirement before, I've manually captured it via a custom login page or an initUser function I've had in applications.
One of the easiest solutions is to trigger an action from a live web page that generates a database.nsf?openagent event.
like:
or
Ideally you've use the openagent to print a content type and a response, but if you don't browsers do pretty well with invalid responses from servers.
inside your "myagent" you will have the users name available to you to write it to a document.
Your next challenge will be in getting the agent to trigger, but, not too often, ideally only on login.
When a user uses a custom login form it submits the username/password and redirection url in POST method. You could change that to ...?openagent&nexturl=/blablabla.nsf
Your tiny little agent would run one and only one time upon login and update a document in a your custom logging database.
That's a developer's solution.
There are also admin solutions. The server does keep track of active web sessions, but, it does not drop them into the log.nsf like it does upon session ending for a notes session. I don't think it would be too much work from an admin standpoint to get that information there are a lot of event triggers available to you. It's just been way too long since I worked on any server that anyone cared about statistics.

Spotfire Web Player force new session

How does one force a new session in the web player?
I am tiling multiple analyses (6) in a web page with iframes, and sometimes (50/50) all but one error out seeming to grab the same session as the one that succesfully loads. In theory if i can add a url parameter that says 'new session' i can force 6 distinct sessions.
Error:"The requested analysis is not loaded on the server. The
analysis with id 'a4afc9575f43c2046c4c1- 281400259cfe04' is not found
in session 'jxqmqvizv5zxoyvhulnj3nmh' in application instance
'281400259cfe04'. This may indicate that the server has been
restarted. (For additional information see server log file or supplied
detailed message). "

Time based notifications service

I am dealing with subscriptions where a user is subscribed to a plan and it has an expiration.
So basically each user store has an expiration field.
I want to be able to get notified when a user plan is expired as soon as it is actually expired.
Right now, I have a job that runs on all users once a day and check if anyone has expired but ideally I would like to get a server postback or some sort of event whenever a user is expired without running this each day.
Can you think of any third party service / database / other tool that deals with these sort of things ?
A lot of services, Stripe for example, notify you with a webhook whenever a user's subscription is renewed / expired. Are they just running a job repeatedly like I am ?
Hope I made myself clear enough, would appreciate help in how to focus my search in Google as well.
My current stack is Mongodb, Node.js, AWS
Thanks
We do not know for sure, how Stripe handles it.
There are two solutions coming to my mind. Let's start with the simple one:
Cronjob
As you mentioned, you already have a Cronjob solution, but you can instead make it run each hour, or each 10 minutes. Just ensure you optimize your query to the maximum, so that it is not super-heavy to run.
It is attractive, easy to implement, very few edge cases, but as you might have though can be a performance drag once you reach millions of clients.
Timers
Implementation varries, and you need to worry about the edge cases, but the concept:
On day start* (00:00) query for all clients who are set to expire today, save them into array (in-memory). Sort the array by time (preferably descending).
Create timer to execute on last array's element time.
Function: If Client X expires now, query database to ensure subscription was not extended. Notify if it wasn't.
Remove Client X from the tracked array. Repeat step 2.
On day start* - Also run it on script launch.

Resources