Git Product home page Git Product logo

browser_details's Introduction

Browser Details

Have you ever had the conversation:

Your site doesn't work.
What browser are you using and do you have Javascript enabled?

What's a browser?
๐Ÿ˜’

Browser Details makes that problem disappear by capturing a user's browser details in your logs. You will get the exact browser version they are using and their OS dumped into your logs, and when possible you'll get whether they have JS enabled too. All entirely unobtrustively.

You may never need to speak to a user ever again!

Before

Started GET "/" for 127.0.0.1 at 2012-12-26 21:25:14 +0000
Processing by HomeController#index as HTML
...
Started POST "/posts" for 127.0.0.1 at 2012-12-26 21:25:19 +0000
Processing by PostsController#create as HTML
...

After

Started GET "/" for 127.0.0.1 at 2012-12-26 21:25:14 +0000
Chrome 23.0.1271.95 (Macintosh, Intel Mac OS X 10_7_5)
Processing by HomeController#index as HTML
...
Started POST "/posts" for 127.0.0.1 at 2012-12-26 21:25:19 +0000
Chrome 23.0.1271.95 (Macintosh, Intel Mac OS X 10_7_5), JS enabled
Processing by PostsController#create as HTML
...

How?

Browser Details is a Rack Middleware that logs information about the browser used to make a request. When possible this includes whether the browser has Javascript enabled or not.

Installation

Add this line to your application's Gemfile:

gem 'browser_details'

And then execute:

$ bundle

Or install it yourself as:

$ gem install browser_details

Rails

The middleware will be installed automatically by the Railtie.

To enable Browser Details to report whether the browser has Javascript enabled for form submissions you must add the following line to your app/assets/javascripts/application.js:

//= require browser_details

Browser Details requires jQuery to be present as it works by checking if the utf8 form element has been changed to a large tick from a small tick by the Browser Details Javascript.

If this script is not added then all browsers will report that Javascript is disabled.

Other Rack applications

To use the Browser Details middleware you must add the line:

use BrowserDetails

Wherever it may be appropriate for your application.

The Javascript detection is currently reliant on Rails. If you would like your application to be able to detect whether Javascript is enabled too, please create an issue, or even better open a pull request.

Custom usage

If you want to use the message elsewhere, you can request the message directly:

details = BrowserDetails.message(request)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

browser_details's People

Contributors

gshutler avatar sunny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.