0.0.2 • Published 2 years ago

@dopt/users-typescript-client v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Dopt's Users TypeScript Client

Getting Started

The Dopt Users TypeScript Client is a friendly server-side and client-side package for accessing the Dopt Users API. This allows you to identify new users and update existing users with Dopt, so that they can interact with the flows created within the app.

Installation

Via Yarn:

yarn add @dopt/users-typescript-client

Via pnpm:

pnpm add @dopt/users-typescript-client

Via npm:

npm install @dopt/users-typescript-client

Configuration

To configure the Users TypeScript Client you will need

  1. A users API key (generated in Dopt)
  2. A user ID for the user you wish to identify (the same ID will be used in the React SDK)
  3. The properties you wish to store and/or update for the given user

Usage

Initialization

import { IdentifyApi, Configuration } from '@dopt/users-typescript-client';

const doptUsersClient = new IdentifyApi(
  new Configuration({
    apiKey: 'USERS_API_KEY',
  })
);

Example Usage

Using the identify API.

const identifier = 'identifier_example';
const properties = {
  stringExample: 'string',
  numberExample: 12345,
  booleanExample: true,
  nullExample: null,
}

await doptUsersClient.identify(identifier, properties)

Using the identifyBulk API.

import { IdentifyBulkRequestBodyInner } from '@dopt/users-typescript-client';

const identifyBulkRequestBody: IdentifyBulkRequestBodyInner[] = []
const identifyBulkUser_1 = {
  '__dopt_identifier': 'identifier_example_1',
  key: 'value',
}
identifyBulkRequestBody.push(identifyBulkUser_1)
const identifyBulkUser_2 = {
  '__dopt_identifier': 'identifier_example_2',
  key: 'value',
}
identifyBulkRequestBody.push(identifyBulkUser_2)

await doptUsersClient.identifyBulk([])
0.0.2

2 years ago

0.0.1

2 years ago