# @dialog-sdk/dialog-browser

> This is [Dialog](askdialog.com) official SDK for browser.

Latest version **0.1.0-beta.4** (published 2023-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dialog-sdk/dialog-browser
pnpm add @dialog-sdk/dialog-browser
yarn add @dialog-sdk/dialog-browser
bun add @dialog-sdk/dialog-browser
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-beta.4 |
| Published | 2023-11-13 |
| First published | 2023-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | louispinsard |

## Links

- npm: https://www.npmjs.com/package/@dialog-sdk/dialog-browser
- npm.io page: https://npm.io/package/@dialog-sdk/dialog-browser

## Recent versions

- 0.1.0-beta.4 (latest) — 2023-11-13
- 0.1.0-beta.0 (beta) — 2023-02-17
- 0.1.0-beta.3 — 2023-03-27
- 0.1.0-beta.2 — 2023-03-07
- 0.1.0-beta.1 — 2023-02-17

## README

This is [Dialog](askdialog.com) official SDK for browser.

# Getting started

With npm:

`npm i @dialog-sdk/dialog-browser`

With yarn:

`yarn add @dialog-sdk/dialog-browser`

With pnpm:

`pnpm add @dialog-sdk/dialog-browser`

```js
import { Analytics } from '@dialog-sdk/dialog-browser';

const analytics = new Analytics('your-public-api-key'); // you can find your public API key in your organization settings
```

# Using the SDK

We recommend calling our SDK as soon as you are aware of your user public wallet address during login.

```js
analytics.identify({
  walletAddress: '0x000000000000000', // your user public wallet address
  chainId: '0x1', // the EVM chain id on which your user signed in
});
```

To also be able to track already connected user, you should call the `identify` method on each page load.

# Adding traits

Traits are information about a user that you can include in an identify call.
You can add the following common traits to your identify call:

- email
- firstName
- lastName
- discordUsername
- telegramUsername
- twitterProfileUrl
- phone
- createdAt

You can also add a custom trait but for now we only support numeric and string values.

```javascript
analytics.identify({
  walletAddress: '0x000000000000000', // your user public wallet address
  chainId: '0x1', // the EVM chain id on which your user signed in
  traits: {
    email: 'yourcustomer@mail.com',
    firstName: 'Your',
    lastName: 'Customer',
    aCustomNumericTrait: 4,
    aCustomStringTrait: 'a string',
  },
});
```

Once you've sent a custom trait, you must respect the same type for the value in your following `identify` calls.

After the above identify call, you cannot send the following call:

```javascript
// ❌❌❌
analytics.identify({
  walletAddress: '0x000000000000000', // your user public wallet address
  chainId: '0x1', // the EVM chain id on which your user signed in
  traits: {
    aCustomNumericTrait: 'a string in a numerical trait',
  },
});
```

# Questions and Feedback

If you have any questions, issues, or feedback, please file an issue on [GitHub](https://github.com/askdialog/dialog-sdk/issues), or send us an [email](mailto:contact@askdialog.com).

---
_Source: https://npm.io/package/@dialog-sdk/dialog-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
