Thank you for this module. I was precisely looking at ways to get the user agent in the access log and came across your piece of work. Brilliant!

Let me drop some food for thought: the Browscap module provides a way to get more information on browser capabilities out of the user_agent string. Also, it allows for logging some hit statistics based on the browsers/crawlers visiting.
Statistics (or, now, Better statistics) + Browscap give quite some overhead as each module writes its own data to the db.
Now with useragent in the accesslog it would be possible to disable Browscap's logging and get all statistics from accesslog only.

Here comes the question - would it be possible to somehow integrate with the browscap_get_browser() function so that in views we could get fields for single properties of the browscap array, so to use them instead of the full useragent string??

Let me make an example:

browscap_get_browser('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0');

would return

Array
(
    [comment] => Firefox 15.0
    [browser] => Firefox
    [version] => 15.0
    [majorver] => 15
    [minorver] => 0
    [platform] => MacOSX
    [platform_version] => unknown
    [alpha] => 0
    [beta] => 0
    [win16] => 0
    [win32] => 0
    [win64] => 0
    [frames] => 1
    [iframes] => 1
    [tables] => 1
    [cookies] => 1
    [backgroundsounds] => 0
    [javascript] => 1
    [vbscript] => 0
    [javaapplets] => 1
    [activexcontrols] => 0
    [ismobiledevice] => 0
    [issyndicationreader] => 0
    [crawler] => 0
    [cssversion] => 3
    [aolversion] => 0
    [parent] => Firefox 15.0
    [useragent] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0
    [browser_name_pattern] => Mozilla/5.0 (*Mac OS X*)*Gecko/*Firefox/15.*
)

could I have a separate field for 'ismobiledevice', 'browser', 'version', 'crawler', etc. so to be able to filter/sort out of each of these?

Cheers

Comments

iamEAP’s picture

Wonderful idea. Could be as simple as exposing those values as fields in the better_statistics_views_data_alter() call and wrapping it in an if (module_exists('browscap')).

If you're able and willing, feel free to post a patch. Otherwise, I'll have some time to work on this later in the week.

Thanks for the suggestion!

mondrake’s picture

Hi

I never used Views API, so a bit lacking on ability :) ... but if you have a go I'll be very willing to review and test a patch. Thanks

iamEAP’s picture

Status: Active » Closed (won't fix)
StatusFileSize
new5.24 KB

After digging into this a bit, 100% seamless integration isn't going to be possible without making additional schema changes.

The problem is that it's impossible to filter, sort, or group by e.g. browser/platform, because we're just teasing those values out of existing data; no way to directly filter/sort/group at the DB level.

While I think Browscap is a great candidate for additional fields to the accesslog table, I think a better idea is to make a sort of statistics API that allows any module to add their own fields to the accesslog. I have thoughts on this, but I'll create a separate issue.

I'm going to mark this as "won't fix," but post the patch I came up with for reference.

iamEAP’s picture