Skip to content

matteolobello/minimalytics

Repository files navigation

Minimalytics

A minimal, on-premise, server-side solution for saving basic info about your users.

What the library logs

  • Anonymized IP of the client
  • The timestamp of the visit
  • The country of the request

What you need

  • A MongoDB instance
  • An Express-based Node.js app

Install

You can get Minimalytics via npm

$ npm install minimalytics

Usage

Simply import Minimalytics and call the init method. You should call this method right after creating the Express app instance:

Minimalytics.init({
    express,
    mongoose,

    // The credentials to access to the dashboard
    username: "test_user",
    password: "test_pass",

    // The name of the MongoDB collection
    collection: "visits",

    // Optional
    // Consider a new visit valid for an IP
    // only after this amount of time
    // Default: 1 minute
    deltaMs: 60 * 1000,

    // Optional
    // Include only selected request paths
    // Default: all paths are valid
    validPaths: new Array<string | RegExp>("/home", "/support", new RegExp("/sample/")),

    // Optional
    // Enable console logs. Should be disabled in production.
    // Default: false
    debug: false
})

Screenshot

Minimalytics Screenshot

About

A minimal, on-premise, server-side solution for saving basic info about your users

Resources

Stars

Watchers

Forks