How to use @splitsoftware/splitio - 7 common examples

To help you get started, we’ve selected a few @splitsoftware/splitio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github splitio / javascript-client / ts-tests / index.ts View on Github external
},
  storage: {
    type: 'REDIS'
  }
};
// For browser
browserSettings = {
  core: {
    authorizationKey: 'another-key',
    key: 'customer-key'
  }
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
  authorizationKey: string,
  key: SplitIO.SplitKey,
  trafficType: string,
  labelsEnabled: boolean,
  IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
  prefix: string,
  options: Object,
  // It can have any of the storages.
github splitio / javascript-client / ts-tests / index.ts View on Github external
authorizationKey: 'key'
  },
  storage: {
    type: 'REDIS'
  }
};
// For browser
browserSettings = {
  core: {
    authorizationKey: 'another-key',
    key: 'customer-key'
  }
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
  authorizationKey: string,
  key: SplitIO.SplitKey,
  trafficType: string,
  labelsEnabled: boolean,
  IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
  prefix: string,
  options: Object,
github splitio / javascript-client / ts-tests / index.ts View on Github external
core: {
    authorizationKey: 'key'
  },
  storage: {
    type: 'REDIS'
  }
};
// For browser
browserSettings = {
  core: {
    authorizationKey: 'another-key',
    key: 'customer-key'
  }
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);

// The settings values the SDK expose.
const instantiatedSettingsCore: {
  authorizationKey: string,
  key: SplitIO.SplitKey,
  trafficType: string,
  labelsEnabled: boolean,
  IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
  prefix: string,
github tdeekens / flopflip / packages / splitio-adapter / modules / adapter / adapter.ts View on Github external
const initializeClient = (): {
  client: SplitIO.IClient;
  manager: SplitIO.IManager;
} => {
  if (!adapterState.splitioSettings) {
    throw Error(
      'cannot initialize SplitIo without configured settings, call configure() first'
    );
  }

  const sdk = SplitFactory(adapterState.splitioSettings); // eslint-disable-line new-cap

  return {
    client: sdk.client(),
    manager: sdk.manager(),
  };
};
github splitio / split-evaluator / sdk.js View on Github external
logger.info(`SDK_URL: ${process.env.SDK_URL}`);
logger.info(`EVENTS_URL: ${process.env.EVENTS_URL}`);
if (process.env.SPLITIO_IMPRESSION_LISTENER) {
  settings = merge({}, settings, {
    impressionListener: {
      logImpression,
    },
  });
  context.start();
  logger.info(`IMPRESSION_LISTENER: ${process.env.SPLITIO_IMPRESSION_LISTENER}`);
}

let isClientReady = false;

// Our SDK factory instance.
const factory = SplitFactory(settings);
// Our client.
const client = factory.client();
// Our manager.
const manager = factory.manager();
// Returns true if the client is ready.
const isReady = () => isClientReady;

client.on(client.Event.SDK_READY, () => {
  logger.info(`ON SDK_READY, IS CLIENT READY?: ${isClientReady}`);
  return isClientReady === true;
});

module.exports = {
  factory,
  client,
  manager,
github tdeekens / flopflip / packages / splitio-adapter / modules / adapter / adapter.spec.js View on Github external
factory = {
        client: jest.fn(() => ({
          on: onStub,
          getTreatments: jest.fn(() => flags),
          Event: {
            SDK_READY: 'SDK_READY',
            SDK_UPDATE: 'SDK_UPDATE',
          },
        })),
        manager: jest.fn(() => ({
          names: jest.fn(() => names),
        })),
      };

      SplitFactory.mockReturnValue(factory);

      return adapter.configure(
        {
          authorizationKey,
          user: userWithKey,
        },
        {
          onStatusStateChange,
          onFlagsStateChange,
        }
      );
    });
github splitio / javascript-client / packages / splitio-browser / bin / bundler.js View on Github external
const touch = require('touch');
const mkdirp = require('mkdirp');

const browserify = require('browserify');
const envify = require('envify/custom');
const uglify = require('uglify-js');
const strStream = require('string-to-stream');

const splitPkg = require('@splitsoftware/splitio/package');

const splitSource = require.resolve('@splitsoftware/splitio/lib/browser.js');

const bundlesDir = path.resolve(path.join(process.cwd(), `splitio`));

const debugBundlePath = path.resolve(path.join(bundlesDir, `split-${splitPkg.version}.js`));
const productionBundlePath = path.resolve(path.join(bundlesDir, `split-${splitPkg.version}.min.js`));

function minify(bundlePath, customUglifySetting) {
  return uglify.minify(bundlePath, Object.assign({
    compress: {
      sequences     : true,
      properties    : true,
      dead_code     : true,
      drop_debugger : true,
      unsafe        : false,
      unsafe_comps  : false,
      conditionals  : true,
      comparisons   : true,
      evaluate      : true,
      booleans      : true,
      loops         : true,
      unused        : true,