1.0.4 • Published 5 years ago

simplest-analytics v1.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

An extremely simple self-hosted analytics library.

Currently only supports firebase and mongodb, will add more configurations soon.

Still in development

To install

npm install simplest-analytics -- save

Note that you'll have to sign up for a firebase account in order to use the serverless aspects of module, at least for now. I'm working on making it available on other databases, too.

To start using it.

import SimplestAnalytics, {FirebaseProvider, MongoProvider} from "simplest-analytics";

//Import a provider
let provider = new FirebaseProvider(<YOUR FIREBASE CONFIG FILE/>); //if you want to use firebase
/**OR**/
provider = new MongoProvider({
    page_views_url, //required
    sessions_destination_url, //required
    routes_destination_url, 
    headers
}); //if you want to upload it to your own server

let analytics = new SimplestAnalytics(provider);

analytics.page(); //track a page view
analytics.track("button_click") //track an event

What Problem Does this Solve?

For people with small projects and in need of metrics collection, GA is an overkill.

Google collects a lot of data using analytics, more than anyone can possibly hope to match, and therein lies the source of ambition for this project. The average project doesn't need that much data.

This project is inspired by my specific need for metrics such as page views, unique visitors and bounce rates without having to sacrifice my soul to the devil.

In summary:

  • Most websites don't need as much data as Google provides, or just don't know what to do with it.
  • Using GA (or others) means there's a potential risk for adblockers to block data that would have otherwise proved useful. Of course, small projects feel a bigger pinch than large ones.
  • Serverless hosting using platforms like Netlify is pretty convenient, so what about the same, only for people who either - Don't want to (or can't!) fire up their own servers just to host an analytics project. If you're willing to pay for Serverless functions like Firebase, AWS Lambda or even Netlify in order to avoid the hassle of setting up a server, this project might be for you. - Are able to fire up a server in order to host a simple analytics project. This project also lets you host it yourself if you want, really.
  • Being the owner of a small blog, I don't care much about tracking users, because I do it as a hobby more than anything. I just want to see how my website is being used.

What this project is not meant for

  • Tracking users across the web. Use the dozen or so analytics libraries and platforms already available for that.
  • Collecting personal information
  • Performance monitoring. Or at least not yet.

What kind of data is collected?

  • Device details like OS, height, width, vendor.
  • Browser details like vendor, version, available APIs, etc.
  • No personal information is collected *
    • *Depending on your setup, IP addresses may be collected for unique user metrics

What You Need to Get Started

  • A Firebase account (optional) or a personal vps (also optional) - you need at least one of these though.
  • Familiarity with MongoDB (the only other currently supported DB, other Firebase) - also optional
  • Some decent Javascript skills (required)
  • Familiarity with React, if you need to change anything on the UI - optional

Looking for somewhere to host your project?

Digitalocean is a good place to start.

Inspired By