Skip to content

Commit

Permalink
docs: updated readme on trench-js
Browse files Browse the repository at this point in the history
  • Loading branch information
christianmat committed Oct 28, 2024
1 parent cbe96d8 commit e772aaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-islands-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'trench-js': patch
---

Updated README
38 changes: 30 additions & 8 deletions packages/trench-js/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
# trench-js

A JavaScript library for tracking events and page views to Trench.
`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:

```bash
npm install trench-js
```

## Usage
You can now initialize the client with your Trench instance URL and public API key:

```javascript
```ts
import Trench from 'trench-js';

const trench = new Trench({
publicApiKey: 'YOUR_PUBLIC_API_KEY',
server: 'your-trench-server.com',
serverUrl: 'https://trench.example.com',
publicApiKey: 'your-public-api-key',
});
```

```javascript
trench.track('page_view', {
url: 'https://example.com',
The client is built on top of [Analytics](https://github.com/DavidWells/analytics) and supports all of its [methods](https://github.com/DavidWells/analytics#usage).

For example, you can identify a user like this:

```ts
trench.identify('user-id', {
email: 'test@example.com',
});
```

And track an event like this:

```ts
trench.track('test-event', {
test: 'test-value',
});
```

Or to record a page view:

```ts
trench.page();
```

You can find the full documentation [here](https://docs.trench.dev/client).

0 comments on commit e772aaa

Please sign in to comment.