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

ab-test-sdk

v2.0.0

Published

AB测试平台SDK

Downloads

6

Readme

一、小程序对接

1、已经集成神策 SDK 项目接入

参数说明:

interface AbTestSdkOptions {
  sensors?: any;//将项目神策实例传入abSdk
  appId: number | string;//AB应用ID
  expIds: Array<string | number>;//实验id集合
  env: "production" | "development";//环境    development|production
  authType: "jwt" | "token";	//鉴权方式     token|jwt
  requestFn: (url: string, params: object) => Promise<any>; //请求实例  返回promise对象
}

####接入示例: #####(1)安装 SDK

yarn add ab-test-sdk --save
npm install ab-test-sdk --save  //或者

(2)使用

import AbTestSdk from 'ab-test-sdk/dist/weapp';
//实例化SDK
export const abTest = new AbTestSdk({
  appId: '522065064467890257',
  expIds: [
    '522065614693466192',
    '522065518568407106',
  ],
  sensors: sensors,
  env: 'development',
  authType: 'token',
  requestFn: (url, parmas) => {
    return request({
      method: 'post',
      url,
      data: parmas,
      isNeedAuth: true,
    });
  },
});
//登录之后调用
abTest.init()
//获取实验受众有三个方法fetchCacheABTest、asyncFetchABTest、fastFetchABTest依次是从缓存中获取;优先从缓存中获取、没有则请求接口获取;直接请求接口获取.三个方法可使用方式一致,如下:
//promise方式:
abTest.fastFetchABTest({ expId: '523570893788557370' }).then((data)=>{
	console.log(data)
})
//回调方式
abTest.fastFetchABTest({ expId: '523570893788557370',callBack:(data)=>{
	console.log(data)
} })
     /***data={
                appId: "522065064467890257" ,
                expId: "523570893788557370" ,
                groupId: "523570893788557368",
                sensorEventKey:"align_exp",
                variableKey: "button_align",
                variableType: "string",
                variableValue: "left"
           	 }
            根据variableValue做AB。
    ***/

2、未集成神策 SDK 项目接入

参数说明:

interface AbTestSdkOptions {
  sensorsOptions?: object;//为神策sdk setPara接口的参数
  appId: number | string;//AB应用ID
  expIds: Array<string | number>;//实验id集合
  env: "production" | "development";//环境    development|production
  authType: "jwt" | "token";	//鉴权方式     token|jwt
  requestFn: (url: string, params: object) => Promise<any>; //请求实例  返回promise对象
}

(2)使用

import AbTestSdk from 'ab-test-sdk/dist/weappSensors';
//实例化SDK
export const abTest = new AbTestSdk({
  appId: '522065064467890257',
  expIds: [
    '522065614693466192',
    '522065518568407106',
  ],
  env: 'development',
  authType: 'token',
  requestFn: (url, parmas) => {
    return request({
      method: 'post',
      url,
      data: parmas,
      isNeedAuth: true,
    });
  },
});
//Sensors实例会挂载在abTest上,通过abTest.sensors访问。
console.log(abTest.sensors)
//登录之后调用
abTest.init()
//获取实验受众有三个方法fetchCacheABTest、asyncFetchABTest、fastFetchABTest依次是从缓存中获取;优先从缓存中获取、没有则请求接口获取;直接请求接口获取.三个方法可使用方式一致,如下:
//promise方式:
abTest.fastFetchABTest({ expId: '523570893788557370' }).then((data)=>{
	console.log(data)
})
//回调方式
abTest.fastFetchABTest({ expId: '523570893788557370',callBack:(data)=>{
	console.log(data)
} })
     // data={
                appId: "522065064467890257" ,
                expId: "523570893788557370" ,
                groupId: "523570893788557368",
                sensorEventKey:"align_exp",
                variableKey: "button_align",
                variableType: "string",
                variableValue: "left"
           	 }
            根据variableValue做AB。

一、h5 对接 (未测试)

1、已经集成神策 SDK 项目接入

参数说明:

interface AbTestSdkOptions {
  sensors?: any;//将项目神策实例传入abSdk
  appId: number | string;//AB应用ID
  expIds: Array<string | number>;//实验id集合
  env: "production" | "development";//环境    development|production
  authType: "jwt" | "token";	//鉴权方式     token|jwt
  requestFn: (url: string, params: object) => Promise<any>; //请求实例  返回promise对象
}

接入示例与小程序一致只是引入文件不同(同时支持 script 标签引入):

    import AbTestSdk from 'ab-test-sdk/dist/h5

2、未集成神策 SDK 项目接入

  import AbTestSdk from 'ab-test-sdk/dist/h5Sensors