npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

taplytics

v1.2.0

Published

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

Downloads

360

Readme

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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for current user | | attributes | Optional | Provide all relevant attributes associated with the user | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | attributes | Optional | All relevant attributes associated with the user | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | experimentName | Required | Name of an Experiment | | attributes | Optional | All relevant attributes associated with the user | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | varName | Required | name of variable | | defaultValue | Required | default value to be used if user does not have variable available. | | attributes | Optional | All relevant attributes associated with the user | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | body | Optional | Provide an array of events, as well as all additional relevant user attributes. | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | attributes | Optional | All relevant attributes associated with the user | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | attributes | Optional | All relevant attributes associated with the user | | callback | Optional | Provide 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

| Parameter | Tags | Description | |-----------|------|-------------| | userId | Required | ID for given user | | keyName | Required | Key name for the feature flag | | attributes | Optional | All relevant attributes associated with the user | | callback | Optional | Provide 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();
	}
})