trench-js
v0.0.17
Published
Trench JS client for browser and Node.js
Downloads
508
Readme
trench-js
trench-js
is a client library for both web and Node.js environments that allows you to send events to any Trench instance. This library is designed to be easy to use and integrate into your existing projects.
Installation
Install trench-js
using your preferred package manager:
npm install trench-js
You can now initialize the client with your Trench instance URL and public API key:
import Trench from 'trench-js';
const trench = new Trench({
serverUrl: 'https://trench.example.com',
publicApiKey: 'your-public-api-key',
});
The client is built on top of Analytics and supports all of its methods.
For example, you can identify a user like this:
trench.identify('user-id', {
email: '[email protected]',
});
And track an event like this:
trench.track('test-event', {
test: 'test-value',
});
Or to record a page view:
trench.page();
You can find the full documentation here.