antonioribeiro / tracker

Laravel Stats Tracker
MIT License
2.89k stars 596 forks source link

Don't consider specific user-agents and robots to be online users [feature request] #232

Open Nemoden opened 7 years ago

Nemoden commented 7 years ago

By default, Tracker writes a session to tracker_sessions.

I've created a simple route as follows:

Route::get('/test/', function () {
    return Tracker::onlineUsers()->count();
});
$ curl http://localhost:8000/test/
1

$ curl http://localhost:8000/test/
2

$ curl http://localhost:8000/test/
3

$ curl http://localhost:8000/test/
4

This is rather undesired behavior because we create sessions for all kinds of robots which should not to be considered online users.

I think a better solution is to not create sessions for robots. What do you think?

pxpm commented 7 years ago

This is indeed a must have feature. Maybe the best way to address this issue is having an "exclude" list wich will prevent the tracker from counting them as "users". Maybe for a quick fix you can set an array of "unwanted" user-agents in config file and check if user-agent in_array before tracking (can be in the middleware where you start your tracking?). This is a workaround until @antonioribeiro decides if this feature is a must have in base package.