• HOME
  • INTEGRATIONS
  • SDKS
  • GUIDES
  • API DOCS
No results for ""
EXPAND ALL
launchdarkly.com

EDIT ON GITHUB

Aliasing users

Read time: 1 minute
Last edited: Jun 18, 2021

Overview

This topic explains how to alias the users of various LaunchDarkly SDKs. This feature is available for both client-side and server-side SDKs, although its behavior differs between client-side and server-side SDKs.

Aliased users

There are situations in which multiple LaunchDarkly users can represent one person. For example, this can happen when a person initially logs into an application. The person might be represented by an anonymous user before they log in, and a different user after they log in. In that case, that one person is identified by two different users as denoted by different user keys. Our SDKs can associate these two LaunchDarkly users by sending an alias event.

All LaunchDarkly SDKs offer the ability to manually send an alias event. Additionally, client-side SDKs automatically send an alias event when identifying a known user if the previous user was anonymous. You can disable this behavior if necessary. To learn more, read Configuration.

Details about each SDK's configuration are available in the SDK-specific sections below.

  • Client-side SDKs
  • Server-side SDKs

Client-side SDKs

This feature is available in the following client-side SDKs:

C/C++ (client-side)

To manually send an alias event:

1LDClientAlias(client, newUser, previousUser);

Electron

To manually send an alias event:

1client.alias(newUser, previousUser);

iOS

To manually send an alias event:

1LDClient.get()!.alias(context: newUser, previousContext: previousUser)

JavaScript

Both alias parameters must have key attributes. If the LaunchDarkly client auto-generated a unique identifier for one of your users, you can access the user's complete object with the getUser method.

To manually send an alias event:

1var previousUser = ldclient.getUser();
2ldclient.alias(newUser, previousUser);

Node.js (client-side)

To manually send an alias event:

1ldClient.alias(newUser, previousUser);

React

All user-related functionality provided by the JavaScript SDK is also available in the React SDK.

Server-side SDKs

This feature is available in the following server-side SDKs:

.NET

To manually send an alias event:

1client.Alias(newUser, previousUser);

Apex

To manually send an alias event:

1client.alias(newUser, previousUser)

C/C++ (server-side)

To manually send an alias event:

1LDClientAlias(client, newUser, previousUser);

Go

To manually send an alias event:

1ldClient.Alias(newUser, previousUser)

Haskell

To manually send an alias event:

1alias client newUser previousUser

Lua

To manually send an alias event:

1client:alias(newUser, previousUser)

Node.js

To manually send an alias event:

1ldClient.alias(newUser, previousUser);

Python

To manually send an alias event:

1ldclient.get().alias(new_user, previous_user)

Ruby

To manually send an alias event:

1ld_client.alias(new_user, previous_user)