Socket
Socket
Sign inDemoInstall

statsig-js

Package Overview
Dependencies
Maintainers
1
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statsig-js

Statsig JavaScript client SDK for single user environments.


Version published
Weekly downloads
128K
decreased by-15.21%
Maintainers
1
Weekly downloads
 
Created

What is statsig-js?

The statsig-js npm package is a client-side library for integrating with Statsig, a feature management and experimentation platform. It allows developers to manage feature flags, run A/B tests, and gather insights on user behavior to make data-driven decisions.

What are statsig-js's main functionalities?

Initialize Statsig

This code demonstrates how to initialize the Statsig client with a client API key and user information. Initialization is necessary before using other features of the library.

const statsig = require('statsig-js');

async function initializeStatsig() {
  await statsig.initialize('client-api-key', { userID: 'user123' });
}

initializeStatsig();

Check Feature Gate

This code sample shows how to check if a feature gate is enabled for the current user. Feature gates are used to control the rollout of new features.

async function checkFeatureGate() {
  const isFeatureEnabled = await statsig.checkGate('new_feature');
  if (isFeatureEnabled) {
    console.log('Feature is enabled');
  } else {
    console.log('Feature is disabled');
  }
}

checkFeatureGate();

Get Experiment Parameter

This code demonstrates how to retrieve a specific parameter from an experiment. This is useful for running A/B tests and customizing user experiences based on experiment results.

async function getExperimentParameter() {
  const parameter = await statsig.getExperimentParameter('experiment_name', 'parameter_name');
  console.log('Experiment parameter value:', parameter);
}

getExperimentParameter();

Log Event

This code sample shows how to log custom events to Statsig. Logging events helps in tracking user interactions and gathering data for analysis.

async function logEvent() {
  await statsig.logEvent('button_click', { buttonName: 'signup' });
  console.log('Event logged');
}

logEvent();

Other packages similar to statsig-js

Keywords

FAQs

Package last updated on 09 Nov 2023

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