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

@felipelealdefaria/experiments-service

v1.1.1

Published

Experiments service for creating A/B tests using lib sixpack-client

Downloads

18

Readme

Experiments Service

npm version npm bundle size (minified) npm bundle minzipped size (minzipped) repo stars repo license

Experiments service for creating A/B tests using lib sixpack-js.

Requirements

Clone this repo sixpack-docker and run:

docker-compose up
API URI: http://127.0.0.1:5000/
SIXPACK DASH: http://127.0.0.1:5001/

Installation

yarn add @felipelealdefaria/experiments-service
# or
npm i @felipelealdefaria/experiments-service

Usage

import experiment from '@felipelealdefaria/experiments-service'

1) Initialize:

This is required before any other methods can be called.

await experiment.init(params: InitParams): Promise<InitResponse>
InitParams:
- baseUrl: string
- timeout?: number (default: 8000)
InitResponse:
- session: unknown
- error?: boolean
- success?: boolean
- message?: string

2) Experiment Participate:

To start an experiment (test a/b).

await experiment.participate(params: ParticipateParams) => Promise<ParticipateResponse>
ParticipateParams
- session: unknown
- traffic?: number (default: 1) // means 50% for each variable
- variationsName: string[]
- experimentName: string
ParticipateResponse
- alternativeName?: string | null
- experimentName?: string | null
- error?: boolean
- success?: boolean
- message?: string

3) Experiment Convert:

To convert an experiment KPI.

await convert(params: ConvertParams) => Promise<ConvertResponse>
ConvertParams
- kpi?: string
- session: unknown
- experimentName: string
ConvertResponse
- kpi?: string
- experimentName?: string
- alternativeName?: string
- error?: boolean
- success?: boolean
- message?: string

4) A/B Test with React.Js:

return (
  <>
    { res?.alternativeName === 'variant_option'} ? <ComponentA /> : <ComponentB /> }
  </>
)

[OBS] To force the variation, insert in your browser cookies:

key: force-${experimentName}
value: ${variation_option}

Possible error for those using webpack

The dependency of the project, sixpack-client has incompatibility with some versions of the webpack. The common error in this case may be linked to not being able to resolve the http and buffer dependencies.

To fix it, in your webpack.config.js file:

resolve: {
    fallback: {
      http: require.resolve('stream-http'),
      buffer: require.resolve('buffer/')
    }
}

Service's Architecture

Service created using the principles of Clean Architecture with the intention of facilitating maintenance and a possible exchange of lib used to perform A/B tests.

image