Skip to main content
Gainsight Inc.

Integrate PX with Product Feature Flag

This article explains how to integrate Gainsight PX with feature flag.

Overview

Using feature flag is core to every SaaS product. It is designed to support graduated rollout from beta release (limited availability) to GA (general availability). Feature flag helps you configure access level controls in case you have different product packaging per subscription.

Gainsight recommends integration of PX with feature flag using GlobalContext. Following code block illustrates the logic of passing feature flag using GlobalContext:

var features = {
"dashboardFeatureEnabled": true,
"superAdminFeatureEnabled":false
};
 aptrinsic('set', 'globalContext',features);

Example of integrating Gainsight PX with LaunchDarkly feature flag system: 


/* How to integrate with LaunchDarkly */
(function(n,t,a,e){var i="ldaptrinsic";n[i]=n[i]||function(){
      (n[i].q=n[i].q||[]).push(arguments)},n[i].p=e;
    var r=t.createElement("script");r.async=!0,r.src=a;
    var c=t.getElementsByTagName("script")[0];c.parentNode.insertBefore(r,c)
  })(window,document,"https://unpkg.com/launchdarkly-js-client-sdk@2","");
/* set you LD client side id and pass a user YOUR_CLIENT_SIDE_ID */
var user = {
  "key": "aa0ceb"
};
setTimeout(function() {
    var ldclient = LDClient.initialize('YOUR_CLIENT_SIDE_ID', user);
/* initializing globalContext */
ldclient.on('ready', function() {
eval( "aptrinsic('set', 'globalContext'," + JSON.stringify(ldclient.allFlags()) +")");
});
}, 4000);

Use the feature flag to trigger in-app guidance using GlobalContext rule: 

feature_flag_global_context_rule.PNG

Measure feature usage based on the active features using GlobalContext filtering:

feature_usage_global_context.PNG