Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This topic explains the changes in the Vue SDK 2.0 release and how to adapt code that uses a 1.x version of the Vue SDK to use version 2.0 or later. Version 2.0 includes several breaking changes. Additionally, if you use the Relay Proxy, you must update your Relay Proxy to version 7.0 before you update your SDK to version 2.- To learn more, read the Relay Proxy 7.0 release notes. To upgrade to the latest Relay Proxy version, visit Relay Proxy releases on GitHub.
- You can update them at your own pace while still using 1.x, rather than migrating everything simultaneously. To learn more about updating to the latest 1.x version, visit the SDK’s GitHub repository.
Identifying supported Vue versions for the 2.0 SDK
The LaunchDarkly Vue SDK 2.0 supports Vue 3.2 and newer.Understanding contexts
Many LaunchDarkly customers create targeting rules for feature flags based on a variety of different information, including attributes pertaining to users, organizations, devices, and more. In previous versions of the LaunchDarkly SDK, you could define this information in a user object, using a combination of built-in and custom attributes. Now you can define this information in a more structured way, using contexts. Each context has a required attribute calledkind that describes the type of attributes it contains. You can also add other attributes. Attributes can be strings, booleans, numbers, arrays, or JSON objects.
When you evaluate a feature flag within your application, the flag’s targeting rules use information from one or more kinds of contexts. For example, you may know:
- the username, first name, last name, and email address of a person, as part of a context with
kindof “user” - the organization, department, and location of a person, as part of a context with
kindof “organization” - the device, model, and operating system of an environment, as part of a context with
kindof “device”
Migrating from users to contexts
The 2.0 version of this SDK only operates on contexts. When you migrate from version 1.x, you must replace every instance of a user with a context. For the 2.0 version of the Vue SDK, this means changing each use ofLDUser to LDContext.
A context always has a
kind attribute. When older versions of the Vue SDK send events to LaunchDarkly, LaunchDarkly will convert the users in those events to contexts with a kind of user.If a flag configuration specifies any context kinds other than user, older versions of the Vue SDK will not evaluate the flag correctly. You must upgrade your SDK if you are going to use context kinds other than user in your flag configurations.Understanding differences between users and contexts
Where you previously created users, now you must create contexts. In the Vue SDK, you specify the context as a configuration option. You can pass configuration options to theLDPlugin when it loads, or to the ldInit function if you are using the deferInitialization option. Here’s how: