AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY] Player Analytics (https://forums.alliedmods.net/showthread.php?t=230832)

Dr. McKay 12-02-2013 21:33

[ANY] Player Analytics
 
1 Attachment(s)
[ANY] Player Analytics

v1.3.1

Description:
This plugin logs detailed statistics of all connecting players to a MySQL table. Stats that are logged include:
  • Server IP
  • Player name
  • Steam ID
  • Time of connection (as Unix timestamp)
  • Date of connection
  • Connection method (on games that support cl_connectmethod)
  • Number of players in-game at time of connection
  • Current map at time of connection
  • Duration of play session
  • User admin flags
  • User IP
  • Player's city, region, 2-letter country code, and 3-letter country code (requires GeoIPCity)
  • Player's country
  • Player's F2P/Premium status (TF2 only, requires SteamTools)
  • Player's HTML MOTD preference (enabled/disabled)
  • Player's operating system

There will be a web interface later with which you can view the stats. In the meantime, you'll have to use something like phpMyAdmin to see the raw logs.

Cvars:
  • player_analytics_version - plugin version
  • player_analytics_auto_update - enables automatic updating (has no effect if Updater is not installed)

Developers:
Player Analytics has an API with which you can get player connection IDs. See the include file.

Requirements:
Both of these extensions are optional dependencies. That is, they are not required for the plugin to operate.
  • GeoIPCity - Required to look up players' cities, regions, and country codes
  • SteamTools - Required to detect the server's public IP behind a NAT and to look up Premium/F2P status on TF2

Installation:
This plugin requires a MySQL database. It will first look for a configuration named "player_analytics", and will fall back to "default" if one is not found. Example:

Code:

    "player_analytics"
    {
        "driver"            "mysql"
        "host"                "example.com"
        "database"            "example_database"
        "user"                "exampleuser"
        "pass"                "examplepassword"
        //"timeout"            "0"
        "port"                "3306"
    }

This should go in databases.cfg.

Install any optional extension dependencies that you want, and then put player_analytics.smx into /addons/sourcemod/plugins and os_detect.games.txt into /addons/sourcemod/gamedata and reboot your server or type "sm plugins load player_analytics" into your console or rcon.

Auto Update:
Install Updater. The plugin will be auto-updated according to your Updater settings. It'll work without Updater.

Changelog:
  • v1.3.0 (4/3/15)
    • Plugin now uses utf8 queries
  • v1.2.0 (3/31/15)
    • Added plugin API
  • v1.1.0 (12/7/13)
    • Updated OS detection
  • v1.0.0 (12/2/13)
    • Initial release

Download Plugin (player_analytics.zip)

.zip file includes plugin, gamedata, source, and include file

Requires updater.inc and mckayupdater.sp to compile.
______________________________

I have attached a development preview of the web panel. It's still in development so there are a lot of broken links and placeholder items. Simply set your variables in config_example.php and rename it to config.php

Web panel is by rannmann.

Dr. McKay 12-02-2013 21:34

Re: [ANY] Player Analytics
 
The development web panel is very limited, and a community member has taken it on themselves to build on it. You may want to use it:

https://forums.alliedmods.net/showpo...8&postcount=69

ocwoody 12-02-2013 23:18

Re: [ANY] Player Analytics
 
Awesome! Thanks for releasing this!

Dr. McKay 12-03-2013 00:25

Re: [ANY] Player Analytics
 
I've attached a development preview of the web panel to the main post.

Mirandor 12-03-2013 13:08

Re: [ANY] Player Analytics
 
hi,
does or will it store multiple player names?

nomy 12-03-2013 13:18

Re: [ANY] Player Analytics
 
Very useful! Thanks Dr. McKay!

Impact123 12-03-2013 13:28

Re: [ANY] Player Analytics
 
Is there a reason why you connect non-threaded to the database?
In some countries it's not permitted (or atleast it's a grey area) to store dynamic ip's, you might want to add an option to anonymize it.
Some of the columns are a little bit too big (auth and ip for example), sure it makes no big difference, but it sums up for long-term data like this.

matrixmark 12-03-2013 13:36

Re: [ANY] Player Analytics
 
This looks awesome.

Will be giving it a try tonight :D

Dr. McKay 12-03-2013 13:49

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by Impact123 (Post 2068237)
Is there a reason why you connect non-threaded to the database?
In some countries it's not permitted (or atleast it's a grey area) to store dynamic ip's, you might want to add an option to anonymize it.
Some of the columns are a little bit too big (auth and ip for example), sure it makes no big difference, but it sums up for long-term data like this.

