skycap-client

server side library for skycap tracking server

Usage no npm install needed!

<script type="module">
  import skycapClient from 'https://cdn.skypack.dev/skycap-client';
</script>

README

Skycap Client

A simple client to send requests to a skycap server. Meant to for tracking stuff on the server side and sending into skydb. This is pretty much taken byte for byte from skycap's client side js with minor modifications for making it node-y.

Very much WIP and lots to fix/finalise/do, namely:

  • add cli/repl
  • write tests
  • tidy up client

Known to work with skycap/skydb v2.3

Testing

None yet, but Works On My Machine verified

Stability index

Stability: 1 Experimental

The API and code are likely to change/evolve as the skydb and skycap themselves change.

Installation

npm install skycap-client

API

Pretty much like the original skycap client, see the examples below.

skycap.createClient(options)

Returns a new instance of a client, currently options has to be an object and only notices one key, host, whose value should be the URL of the skycap server to send the tracking data to.

client.identify(identifier, [data])

This method identifies a user and associates user-level state with them. For example, you may want to identify the user by an email address or id from your datastore.

The data object represents state about the user itself. This could be their name or whether they are a paid user. User-level data is data that changes over time and exists outside the context of an action the user is performing.

client.track(action, [data], [callback])

This method tracks a specific action that has occurred. This could be the web page that the user is on or it could be a link that is clicked.

The first argument is the name of the action. The second argument is action-level data. Action-level data is any data that exists only within the context of this specific action. For example, a purchase action could have purchase_amount. An optional callback function may be supplied which gets 1 arguments, err, in the event of their being an error making the tracking call

Examples


var skycap = require(skycap-client);

var options = {host: "http://skycap.example.com"}
var client = skycap.createClient(options);

client.identify('user-101', {entryPoint:'web', accId:'8172635'});

client.track('did stuff', { thing: 'some-value' }, [callback]);

client.track('purchase', {amount: 1256}, [callback]);

client.track('beep-boop', { volume: 11}, [callback]);