New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

taplytics

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

taplytics

Taplytics Node.js SDK for fast A/B testing and Feature Flagging

1.2.0
latest
npm
Version published
Weekly downloads
11
-70.27%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI

Getting started

Taplytics decisions is an API to quickly use Taplytics features and functionality at edge.

Initialization

API client can be initialized as following:

First install the SDK to your project

npm install taplytics

Then import it

var taplytics = require('taplytics')('API_KEY');

Identification

All method calls to Taplytics require a user id. This is to ensure that the user will always receive the correct experiments and variations across all platforms.

Methods

All methods can use either a callback as a param, or used as a promise, i.e.

taplytics.getConfig(...).then(val => {
	// use val
}).catch(err => {
	// error err
})

If a callback is provided, the function will not return a promise.

getBucketing

Returns a key/value pairing of all experiments that the user has been segmented into, as well as the variation the users are assigned.

Parameters
ParameterTagsDescription
userIdRequiredID for current user
attributesOptionalProvide all relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id
var body = { attributes:{ key:'value', key2:'value2' } }

taplytics.getBucketing(userId, body, (err, bucketing) => {
	// your code here
})

getVariables

All variables and their values for the given user

Parameters
ParameterTagsDescription
userIdRequiredID for given user
attributesOptionalAll relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id
var attributes = { attributes:{ key:'value', key2:'value2' } }

taplytics.getVariables(userId, attributes, (err, variables) => {
	// your code here
})

getVariationForExperiment

For a given experiment, determine whether or not a user is in the experiment, and in which variation

Parameters
ParameterTagsDescription
userIdRequiredID for given user
experimentNameRequiredName of an Experiment
attributesOptionalAll relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = 'user_id'
var experimentName = 'experimentName';
var attributes = { attributes:{ key:'value', key2:'value2' } }

taplytics.getVariationForExperiment(userId, experimentName, attributes,(error, variation) => {
	// your code here
})

getVariableValue

Value for given Taplytics Dynamic Variable. If a user is not in an experiment containing the variable, the response be the provided default value in the query params.

Parameters
ParameterTagsDescription
userIdRequiredID for given user
varNameRequiredname of variable
defaultValueRequireddefault value to be used if user does not have variable available.
attributesOptionalAll relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id;
var varName = 'varName';
var defaultValue = 'defaultValue';
var attributes = { attributes:{ key:'value', key2:'value2' } }

taplytics.getVariableValue(userId, varName, defaultValue, attributes, (err, value) => {
	// your code here
});

postEvent

Send an event to Taplytics. These events are then used to compare against an experiment's goals to determine the success of an A/B test.

Parameters
ParameterTagsDescription
userIdRequiredID for given user
bodyOptionalProvide an array of events, as well as all additional relevant user attributes.
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id
var body = {
	attributes: {key: 'value'},
	events: [
		{ eventName: 'event 1', eventValue: 3 },
		{ eventName: 'event 2' }
	]
}

taplytics.postEvent(userId, body, (error, response) => {
	// your code here
})

getConfig

Returns the entire configuration for the project. This is the document that informs the experiment information such as segmentation. Extremely verbose and should be used for debugging.

Parameters
ParameterTagsDescription
userIdRequiredID for given user
attributesOptionalAll relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id
var attributes = { attributes:{ key:'value', key2:'value2' } }

taplytics.getConfig(userId, attributes, (error, config) => {
	// your code here
})

getFeatureFlags

Returns array of all the enabled feature flags for this project. Each object in the array has name for the name of the feature flag and keyName for the feature flag's key to be used in your code

Parameters
ParameterTagsDescription
userIdRequiredID for given user
attributesOptionalAll relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id
var attributes = { attributes:{ key:'value', key2:'value2' } }

taplytics.getFeatureFlags(userId, attributes, (error, featureFlags) => {
	// your code here
})

isFeatureFlagEnabled

Returns true or false depending if the keyName provided corresponds to an enabled featureFlag in your Taplytics project

Parameters
ParameterTagsDescription
userIdRequiredID for given user
keyNameRequiredKey name for the feature flag
attributesOptionalAll relevant attributes associated with the user
callbackOptionalProvide a callback if you don't want to use a promise
Example Usage
var userId = user_id
var attributes = { attributes:{ key:'value', key2:'value2' } }

taplytics.isFeatureFlagEnabled(userId, attributes, (error, enabled) => {
	if (enabled) {
		enableFeature();
	}
})

FAQs

Package last updated on 10 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts