Skip to main content
Version: Config V2

Twilio Segment - Monitor your feature flag change events and feature flag analytics

Overview​

There are two available integration opportunities between ConfigCat and Twilio Segment:

Sending feature flag change events to Twilio Segment​

Ensures that every setting change in ConfigCat is sent to Segment as a track event.

Twilio Segment Feature Flag Changed event

Installation​

2

Add the ConfigCat source to your Twilio Segment account and copy the Write Key.

3

Open the integrations tab on the ConfigCat Dashboard.

4

Click on Twilio Segment's CONNECT button and set the Twilio Segment Write Key acquired while adding the ConfigCat source in Twilio Segment.

5

OPTIONAL - Set the proper server of your Twilio Segment account. More about Segment servers.

6

You're all set. Go ahead and make some changes to your feature flags, then check your events in Twilio Segment.

Un-installation​

1

Open the integrations tab on the ConfigCat Dashboard.

2

Click on Twilio Segment's DISCONNECT button.

Event details​

Every feature flag change event sent to Twilio Segment by ConfigCat has the following properties:

  • event name: Feature Flag Changed.
  • timestamp: When the change happened.
  • details: A summary of the change.
  • product_id, product_name: The product where the change happened.
  • config_id, config_name: The config where the change happened.
  • environment_id, environment_name: The environment where the change happened.
  • url: A direct link to the config/feature flag.
  • userId, user_email, user_full_name: Who made the changes.

Sending feature flag evaluation analytics to Twilio Segment​

Ensures that feature flag evaluations are sent into the Twilio Segment ConfigCat source. With this integration, you get advanced analytics on your feature flag usage and A/B test results in any of Segment's destinations.

Setup​

1

Add ConfigCat source in Twilio Segment: Add the ConfigCat source in Twilio Segment.

2

Install SDKs: Add both the ConfigCat SDK and Segment SDK to your application.

3

Configure SDKs:

  • ConfigCat SDK: Initialize with your ConfigCat SDK key.
  • Twilio Segment SDK: Set up with the Twilio Segment Write Key acquired while adding the ConfigCat source in Twilio Segment.
4

Integrate Feature Flag Evaluations:

  • During the initialization of the ConfigCat SDK, subscribe to the flagEvaluated hook.
  • Send feature flag evaluation data to Twilio Segment using the Feature Flag Evaluated event name. Include the following parameters:
    • feature_flag_key: the feature flag's key.
    • value: the evaluated feature flag's value or Variation ID.
    • variation_id (optional): the evaluated feature flag's Variation ID.
    • userId (optional): the user object's identifier used during feature flag evaluation.
    • user (optional): the user object used during feature flag evaluation.

Code samples:

const segmentAnalytics = AnalyticsBrowser.load({ writeKey: "#YOUR_SEGMENT_WRITE_KEY#" });
segmentAnalytics.addSourceMiddleware(({payload, next}) => {
payload.obj.context.integration = payload.obj.context.integration || {};
payload.obj.context.integration['name'] = 'configcat';
payload.obj.context.integration['version'] = '1.0.0';
next(payload);
});

const configCatClient = configcat.getClient("#YOUR_SDK_KEY#", PollingMode.AutoPoll, {
setupHooks: (hooks) =>
hooks.on('flagEvaluated', evaluationDetails => {
if (evaluationDetails.user) {
segmentAnalytics.identify(evaluationDetails.user.identifier, evaluationDetails.user);
}
segmentAnalytics.track('Feature Flag Evaluated',
{
'feature_flag_key': evaluationDetails.key,
'value': evaluationDetails.value,
'variation_id': evaluationDetails.variationId,
'user': evaluationDetails.user
});
}),
});
note

For Text feature flags with lengthy values (e.g., JSON), send the variationId instead of the value as the value to Twilio Segment. The variationId is a hashed version of the feature flag value, accessible on the ConfigCat Dashboard by enabling the Show VariationIDs to support A/B testing setting. Learn more here.

For more information about Variation IDs, see Variation ID for analytics.

5

Deploy your application and wait for feature flag evaluations to happen so feature flag evaluation events can be sent to Twilio Segment.

6

Add the preferred destination in Twilio Segment for your source and configure your mappings.

7

Enable the destination and utilize advanced feature flag analytics in the destination.

Example event​

Check your source's debugger to see the events.

Twilio Segment event debugger

Useful Resources​