Skip to content

Migration notes

Irina Southwell edited this page Jan 31, 2022 · 8 revisions

Migration notes for SDK's from version 1.x.x to version 2.x.x

FeatureHub now provides support for both client and server evaluated rollout strategies (flag variations). As such, breaking changes have been introduced to the following SDKs to support this:

  • Java-Android (2.x)

  • Java-Jersey (2.x)

  • Typescript Eventsource (2.x) - this is a deprecated package. Please use featurehub-javascript-client-sdk or featurehub-javascript-node-sdk from NPM.

  • C# (2.x)

New SDK versions require you to upgrade to the v1.3.0+ of the FeatureHub Party server (Includes FeatureHub Admin UI).

This version is backward compatible with the previous versions of the SDKs. We do recommend to upgrade and update your code, however you can upgrade the FeatureHub Party server to the latest version and still use the older (1.x.x) SDK versions.

New in FeatureHub Admin Console

  • Service Accounts page has been renamed to the API Keys page. You will now be offered 2 types of keys. You can read about it here
  • Your existing keys will be automatically converted to the "Server eval keys".

SDKs migration tips

based on Typescript code snippets

  1. Update the way FeatureHub config is created:

Old way:

FEATUREHUB_APP_ENV_URL=http://localhost:8553/features/default/99d8bca3-4e10-4c58-a10c-509b31db3532/X8y3nRMTgtVS7Lsn8Oyk1ppT2Yeap7XGnKVZEjVDMd1XdeqtBAjE6BH4F6f91jXkdh2Sf2zk6PzHJSPa
const featureHubEventSourceClient  = new FeatureHubEventSourceClient(FEATUREHUB_APP_ENV_URL);

New way:

Create an instance of EdgeFeatureHubConfig. You need to provide the API Key and the URL of the FeatureHub Edge server.

import {
  EdgeFeatureHubConfig,
} from 'featurehub-eventsource-sdk';

const edgeUrl = 'http://my-fh-edge-server.com/';
const apiKey = 'default/3f7a1a34-642b-4054-a82f-1ca2d14633ed/aH0l9TDXzauYq6rKQzVUPwbzmzGRqe*oPqyYqhUlVC50RxAzSmx';

const fhConfig = new EdgeFeatureHubConfig(edgeUrl, apiKey);
  1. Update the way FeatureHub flags and values are requested:

Old way:

const color = featureHubRepository.getString('SUBMIT_COLOR_BUTTON');

New way:

const fhClient = await fhConfig.newContext().build(); 
const color = fhClient.getString('SUBMIT_COLOR_BUTTON');

Old way - react to incoming feature changes in real-time:

   featureHubRepository.getFeatureState('SUBMIT_COLOR_BUTTON').addListener((fs: FeatureStateHolder) => {
        this.setState({todos: this.state.todos.changeColor(fs.getString())});
   });

New way - react to incoming feature changes in real-time: :

   fhClient.feature('SUBMIT_COLOR_BUTTON').addListener(fs => {
       this.setState({todos: this.state.todos.changeColor(fs.getString())});
   });
  1. Update the way rollout strategies / user information is passed on

Old way:

 featureHubRepository.clientContext.userKey('foo')
            .country(StrategyAttributeCountryName.NewZealand)
            .device(StrategyAttributeDeviceName.Browser)
            .build(); 

New way:

const fhClient = await fhConfig.newContext().userKey('foo')
         .country(StrategyAttributeCountryName.NewZealand)
         .device(StrategyAttributeDeviceName.Browser)
         .build();
const color = fhClient.getString('SUBMIT_COLOR_BUTTON');
  1. Update the way Google Analytics is connected

Old way:

featureHubRepository.addAnalyticCollector(new GoogleAnalyticsCollector('UA-1234', '1234-5678-abcd-1234'));

New way:

fhConfig.addAnalyticCollector(new GoogleAnalyticsCollector('UA-1234', '1234-5678-abcd-1234'));

FAQs:

  • Does it affect my implementation of FeatureHub SDK if I wasn't using rollouts strategies?

Yes, the new way to evaluate flags has changed regardless if you used rollout strategies or not