Skip to content

kleinjoshuaa/associator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Split Associator

The Split Associator library allows you to handle the lifecycle of a user as they pass from anonymous, to logged in, and perhaps associated with other IDs such as accounts or customer.

The Associator wraps the Split Javascript client - it requires a client side SDK key from Split.io in order to function.

This demo shows how it can be used.

Instantiation

const associator = new Associator('CLIENT_SDK_KEY', {'attr1': 'val1'}, true);

Associating IDs with trafficTypes

Note that the getReady function returns a promise. This function is important because it matches the key to the trafficType - ensuring that splits that are called with the proper key.

associator.getReady(key, trafficType).then(() => {
  doSomething();
}

Fetching Treatments

This is how you get treatments. The associator will automatically select the proper key for the split based upon the split's traffic type. The config parameter lets you optionally elect to recieve dynamic configuration. It can be true or false.

associator.getTreatment(splitName, config)

Tracking Events

The track function is used to track events - with an optional value and optional properties. It will automatically track for all traffic types that it knows about

associator.track(eventType, value, properties)

Destroying SDK Clients

The destroy methods can be used to destroy the client. Note that you can't bring a client back to life once you've destroyed it.

associator.destroyAll();

The Associator class itself is in the public/js/script.js file. Click here to view..

To run this demo, first update with your client side SDK key in the views/login.ejs file and then in the terminal run npm install and then node index.js to run the demo server.

image

It will serve locally on port 3000

About

Associate multiple split traffic types together

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published