Search documentation...

K

LaunchDarkly

Keep your team's feature flags up-to-date with fresh targeting rules and lists of users

Overview

To get the most out of tools like LaunchDarkly, you'll need to create user segments so that features can be toggled on for specific customers when the time is right. There are two segmentation methods in LaunchDarkly:
  • Targeting individual users for inclusion or exclusion (e.g., enable or disable a feature for user #123)
  • Targeting all users who satisfy an attribute-based rule (e.g., enable a feature for all users located in Germany)
Both of these methods are limited by the fact that LaunchDarkly can't read user attributes directly from your data warehouse or production database. Instead, LaunchDarkly relies on developers to send user data via the SDK during feature flag evaluation. This is problematic in many common scenarios. For example, you might want to segment users based on attributes that are simply not possible to compute in real-time (e.g., historical usage metrics that require aggregating across large volumes of data).
LaunchDarkly has a limited view of your customers. Hightouch solves this problem by letting you define your user segments on top of your data warehouse or production database. This ensures that your LaunchDarkly segments will always remain in sync with your entire data stack. Feature flags work best when they share a single source of truth with the rest of your business.
We use LaunchDarkly at Hightouch. We built this destination for ourselves, and we think you'll love it too.

Why feature flagging should be based on the warehouse

  • You can do more complex segmentation by leveraging all the data in your warehouse, including event data and third-party data. Your warehouse is the only place where all of this data coexists.
  • You can keep your LaunchDarkly segments in sync with the rest of your business tools. For example, you might want to send an email newsletter to users who've been invited to a beta program. You also might want to sync these attributes to a CRM like Salesforce or HubSpot. Hightouch integrates with 100+ SaaS tools used for email marketing, customer support, sales, and more. Define your audience once and activate your data everywhere.
  • You don't have to send any sensitive user data to LaunchDarkly. Hightouch determines which users are part of your segment and only transmits the bare minimum information necessary for targeting (usually just a user ID).
  • Segments can be defined using the tools that your teams are most comfortable with. You can filter and transform data from your warehouse using SQL or our visual query builder—whichever you prefer. (You can even create LaunchDarkly segments based on work you've already done in dbt or Looker!)

Supported sync methods

Hightouch can sync data to a LaunchDarkly segment in three ways:
  1. Target users for inclusion
  2. Target users for exclusion
  3. Target users who match a custom rule
We recommend targeting individual users for inclusion/exclusion if LaunchDarkly's feature flagging only affects your application's frontend experience. However, if you intend on feature flagging backend functionality that applies to entire organizations (instead of specific users), it might be better to use rule-based targeting. This is because certain backend logic often cannot be associated with an individual application "user" in the traditional sense. Chat with us if you're not sure which approach to take!

Targeting users for inclusion or exclusion

The most common way of using our LaunchDarkly destination is to sync a model containing a list of user IDs for inclusion or exclusion in a particular segment.
In your sync configuration, simply tell Hightouch which field from your model represents the user identifier known to LaunchDarkly.
Sometimes, you might want to sync different users to inclusion and exclusion lists for the same LaunchDarkly segment. This can be accomplished by configuring two separate syncs in Hightouch.

Creating a new segment

In your sync configuration, you can tell Hightouch to create a new LaunchDarkly segment for you.
You can optionally assign a custom name to your segment. Use the following LaunchDarkly segment naming guidelines:
  • All lowercase
  • No spaces. Use hyphens instead.
  • Must be unique within your LaunchDarkly instance.
If no name is provided, Hightouch will default to using your model name.

Targeting users who match a custom rule

Hightouch can also sync your data into a LaunchDarkly rule clause.
Suppose you have a list of email addresses belonging to your sales prospects. You want to immediately enable a feature as soon as they sign up for a trial account. However, you can't predict their user IDs before they've created their accounts. How would you add them to your LaunchDarkly segment in advance?
This scenario is perfect for rule-based segmentation. Your rule clause might look something like this.
Simply create a model that returns a list of email addresses. Then, in your sync configuration, point Hightouch to the desired rule clause. Your LaunchDarkly segment will automatically mirror your Hightouch model. As new email addresses appear, they will be added to the rule clause. The opposite is also true: as email addresses disappear, they will be removed from the rule clause. Simple, right?
Hightouch cannot create new rules on your behalf, so rule-based targeting requires you to initially create each rule inside of the LaunchDarkly web app.

Getting started

If you're new to Hightouch, be sure to sign up for a free account. Your first destination is free, and LaunchDarkly is a great way to get started.
Before diving into this tutorial, we also recommend reading this article on our core concepts. It's a quick overview of how Hightouch works.

Step 1: Connect to LaunchDarkly

Create an API token

  1. Log in to LaunchDarkly
  2. Visit your Account settings page
  3. Click on the Authorization tab
  4. Click on Create token
  5. Give your token a name and assign it the Writer role
  6. Click Save token and copy the new token that appears in the Authorization page
We recommend using a service token if your LaunchDarkly account is on the Enterprise plan. To do this, simply select This is a service token while creating the token. If you're not on the Enterprise plan, just be mindful that your API token will get revoked (and your Hightouch syncs will fail) if your personal LaunchDarkly account is deactivated for any reason.

Add LaunchDarkly as a destination in Hightouch

  1. Log in to Hightouch or create a free Hightouch account
  2. Click on Destinations in the left sidebar
  3. Click on Add destination in the top right corner
  4. Select LaunchDarkly in the destination catalog and click Continue to proceed
  5. Paste your API token into the API Access Token field and click Continue to proceed
  6. Give your destination a name and unique slug (e.g., “LaunchDarkly Production” and launchdarkly-production)
  7. Click Finish to create your LaunchDarkly destination!
Now that we've linked Hightouch to your LaunchDarkly account, it's time to connect to build user segments using the data that resides in your data warehouse.

Step 2: Connect to your data source

Hightouch sits on top of your data warehouse and can read from Snowflake, Redshift, BigQuery, Databricks, Postgres, MySQL, and many other data sources. You can even fetch data from Google Sheets and Airtable. Hightouch can help activate your data wherever it resides.
We've written dedicated guides for each supported data source. Take your pick:
If you're missing the credentials necessary to connect to your data source, try inviting your teammates to Hightouch. You can have unlimited collaborators in your workspace!

Connect to a sample database instead

Waiting for credentials to your data warehouse? No problem! You can connect to one of our sample databases to get started right away. For the rest of this tutorial, we'll use our demo Postgres database, which contains a users table with names, emails, locations, and other user attributes. This sample source is available when you log in for the first time—no setup required.
Next, we'll write a SQL query to define which users should be synced to our LaunchDarkly segment.

Step 3: Create a model

In Hightouch, a model represents a query that filters or transforms the records in your data source. Models are used to determine exactly which records to sync between sources and destinations.
When you connect to a data warehouse, your models will probably be written in SQL. You can also import models from tools like dbt and Looker.
In this example, we'll keep it simple. Suppose you want to use LaunchDarkly to enable a feature only for your customers located in the city of Nashville. To accomplish this, you'll want to create a model that looks like this:
SELECT * FROM users WHERE location = 'Nashville';
  1. Click on Models in the left sidebar
  2. Click on Add model in the top right corner
  3. Select Demo Database as your source and click Continue to proceed
  4. Select SQL Editor as your modeling method
  5. Paste the SQL query from above into the editor on the left side of the page
  6. Click Preview to execute the query
  7. Click Continue to proceed
  8. Give your model a name and unique slug (e.g., "Users in Nashville" and users-in-nashville)
  9. Select id as the primary key for your model
  10. Click Finish to create your model!
We just created a model using a SQL query that filters our users table down to only those located in Nashville. Next, we'll configure our sync to add these users to a LaunchDarkly segment.

Step 4: Create a sync

  1. Click on Syncs in the left sidebar
  2. Click on Add sync in the top right corner
  3. Select Users in Nashville as your model and click Continue to proceed
  4. Select LaunchDarkly Production as your destination and click Continue to proceed
  5. Select which LaunchDarkly project you want to sync data to
  6. Identify which field from your model represents the identifier known to LaunchDarkly
  7. Select Segment Included Users as the field you wish to update in LaunchDarkly
  8. Select Create a new segment
  9. Give a name to your segment (e.g., "My beta test")
  10. Click Continue to proceed to the last step
  11. Select Interval to tell your sync to run on a set interval
  12. Configure your sync schedule to run every 5 minutes
  13. Click Finish to create your sync!
Your LaunchDarkly sync configuration would look something like this.
And your sync schedule configuration would resemble this.

Troubleshooting

Common errors

To date, our customers haven't experienced any errors while using the LaunchDarkly destination. (Knock on wood.)

Don't see your data in LaunchDarkly?

Make sure you've configured your sync to use the correct LaunchDarkly environment! You might've accidentally pointed to a different environment. If that doesn't solve your issue, please reach out! We're happy to help.

Use the Hightouch debugger

Hightouch provides full visibility into the LaunchDarkly API calls made during each of your sync runs. We recommend reading our article on debugging tips and tricks.

Set up sync alerts

Hightouch can alert you of any sync issues via Slack, PagerDuty, SMS, and/or email. For details, please visit our article on alerting.

    Need help?

    Our team is relentlessly focused on your success. We're ready to jump on a call to help unblock you.

    • Connection issues with your data warehouse?
    • Confusing API responses from destination systems?
    • Unsupported destination objects or modes?
    • Help with complex SQL queries?

    or

    Feature Requests?

    If you see something that's missing from our app, let us know and we'll work with you to build it!

    We want to hear your suggestions for new sources, destinations, and other features that would help you activate your data.

On this page

OverviewWhy feature flagging should be based on the warehouseSupported sync methodsTargeting users for inclusion or exclusionTargeting users who match a custom ruleGetting startedStep 1: Connect to LaunchDarklyStep 2: Connect to your data sourceStep 3: Create a modelStep 4: Create a syncTroubleshootingCommon errorsDon't see your data in LaunchDarkly?Use the Hightouch debuggerSet up sync alerts

Was this page helpful?