@putdotio/pas-js
v3.0.3
Published
Browser analytics client for the put.io Analytics System.
Readme
Installation
npm install @putdotio/pas-jsQuick Start
import createPasClient from "@putdotio/pas-js";
const pas = createPasClient();
pas.identify({
id: "42",
hash: "signed-user-hash",
properties: {
plan: "pro",
},
});
pas.track("transfer_completed", {
transfer_id: 123,
});Browser Tracking
The client keeps an anonymous identifier in a browser cookie and sends identity, event, and page-view payloads to PAS:
import createPasClient from "@putdotio/pas-js";
const pas = createPasClient();
pas.alias({ id: "42", hash: "signed-user-hash" });
pas.pageView();Requests queued for retry are stored in a cookie and replayed on the next initialization. The queue keeps at most the 20 most recent requests within 3000 bytes of percent-encoded JSON: a request too large on its own is discarded, and the oldest are dropped when either bound is reached. Malformed queue entries are discarded on initialization.
API
| Method Name | Parameters |
| :----------- | :----------------------------------------------------------- |
| alias | ({ id: string/number, hash: string }) |
| identify | ({ id: string/number, hash: string, properties?: object }) |
| track | (name: string, properties?: object) |
| pageView | - |
Docs
License
This project is available under the MIT License
