The Dopt users JavaScript client is a friendly client-side package for identifying users and/or groups along with properties associated with them to Dopt.
It is published to npm as @dopt/users-javascript-browser-client
.
Via npm:
npm install @dopt/users-javascript-browser-client
Via Yarn:
yarn add @dopt/users-javascript-browser-client
Via pnpm:
pnpm add @dopt/users-javascript-browser-client
To configure the Users JavaScript Client you will need
- A users API key (generated in Dopt)
- An identifier for the user or group you wish to identify (the same identifier will be used in the React SDK)
- The properties you wish to store and/or update for the given user or group
import { DoptApiClient } from '@dopt/users-javascript-browser-client';
const client = new DoptApiClient({
apiKey: process.env.DOPT_USERS_API_KEY,
});
Identify a single user to Dopt.
await client.users.identifyUser({
identifier: "identifier_example",
properties: {
stringExample: "string",
numberExample: 12345,
booleanExample: true,
nullExample: null,
},
});
Identify a batch of users to Dopt.
await client.users.identifyUsers([
{
identifier: "identifier_example",
properties: {
stringExample: "string",
numberExample: 12345,
booleanExample: true,
nullExample: null,
},
},{
identifier: "user2_identifier",
properties: {
stringExample: "string",
},
}
]);
Identify a group to Dopt.
await client.groups.identifyGroup({
identifier: "group_identifier_example",
properties: {
stringExample: "string",
numberExample: 12345,
booleanExample: true,
nullExample: null,
},
})