fizz-client
Version:
Fizz Javascript Client
36 lines (30 loc) • 1.35 kB
Markdown
[](https://fizz.io) is a platform aimed at improving user acquisition, retention and conversion. Fizz provides different services that work together to achieve these goals. These services include chat, moderation, analytics, etc
```
npm install fizz-client --save
```
Create an instance of the FizzClient using the appropriate factory function:
```
let client = await FizzClient.create(APP_ID, APP_SECRET, "userA", "en", null);
```
Interact with the chat service using the 'chat' property of the client. For example:
```
await client.chat.publishMessage(CHANNEL_ID, "userA", "hello from js!", null, true, true, true);
```
Interact with the moderation service using the 'moderation' property of the client. For example:
```
let filteredTexts = await client.moderation.moderateTexts(texts);
```
Note: All APIs return promises which allows you to use async/await if you prefer.
To log messages on the analytics service.
```
let messageSent = await client.analytics.messageSent(USER_ID, "Hello World", CHANNEL_ID, "testnick")
```
To log product purchased on the analytics service.
```
let productPurchased = await client.analytics.productPurchased(USER_ID, "pr01", 100, "usd");
```
For more details (and an API reference) see the [Fizz documentation](https://docs.fizz.io);