npm install @putdotio/pas-jsimport 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,
});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();pageView sends the page's origin and path, its utm_source, utm_medium,
and utm_campaign values, and only the origin of the referrer. Nothing else
from either URL is sent, so search terms in them stay out of PAS. When the path
itself carries something PAS must not store, such as a username or an invite
code, pass the path to send instead:
pas.pageView({ path: "/files/user/FILTERED" });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.
| Method Name | Parameters |
|---|---|
| alias | ({ id: string/number, hash: string }) |
| identify | ({ id: string/number, hash: string, properties?: object }) |
| track | (name: string, properties?: object) |
| pageView | ({ path?: string }) |
This project is available under the MIT License
