Giter Site home page Giter Site logo

andersonba / whoami.js Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 1.0 972 KB

A simple and lightweight browser detection and logger library

Home Page: http://andersonba.github.io/whoami.js

License: MIT License

JavaScript 100.00%
logging browser user-agent detection whoami

whoami.js's Introduction

whoami.js

A simple and lightweight browser detection and logger library.

Codeship Status for andersonba/whoami.js

See demo page

Usage

// initialize whoami
var me = new whoami( [options] [, callback] );

// capture
me.execute();

The callback argument gets a data object with all catched informations.

Configuring whoami to communicate via API

// initialize whoami
var me = new whoami( urlApi [, options] [, callback] );

// capture
me.execute();

The callback argument gets 2 arguments:

  1. An error when applicable (usually from XHR request)
  2. A data object

See a server example using express.js

Options

name type default description
basic boolean true Basic browser informations (document title and url, user-agent, resolution, origin url and time)
console boolean|object false Catch all console output. You could customize which method will be subscribed using options, eg.: {warn: true, log: false}
context object {} Set application context, like as userId, userEmail, etc
cookie boolean false Catch all cookies from domain
error boolean false Catch all exceptions raised on the page
functions object {} Execute custom functions on capture and catch the return values. The functions could be sync/async using callback. You could create feedbacks prompts, check a ping using XHR request, etc
localStorage object false Catch all the localStorage data from domain
screenshot boolean false Capture a screenshot using the html2canvas. It will returns a Data URI containing a representation of the image in jpg format
sessionStorage boolean false Catch all the sessionStorage data from domain
shortcut boolean true Bind the Ctrl+0 shortcut on keyboard to execute whoami.execute()

Thank You

With special thanks to BrowserStack for providing cross browser testing.

whoami.js's People

Contributors

andersonba avatar ernestorocha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ernestorocha

whoami.js's Issues

Demo configuration component

Create a composition component using checkbox to test selected filters on demo page.
Also, after click button or shortcut, print the output in textarea.

Catches configuration

Use object configuration to enable/disable filters

Example:

whoami({
  filters: {
    screenshot: false,
    localStorage: false,
    cookies: true
  }
});

Ignore unknown filters

Currently, breaking the execute command when enter a invalid filter in instance options

Tasks runner (beta)

Catch routine tasks output (javascript functions)

Example:

whoami({
   filters: {
     tasks: {
       browserTime: function() {
         return +new Date();
       },
       apiIsLive: function(done) { // async
         fetch('/api/healthCheck')
           .then(function(response) {
             done(response.status === 200);
           });
       }
     }
   }
});

output:

{
  "tasks": {
    "browserTime": "144120312812",
    "apiIsLive": true
  }
}

Create UI

  • Use Loading spinner
  • Replace prompt by component
  • Replace alert by component

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.