Code Monkey home page Code Monkey logo

associator's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.