Aliasing users

This feature is deprecated for SDKs that use contexts

LaunchDarkly no longer supports alias events for SDKs upgraded for contexts. LaunchDarkly continues to support sending and receiving alias events for older SDK versions. To learn more, read about our SDKs that support contexts.

To learn how to associate contexts without using the alias method, read Associate anonymous contexts with logged-in end users.

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.

Only some LaunchDarkly SDKs offer the ability to manually send an alias event. Some 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 how, read Configuration.

Details about each SDK’s configuration are available in the SDK-specific sections below:

Client-side SDKs

This feature is no longer supported or required in any client-side SDKs. To learn more, read Best practices for upgrading users to contexts, and consult the custom contexts migration guide for each client-side SDK.

Older versions of these SDKs still support aliasing. Details for these older versions are included below.

.NET (client-side)

In version 3 and newer of the .NET (client-side) SDK, aliasing is no longer supported or required. To learn more, read .NET (client-side) SDK 2.x to 3.0 migration guide.

To manually send an alias event:

.NET SDK 2.x (C#)
1client.Alias(newUser, previousUser);

To learn more, read LdClient.Alias and ConfigurationBuilder.AutoAliasingOptOut.

Android

In version 4.0 and newer of the Android SDK, aliasing is no longer supported or required. To learn more, read the Android SDK 3.x to 4.0 migration guide.

To manually send an alias event:

1client.alias(newUser, previousUser);

C++ (client-side)

In version 3 and newer of the C++ (client-side) SDK, aliasing is no longer supported or required. To learn more, read C++ (client-side) SDK 2.x to 3.0 migration guide.

To manually send an alias event:

C SDK v2.0 (native)
1LDClientAlias(client, newUser, previousUser);

Electron

To manually send an alias event:

JavaScript
1client.alias(newUser, previousUser);

Flutter

In version 2 and newer of the Flutter SDK, aliasing is no longer supported or required. To learn more, read the Flutter SDK 1.x to 2.0 migration guide.

To manually send an alias event:

Dart
1await LDClient.alias(newUser, previousUser);

iOS

In version 8 and newer of the iOS SDK, aliasing is no longer supported or required. To learn more, read the iOS SDK 7.x to 8.0 migration guide for Objective-C or for Swift.

To manually send an alias event:

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

JavaScript

In version 3 and newer of the JavaScript SDK, aliasing is no longer supported or required. To learn more, read JavaScript SDK 2.x to 3.0 migration guide.

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:

JavaScript SDK v2.x
1const previousUser = client.getUser();
2client.alias(newUser, previousUser);

Node.js (client-side)

In version 3 and newer of the Node.js SDK, aliasing is no longer supported or required. To learn more, read Node.js (client-side) SDK 2.x to 3.0 migration guide.

To manually send an alias event:

JavaScript
1client.alias(newUser, previousUser);

React Native

In version 7 and newer of the React Native SDK, aliasing is no longer supported or required. To learn more, read React Native SDK 6.x to 7.0 migration guide.

To manually send an alias event:

JavaScript
1client.alias(user, previousUser);
2
3// to send an alias event in a different environment than the default,
4// pass in the environment key (optional)
5client.alias(user, previousUser, environment);

Roku

In version 2 and newer of the Roku SDK, aliasing is no longer supported or required. To learn more, read Roku SDK 1.x to 2.0 migration guide.

To manually send an alias event:

BrightScript
1client.alias(user, previousUser)

Server-side SDKs

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

.NET (server-side)

In version 7.0 and newer of the .NET (server-side) SDK, aliasing is no longer supported or required. To learn more, read .NET (server-side) SDK 6.x to 7.0 migration guide.

To manually send an alias event:

.NET SDK v7.0 and earlier (C#)
1client.Alias(newUser, previousUser);

Apex

To manually send an alias event:

Apex
1client.alias(newUser, previousUser)

C++ (server-side)

In version 3.0 and newer of the C++ (server-side) SDK, aliasing is no longer supported or required. To learn more, read C++ (server-side) SDK 2.x to 3.0 migration guide.

To manually send an alias event:

C/C++
1LDClientAlias(client, newUser, previousUser);

Erlang

In version 2 and newer of the Erlang SDK, aliasing is no longer supported or required. To learn more, read Erlang SDK 1.x to 2.0 migration guide.

To manually send an alias event:

Erlang
1ldclient:alias(User, PreviousUser)

Go

In version 6.0 and newer of the Go SDK, aliasing is no longer supported or required. To learn more, read Go SDK 5.x to 6.0 migration guide.

To manually send an alias event in older versions of the Go SDK:

Go SDK v5.x and earlier
1client.Alias(newUser, previousUser)

Haskell

In version 4 and newer of the Haskell SDK, aliasing is no longer supported or required. To learn more, read Haskell SDK 3.x to 4.0 migration guide.

To manually send an alias event:

Haskell
1alias client newUser previousUser

Java

In version 6 and newer of the Java SDK, aliasing is no longer supported or required. To learn more, read Java SDK 5.x to 6.0 migration guide.

To manually send an alias event:

Java SDK v5.x and earlier
1client.alias(user, previousUser);

Lua

In version 2.0 and newer of the Lua SDK, aliasing is no longer supported or required. To learn more, read Lua (server-side) SDK 1.x to 2.0 migration guide.

To manually send an alias event:

Lua SDK v1.x
1client:alias(newUser, previousUser)

Node.js (server-side)

In version 7.0 and newer of the Node.js (server-side) SDK, aliasing is no longer supported or required. To learn more, read Node.js (server-side) SDK 6.x to 7.0 migration guide.

To manually send an alias event:

JavaScript
1client.alias(newUser, previousUser);

PHP

In version 5.0 and newer of the PHP SDK, aliasing is no longer supported or required. To learn more, read PHP SDK 4.x to 5.0 migration guide.

To manually send an alias event:

PHP
1$client->alias($user, $previousUser);

Python

In version 8 and newer of the Python SDK, aliasing is no longer supported or required. To learn more, read Python SDK 7.x to 8.0 migration guide.

To manually send an alias event:

Python SDK v7.x and earlier
1ldclient.get().alias(new_user, previous_user)

Ruby

In version 7 and newer of the Ruby SDK, aliasing is no longer supported or required. To learn more, read Ruby SDK 6.x to 7.0 migration guide.

To manually send an alias event:

Ruby SDK v6.x and earlier
1client.alias(new_user, previous_user)

Rust

In version 1 and newer of the Rust SDK, aliasing is not supported or required. To learn more, read Rust SDK v1 implementation guide.

To manually send an alias event:

Rust
1client.alias(user, previous_user);
Built with