Skip to content

Commit e06a244

Browse files
committed
Improve readmes
1 parent 30a3e33 commit e06a244

3 files changed

Lines changed: 98 additions & 14 deletions

File tree

packages/push/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const userlist = new Userlist({
4444

4545
## Usage
4646

47+
> [!TIP]
48+
> All of the following methods return promises. In order to decouple your application from our service, we recommend to not await them. If you decide to still await them, make sure to add proper error handling.
49+
4750
### Tracking Users
4851

4952
To send user data into Userlist, use the `userlist.users.push` method. This method will create a new user if the user doesn't exist yet, or update the existing user if it does. Properties that aren't present in the payload are ignored and remain unchanged.

packages/web/README.md

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,98 @@
1-
# `@userlist/web`
1+
# @userlist/web
22

3-
> TODO: description
3+
This package helps with client side tracking for [Userlist](http://userlist.com).
4+
5+
> For server side tracking on Node.js, please use [@userlist/push](https://github.com/userlist/userlist-javascript/tree/main/packages/push).
6+
7+
## Installation
8+
9+
To install this package, use one of the commands corresponding to your package manager.
10+
11+
Via NPM:
12+
13+
```shell
14+
npm install @userlist/web
15+
```
16+
17+
Via Yarn:
18+
19+
```shell
20+
yarn add @userlist/web
21+
```
22+
23+
## Configuration
24+
25+
To initialize the Userlist client, you have to pass it a user token that you generate on your backend. For details on how to create a user token, please refer to the [documentation](https://userlist.com/docs/developers/in-app-messages/#generating-user-tokens).
26+
27+
```javascript
28+
import Userlist from "@userlist/web";
29+
30+
// With a static token
31+
const userlist = new Userlist("userlist-user-token");
32+
33+
// With a promise that retuns a token
34+
const token = fetch("http://example.com/token")
35+
.then((response) => response.json())
36+
.then((data) => data.userlistToken);
37+
38+
const userlist = new Userlist(token);
39+
```
440

541
## Usage
642

43+
You can only update data of the user that the user token was generated for. To update other data, please use server side tracking.
44+
45+
### Tracking User Properties
46+
47+
To send user data into Userlist, use the `userlist.identify` method. This method will create a new user if the user doesn't exist yet, or update the existing user if it does. Properties that aren't present in the payload are ignored and remain unchanged.
48+
49+
```javascript
50+
userlist.identify({
51+
email: user.email,
52+
properties: {
53+
first_name: user.first_name,
54+
last_name: user.last_name,
55+
},
56+
});
757
```
8-
const web = require('@userlist/web');
958

10-
// TODO: DEMONSTRATE API
59+
### Tracking User Events
60+
61+
To track custom events use the `userlist.track` method. This method will create a new user if the user doesn't exist yet, or update the existing user if it does.
62+
63+
```javascript
64+
userlist.track({
65+
name: "project_created",
66+
properties: {
67+
project_name: project.name,
68+
},
69+
});
1170
```
71+
72+
### Resetting
73+
74+
If you want to reset the connection to our services to be able to start tracking a new user, please call `destroy` before creating a new Userlist client.
75+
76+
```javascript
77+
userlist.destroy();
78+
```
79+
80+
## Contributing
81+
82+
Bug reports and pull requests are welcome on GitHub at https://github.com/userlist/userlist-javascript. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
83+
84+
## License
85+
86+
The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
87+
88+
## Code of Conduct
89+
90+
Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/userlist/userlist-javascript/blob/main/CODE_OF_CONDUCT.md).
91+
92+
## What is Userlist?
93+
94+
[![Userlist](https://userlist.com/images/external/userlist-logo-github.svg)](https://userlist.com/)
95+
96+
[Userlist](https://userlist.com/) allows you to onboard and engage your SaaS users with targeted behavior-based campaigns using email or in-app messages.
97+
98+
Userlist was started in 2017 as an alternative to bulky enterprise messaging tools. We believe that running SaaS products should be more enjoyable. Learn more [about us](https://userlist.com/about-us/).

packages/widget/README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
# `@userlist/widget`
1+
# @userlist/widget
22

3-
> TODO: description
4-
5-
## Usage
6-
7-
```
8-
const widget = require('@userlist/widget');
9-
10-
// TODO: DEMONSTRATE API
11-
```
3+
> [!WARNING]
4+
> This package is not intended for direct usage.
5+
> Use the [@userlist/web](https://github.com/userlist/userlist-javascript/tree/main/packages/web) package instead.

0 commit comments

Comments
 (0)