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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to trigger a custom event every time a user accesses ThingWorx

SrijithKrish
12-Amethyst

How to trigger a custom event every time a user accesses ThingWorx

Hi Team,

 

Hope everyone is doing well.

 

I would like to know how will I throw my custom event each time a user logs in and logs off ThingWorx.

 

Thanks in Advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @slangley 

 

Thank you for the response. The current implementation uses a scheduler that monitors the number of users logged in and compares with the users before in a particular interval. This implementation is working currently.

 

Thank You @BABA-SHYAM those events are very useful I had tried them but the problem was during logging out, there will be users who might not log off in the required manner.

View solution in original post

11 REPLIES 11
slangley
23-Emerald II
(To:SrijithKrish)

Hi @SrijithKrish.

 

Are you referring to a user logging in to Composer or a mashup?  If you're referring to a mashup, you could design a service to run each time the user logs in.  Logging out would be more difficult since it requires a user to logout elegantly instead of just closing the browser.

 

Regards.

 

--Sharon

@slangley , main requirement is to keep track of all the users that are accessing Thingworx within a day (both via composer as well as mashup application), that is I would require to keep history of this data. Currently I am able to see how many people are using but not the history.

Is this requirement possible within ThingWorx?

slangley
23-Emerald II
(To:slangley)

Hi @SrijithKrish.

 

Another way to capture successful/unsuccessful logins is to turn up the logging level (we think it's debug).  This will capture information in the security log, but with the logging level set this high, you will have an increase in the number of logs requiring more disk space and overhead.  It will also make it more difficult to research issues due to the size of the logs.

 

The "LoginSucceeded" event is also something that can be used as stated by @BABA-SHYAM but doesn't address logout.  Is that enough for your use case?

 

Regards.

 

--Sharon

BABA-SHYAM
14-Alexandrite
(To:slangley)

Hello,

 

Security monitor do address all these scenarios. See below image.

BABA-SHYAM_0-1619709048951.png

Regards

Shyam

slangley
23-Emerald II
(To:BABA-SHYAM)

Hi @SrijithKrish and @BABA-SHYAM.

 

A lot of users simply close their browsers instead of logging out, which means their session will time out. That's the scenario that would be difficult to address.

 

Regards.

 

--Sharon

BABA-SHYAM
14-Alexandrite
(To:slangley)

Sharon,

 

That is correct. but his question clearly states that he want to run custom event every time user either logs in or visit a particular mashup. So Security Monitor will help him perform this action.

 

Regards

Shyam

BABA-SHYAM
14-Alexandrite
(To:SrijithKrish)

Hi,

 

There is a security monitor thing (don't select template with same name) available in thingworx. There you will find a "LoginSucceeded" event under it. This event will work if your user is login by typing the credentials. There is another event available "ApplicationKeySucceeded " if user try to access thingworx using app key. Every time this event occur you can run a custom event.

 

Regards

Shyam

slangley
23-Emerald II
(To:SrijithKrish)

Hi @SrijithKrish.

 

Have you found a solution to your issue?  If so, we would be happy for you to post it here for the benefit of others in the community.

 

Regards.

 

--Sharon

Hi @slangley 

 

Thank you for the response. The current implementation uses a scheduler that monitors the number of users logged in and compares with the users before in a particular interval. This implementation is working currently.

 

Thank You @BABA-SHYAM those events are very useful I had tried them but the problem was during logging out, there will be users who might not log off in the required manner.

BABA-SHYAM
14-Alexandrite
(To:SrijithKrish)

Hi,

 

What is the role of those users? I don't think any such issue could happen while logging out the user. User logs out successfully right? Its only the trigger which doesn't run. Is it happen always? Did you try to debug the issue?

 

Regards

Shyam

@BABA-SHYAM I did not try to debug more as it was to be provided asap. Currently, the implementation is as I mentioned previously and I am debugging it from my end in the background.

Top Tags