makesites / apptrack

Application tracking for the client and the server, also available as SaaS
http://apptrack.io
3 stars 2 forks source link

Apptrack

Application tracking that simplifies the process of gathering analytics and avoids convoluted conventions.

The logic is minimal, lightweight, yet can work both on the server and the client, with asynchronous syncing of the client data.

Features

Examples

To run the examples go to the dir and execute the server script

$ cd [repo]/examples/[folder]/
$ node server.js

Dependencies

Install

Using npm

node install apptrack

Usage

When Apptrack is initiated you can pass the selected store, among other options:

Apptrack = require("apptrack");

var apptrack = new Apptrack({ store : "redis", db: db });

The library can operate independently but optionally can be connected to the server using a middleware

// middleware
app.use( apptrack.connect() );

Apptrack automatically serves the client-side javascript from the client route (mentioned in the options below) which, when included in a web page, will create an object named at in the global namespace.

Options

Server

Client

Routes

A top level option that may contain the following sub-options:

Methods

Below are the public methods that are provided for interfacing with the library:

Client

Server

Tracking

To track any event, load Apptrack on the server and optionally include the client-side JavaScipt (default: /apptrack.js) in the HTML page. You can call the method log available from both ends of the application stack, with a keyword for the action and any parameters attached to it.

.log(action, params);

Action

An action can be any arbitrary string, but you should treat is as an identifier label. To be able to group events you should use the same action keyword.

Params

The library does not try to define the structure of the parameters - it is left schema-less for simplicity, allowing the developer to send arbitrary data along with any action.

In addition to the above, Apptrack also stores if provided:

Session

An object defining user data (ex. email, id etc.) to identify the source of the log

Headers

Request headers passed during the log event. This is mostly to record authenticity data and other metadata (ex. browser, location etc.)

Credits

Initiated by Makis Tracend ( @tracend )

Distributed through Makesites.org

Thanks

Inspired by the analytics app by @srivastavarobin

License

Released under the Apache license, version 2.0