Create, update, and delete experiments and determine if they are active for users/audiences.
npm install @toggles/experimentsCreate, update, and delete experiments and determine if they are active for users/audiences.
Install with npm.
``sh`
$ npm i @toggles/experiments
`js
const toggles = require('@toggles/experiments');
const client = toggles({
apiKey: 'KEY',
})
async function main() {
const {uuid} = await toggles.createExperiment({name: 'foo'})
await toggles.updateExperiment(uuid, {name: 'bar', percent: 100})
const experiments = await toggles.getExperiments()
const experiment = await toggles.getExperimentById(uuid)
const active = await toggles.isExperimentActive(uuid, {uniqueId: 'foo@bar.co'})
}
`
`js`
const options = {
apiKey: 'string', // This comes from the Settings tab of the Dashboard.
}
const client = toggles.createClient(options)
`js
const params = {
name: 'string',
}
const experiment = await client.createExperiment(params)
console.log(experiment)
// {
// description: 'string',
// enabled: boolean,
// name: 'string',
// percent: number,
// uuid: 'string',
// }
`
`js
const success = await client.createExperiment(experiment.uuid)
console.log(success) // boolean
`
`js`
const key = client.getAPIKey()
`js`
const url = client.getAPIUrl()
`js
const experiment = await client.getExperiment(experiment.uuid)
console.log(experiment)
// {
// description: 'string',
// enabled: boolean,
// name: 'string',
// percent: number,
// uuid: 'string',
// }
`
`js
const experiments = await client.getExperiments()
console.log(experiment)
// [
// {
// description: 'string',
// enabled: boolean,
// name: 'string',
// percent: number,
// uuid: 'string',
// },
// ]
`
`js
const experiment = client.getLocalExperiment(experiment.uuid)
console.log(experiment)
// {
// description: 'string',
// enabled: boolean,
// name: 'string',
// percent: number,
// uuid: 'string',
// }
`
`js
const params = {
uniqueId: 'string', // optional
}
const active = await client.isExperimentActive(experiment.uuid, params)
console.log(active) // boolean
`
`js`
client.setAPIKey('KEY')
`js
const params = {
description: 'string',
enabled: true,
name: 'string',
percent: 100,
}
const experiment = await client.updateExperiment(experiment.uuid, params)
console.log(experiment)
// {
// description: 'string',
// enabled: boolean,
// name: 'string',
// percent: number,
// uuid: 'string',
// }
``
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Copyright © 2019 []
Licensed under the MIT license.
*
_This file was generated by readme-generator on June 21, 2019._