Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@4a/abtest

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4a/abtest

abtest,AB实验模型

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Abtest

流量均衡AB实验分组策略

Install

npm i @4a/abtest

Usage

根据abtestIdid地址执行流量均衡分组

// abtest依赖redis
// redis实例需支持promise,推荐配合ioredis使用
import ABTest from '@4a/abtest'

// or
const ABTest = require('@4a/abtest').default.register(redis)

// async函数内调用
return await ABTest.grouping(testId, id) // Number

// 设置redis过期时间,默认7d
// 实验停止后,redis关联key 7天后过期
// 实验期间每次命中实验都会刷新有效期
return await ABTest.grouping(testId, id, 7 * 60 * 60)

Notes

# 
# 1、流量均衡分组
# 2、默认分组结果 a:1, b:2, c:0
# 3、根据id来进行固定分组
# 4、可同时进行多个实验,按照abtestId区分
# 
# 5、前端实验分组单步时长,过期时间前端可自行设置
# 
# c:0 C组表示意外分组流量,其他分组失败的流量也会归到C组
#

Example

npm test

DEBUG=abtest npm test

Keywords

FAQs

Package last updated on 18 Jan 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc