0.0
No release in over 3 years
BrowserSense logs information about the browsers accessing your RubyOnRails app. Data can be easily extracted from the log, analyzed with the included script or with the log_sense gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 6.2.0
 Project Readme

BrowserSense

Log information about the browsers accessings your Rails application.

Installation

BrowserSense monitors which browser is accessing your Ruby on Rails app.

Add the gem to your application’s Gemfile and then bundle:

gem "browser_sense"
bundle

To enable logging, add browser_sense to the application_controller.rb of your app, i.e.:

class ApplicationController < ActionController::Base
  [...]

  include BrowserSenseFilter
  browser_sense

  [...]
end

Data logged

Each invocation of a route of your application generates a line in the log storing the following details:

  1. Browser name
  2. Platform
  3. Device name
  4. Controller being invoked
  5. Method of the controller being invoked
  6. Request format (e.g. html, json)
  7. Hashed IP, which allows to track requests from the same IP, while preserving privacy
  8. Timestamp

Information is stored in the application log, each line prefixed by BrowserSense and data presented in CSV.

Example

$ cat production.log
[...]
BrowserSense: "Firefox","linux","Unknown","Devise::SessionsController","new","12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0","2022-06-09T10:08:09+02:00"
[...]

Analyzing Data

When you want to analyze data, extract the information with:

grep BrowserSense production.log | cut -f2- -d: > data.csv

and then, e.g., open the resulting file in a spreadsheet.

There is also a ruby script browser_sense. The script takes as input the pathname of the file with the log and prints to stdout the result of various analyses. The script is a quick hack, wrapping sed, grep and miller (Miller), which must be installed on your machine for the script to succeed.

If you want more reports and plots, you can use the log_sense gem (https://rubygems.org/gems/log_sense), which understands the data generated by this gem.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org

Contributing

TODO

Changelog

./CHANGELOG.org

Authors and Contributors

Shair.Tech

Known Bugs

We have been running BrowserSense for quite a few years with no particular issues. There are no known bugs; there is an unknown number of unknown bugs.

You are most welcome to report issues and missing features, using the Issue tracker.

License

The gem is available as open source under the terms of the MIT License.