cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How to monitor users' time spent on thingworx

Willie
16-Pearl

How to monitor users' time spent on thingworx

I am trying to track how much time users spend on thingworx.  It is kind of like how this PTC community portal tracks how many minutes each user spends here.

Thingworx - 2021-05-09 - PTC Community total minutes online.PNG

I have a couple of subscriptions that tracks when a user logs in and when a user logs out.  It updates a property called trueLastConnection, when the following "SecurityMonitor" events occur:

  • LoginSucceeded
  • Logout

Thingworx - 2021-05-09 - LastConnection related subscriptions.PNG

In the subscription called "UpdateTrueLastConnectionLogout", I have the following code:

 

var currentDate = new Date();
Users[eventData.user].TotalMinutesOnline = Users[eventData.user].TotalMinutesOnline + ((currentDate - Users[eventData.user].trueLastConnection)/60000);
Users[eventData.user].trueLastConnection = currentDate;

 

 

This subscription is triggered by the "SecurityMonitor" event called "Logout".

I expected it to update the user property called "TotalMinutesOnline"; however, I noticed that it only works if the user actually clicks on the logout button.  If the user closes the tab or browser, it seems the "TotalMinutesOnline" property does not get updated.  Is there a way to check how much time a user spends on thingworx?

3 REPLIES 3
Jimwang
14-Alexandrite
(To:Willie)

@Willie , refer to below article CS337758, currently Thingworx can get login/logout history, not the total online time:

https://www.ptc.com/en/support/article?n=CS337758

Willie
16-Pearl
(To:Jimwang)

Forgot to mention that I have added the properties called "trueLastConnection" and "TotalMinutesOnline" to the "UserExtensions" Thing Shape.  I am using the subscriptions mentioned in my previous post to update these properties.

 

In the article, it states, "Currently ThingWorx does not log any session timeout activities."  If an event for user session timeout were available, I would be able to log users minutes online.  Is this something that will be available in the future?  Or is there a way to somehow get the time when a user session times out?

 

 

 

Jimwang
14-Alexandrite
(To:Willie)

To request this functionality, I suggest to submit an idea at PTC Community refer to article CS67713 so that Product Manager Team evaluate the feature and consider to add it in a future release.

Top Tags