php - Symfony2 count visited sites per user -


I'm trying to count how many pages the user visited during their login.

I have created a service that is listening to the kernel :: termininate event that goes to a user at another site at all times System

class ActivityListener applies EventSubscriberInterface {Personal $ principle; Private $ session; Public function __ composition (Registry $ principle, session $ session) {$ this- & gt; Theory = $ principle; $ This- & gt; Session = $ session; } Public stable work receiving memberships () {Returns array (kernel events :: Terminatet = & gt; Increase PageGrak '); } Public Function Increase Page Count () {$ em = $ this- & gt; Theory-> GetManager (); $ Log = $ em- & gt; GetRepository ('bundle: userlog') - & gt; Search (array ('sessionId' =>> $ this-> session-> getId ())); If ($ log) {$ log = $ log [0]; $ Log- & gt; IncreasePageCounter (); // The number of jobs in the unit increases by $ em- & gt; Continues ($ log); $ Em- & gt; Flush (); }}}

The code will be called, which is fine, but up to 10 times the change per page, which is obviously too much!

I also tried the kernel :: request event, but with the same result.

What can I do that it only increases PageConverter once, new page request? (For example, the user gives a specific bill details from the billing overview)

kernel: : VIEW is removed when the controller action response is returned. If you want to track users reaching from one scene to another, this is your best bet.

See also

Of course it is also removed if you have a JSON Response in some Ajax call or you can redirect one, then all responses are removed. Not only render you can filter it through the request though.

In addition, I really suggest not to user tracking in Symphony. Tools like Piwik are a good API where you can create a good profile for users and track them. There is also a symphony bundle for Piwik, it is not sure whether it is still maintained or works


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -