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

@gaoding/gd-abtest

v0.1.13

Published

Gaoding ABTest SDK

Downloads

38

Readme

gd-abtest 稿定 ABTest SDK

安装

npm install @gaoding/gd-abtest

使用

import gdABTest from '@gaoding/gd-abtest';

SDK Methods

init()

js SDK 初始化

gdABTest.init({
  app_key: 'application appkey', //应用对应的 appkey,必填
  app_name: 'application appName', // 应用对应的 appName,必填
  user_id:  '', // 客户端能唯一标识用户的ID,必填
  device_id: '', // 用户设备id,必填 
  is_login: '' // 用户是否登录,必填  0:未登陆,1:登陆
})

getExps()

获取所有匹配的版本信息,并缓存到本地,缓存时间为30分钟

const exps = gdABTest.getExps()

getValue()

根据变量名称获取所匹配的版本信息的变量值

gdABTest.getValue(variableName, defaultVaule).then(flag => {
  console.log(flag);
})

// 例如输出:
// sdjjkxx_0

当需要获取多个变量,可入参一个变量名数组,相应的 defaultVaule 也需要设置为数组

gdABTest.getValue(['variableName_1', 'variableName_2'], ['defaultVaule_1', 'defaultVaule_1']).then(flag => {
  console.log(flag);
})

// 例如输出:
// 匹配情况 ['sdjjkxx_0', 'sdjjkxx_1']
// 部分不匹配情况 ['sdjjkxx_0', 'defaultVaule_1']
// 不匹配情况 ['defaultVaule_1', 'defaultVaule_1']

setUserId()

设置 userId

gdABTest.setUserId(userId)

setDeviceId()

设置 deviceId

gdABTest.setDeviceId(deviceId)

on('fetch', () => {})

网络请求钩子。 监听 fetch 事件,当sdk发起网络请求会触发该钩子事件

gdABTest.on('fetch', (data: object[]) =>{
  console.log(data); // 返回所有版本信息
})

on('windTrack', () => {})

无垠埋点钩子,监听 windTrack 事件,当 this.getValue() 后触发一次埋点上报

gdABTest.on('windTrack', (data: object) =>{
  console.log(data); // 埋点信息
})

// 埋点信息如:
{
  event: 'abtest_track',
  event_id: 125,
  ab_tags: ['xxx_1']
}

getAbTags(eventId)

根据 eventId 获取 abtags

const abTags = getAbTags('event_id')
// 输出:null 或  [mdamday_1]