SQL_TQuery doesn't support the persistent parameter, and I like to conserve connections. Since it only connects on plugin startup, it won't block the server since realistically plugin startup will only be on server startup.

I find it somewhat questionable that it wouldn't be legal to store the IP address associated with a connection. If that were the case, then SRCDS itself would be in question due to its logs, which are stored indefinitely. If you can provide me a source, I might be able to add an option to not log IPs.

Impact123 12-03-2013 14:07

Re: [ANY] Player Analytics
 
An threaded connection handle stays valid until you close it, persistant connections are kinda default for it.

Dr. McKay 12-03-2013 14:34

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by Impact123 (Post 2068254)
An threaded connection handle stays valid until you close it, persistant connections are kinda default for it.

The persistent parameter tells SourceMod to try to re-use an already-open connection if one exists, eliminating unnecessarily duplicate database connections. When you have many servers, this starts to become an issue.

TnTSCS 12-03-2013 16:28

Re: [ANY] Player Analytics
 
Neat plugin - Thanks Dr. McKay :)

Looking forward for the front end to be all done.

Dr. McKay 12-03-2013 16:48

Re: [ANY] Player Analytics
 
Updated to 1.0.2. Fixed a problem that prevented SteamTools from being properly marked as optional (thanks nomy) and removed some debug spew.

ocwoody 12-03-2013 22:41

Re: [ANY] Player Analytics
 
1 Attachment(s)
Here's a screenshot of the dev web panel if anyone is interested

DrFallen 12-04-2013 00:05

Re: [ANY] Player Analytics
 
Hey great work guys, I've got the panel working but whenever I try to any of the top 4 tabs (users,sessions,connection or audience) it doesnt do anything. If I open in new tab it goes back to the dashboard. Is it supposed to happen for now or is there something I need fix?

cREANy0 12-04-2013 00:32

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by ocwoody (Post 2068404)
Here's a screenshot of the dev web panel if anyone is interested

Looks nice!

Dr. McKay 12-04-2013 00:44

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by DrFallen (Post 2068409)
Hey great work guys, I've got the panel working but whenever I try to any of the top 4 tabs (users,sessions,connection or audience) it doesnt do anything. If I open in new tab it goes back to the dashboard. Is it supposed to happen for now or is there something I need fix?

Quote:

Originally Posted by Dr. McKay (Post 2067976)
It's still in development so there are a lot of broken links and placeholder items.

None of the links work yet.

DrFallen 12-04-2013 00:54

Re: [ANY] Player Analytics
 
Ok thanks for confirming :)

Skyrider 12-05-2013 12:20

Re: [ANY] Player Analytics
 
Awesome! Exactly what i was looking for, the web preview that I've installed so good so far! Can't wait to see the finalized version.

cREANy0 12-05-2013 15:36

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by Skyrider (Post 2068884)
Awesome! Exactly what i was looking for, the web preview that I've installed so good so far! Can't wait to see the finalized version.

+1

Pythong 12-06-2013 10:43

Re: [ANY] Player Analytics
 
FYI I got some errors from the dev. web panel.

For starts, i'm running PH 5.3.10

The config.php had to be edited to include quotes or i received errors
<?php
define('PA_DATABASE_SERVER', 'localhost');
define('PA_DATABASE_USER', 'user');
define('PA_DATABASE_PASSWORD', 'password');
define('PA_DATABASE_NAME', 'player_analytics');
?>

And on the main page i'm getting:
Quote:

Notice: Undefined property: UserSessions::$mTimeAvg in /path/to/data/users.php on line 44


EDIT: I had to add at line 25:
Quote:

private $mTimeAvg;
That fixed the error above.

Dr. McKay 12-07-2013 02:55

Re: [ANY] Player Analytics
 
Updated to v1.1.0. The method by which it detects players' operating systems has been updated. It now requires a gamedata file, which is in the .zip file.

nineteeneleven 12-07-2013 08:24

Re: [ANY] Player Analytics
 
If a player connects twice, does it write 2 logs or overwrite the first?.


edit: it just keeps making logs. Mabye you can provide a cvar for that in the future?

Edi2:actually that's probably not the best idea

nineteeneleven 12-07-2013 10:04

Re: [ANY] Player Analytics
 
Added support for this in Donations Control

https://github.com/nineteeneleven/Donations-Control/

StayOx 12-07-2013 16:09

Re: [ANY] Player Analytics
 
this plugin is very useful ^^, the plugin creates a table with charset utf8, however the charset of querys was not set to utf8

[IMG]http://s29.************/536ght8sn/non_utf8.png[/IMG]

TnTSCS 12-07-2013 18:48

Re: [ANY] Player Analytics
 
Isn't the connect_date not needed since the connect_time has it already?

1386450476 translates to:
Sat, 07 Dec 2013 21:07:56 GMT

Unless it's there to help with front end displaying of data?

Dr. McKay 12-07-2013 19:41

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by TnTSCS (Post 2069793)
Unless it's there to help with front end displaying of data?

That's what it's there for.

Impact123 12-08-2013 13:00

Re: [ANY] Player Analytics
 
PHP Code:

SELECT DATE_FORMAT(FROM_UNIXTIME(connect_time), "%Y-%m-%m"

Same result as connect_date, let the database do the work.

tigerox 12-09-2013 10:53

Re: [ANY] Player Analytics
 
Great plugin, thanks!

Seeing this on our CSGO servers:

Code:

L 12/09/2013 - 01:17:49: SourceMod error session started
L 12/09/2013 - 01:17:49: Info (map "ar_arena_box") (file "errors_20131209.log")
L 12/09/2013 - 01:17:49: [SM] Native "CloseHandle" reported: Handle 25050489 is invalid (error 1)
L 12/09/2013 - 01:17:49: [SM] Displaying call stack trace for plugin "player_analytics.smx":
L 12/09/2013 - 01:17:49: [SM]  [0]  Line 168, D:\Libraries\Documents\Repos\Public Plugins\scripting\player_analytics.sp::OnMOTDQueried()
L 12/09/2013 - 01:17:49: [SM] Native "CloseHandle" reported: Handle 2506048d is invalid (error 3)
L 12/09/2013 - 01:17:49: [SM] Displaying call stack trace for plugin "player_analytics.smx":
L 12/09/2013 - 01:17:49: [SM]  [0]  Line 202, D:\Libraries\Documents\Repos\Public Plugins\scripting\player_analytics.sp::OnOSQueried()
L 12/09/2013 - 01:26:56: Error log file session closed.


Pickles47 12-13-2013 22:58

Re: [ANY] Player Analytics
 
Seeing some errors in my database, sometimes the server IP is not added correctly, filling a server_ip as 0.0.0.0:27015.

Also seeing problems with flags, a few times flags are not added properly. For example, my flags are 'azop' on a few occasions the flags are only 'az'. There are no errors in my sourcemod log file when these occur.

Snaggle 12-21-2013 18:54

Re: [ANY] Player Analytics
 
Is there a rough time of when the panel will be fully available?

Dr. McKay 12-22-2013 01:09

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by Snaggle (Post 2074777)
Is there a rough time of when the panel will be fully available?

Currently, no.

Mirandor 12-22-2013 05:36

Re: [ANY] Player Analytics
 
Quote:

Originally Posted by Mirandor (Post 2068222)
hi,
does or will it store multiple player names?

?

Danyas1337 12-22-2013 05:51

Re: [ANY] Player Analytics
 
Great job, working on css :3
P.S.
Quote:

Demo here!

Pickles47 12-24-2013 10:28

Re: [ANY] Player Analytics
 
https://forums.alliedmods.net/showpo...8&postcount=69

Fearts 12-24-2013 11:53

Re: [ANY] Player Analytics
 
Thanks for the work you did on the interface. One thing I would really like is just to be able to filter each column so I can see who has played the longest and who has the most visits ect. Also a way to get a % for each type of thing. Like the % of people who connect via favorites and such.

StayOx 12-25-2013 17:08

Re: [ANY] Player Analytics
 
1 Attachment(s)
A very simple edit, set query to use utf8
with that player names with special characters are entered correctly in the table :wink:

Pitbull3 01-12-2014 21:35

Re: [ANY] Player Analytics
 
I am having these issues, any way to fix?

Code:

PHP Warning:  gmdate() expects parameter 2 to be long, string given in players.php on line 238
Line 238:
Code:

<?php echo gmdate("G:i:s", "$Total");?>


EDIT::: Weird, idk...but after about 10 minutes it fixed it's self... lol

Pitbull3 01-23-2014 04:55

Re: [ANY] Player Analytics
 
hey I am seeing like.... 50 versions of quickplay_1, 2 ect..... is there a way to combine all of them permanently? I don't want to have to run an sql query each time I want to merge them together...

Dr. McKay 01-23-2014 09:45

Re: Re: [ANY] Player Analytics
 
Quote:

Originally Posted by Pitbull3 (Post 2089812)
hey I am seeing like.... 50 versions of quickplay_1, 2 ect..... is there a way to combine all of them permanently? I don't want to have to run an sql query each time I want to merge them together...

Rewrite your query.


All times are GMT -4. The time now is 18:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.