New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@featurevisor/sdk

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@featurevisor/sdk

Featurevisor SDK for Node.js and the browser

  • 0.18.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by38.61%
Maintainers
1
Weekly downloads
 
Created
Source

@featurevisor/sdk

Universal JavaScript SDK for both Node.js and the browser.

Visit https://featurevisor.com/docs/sdks/ for more information.

Installation

$ npm install --save @featurevisor/sdk

Usage

Initialize the SDK:

import { createInstance } from "@featurevisor/sdk";

const sdk = createInstance(options);

Options

KeyTypeDescription
datafileobjectParsed datafile object
datafileUrlstringURL to fetch the datafile from
onReadyfunctionCallback to be called when the SDK is ready to be used
onActivationfunctionCallback to be called when a feature is activated
onRefreshfunctionCallback to be called when the datafile is refreshed
onUpdatefunctionCallback to be called when the datafile is updated
refreshIntervalnumberInterval in seconds to refresh the datafile
handleDatafileFetchfunctionCallback to be called when the datafile is fetched
interceptAttributesfunctionCallback to be called before attributes are used
loggerLoggerLogger object to be used by the SDK

API

getVariation

getVariation(featureKey: string, attributes: Attributes): VariationValue

Also supports additional type specific methods:

  • getVariationBoolean
  • getVariationString
  • getVariationInteger
  • getVariationDouble

getVariable

getVariable(featureKey: string, variableKey: string, attributes: Attributes): VariableValue

Also supports additional type specific methods:

  • getVariableBoolean
  • getVariableString
  • getVariableInteger
  • getVariableDouble
  • getVariableArray
  • getVariableObject
  • getVariableJSON

activate

activate(featureKey: string, attributes: Attributes): VariationValue

Same as getVariation, but also calls the onActivation callback.

This is a convenience method meant to be called when you know the User has been exposed to your Feature, and you also want to track the activation.

Also supports additional type specific methods:

  • activateBoolean
  • activateString
  • activateInteger
  • activateDouble

isReady

isReady(): boolean

Synchonously check if the SDK is ready to be used.

refresh

refresh(): void

Manually refresh datafile.

setLogLevels

setLogLevels(levels: LogLevel[]): void

Accepted values for levels: ["debug", "info", "warn", "error"].

on

on(event: string, callback: function): void

Listen to SDK events, like:

  • ready
  • activation
  • refresh
  • update

addListener

Alias for on method.

off

off(event: string, callback: function): void

removeListener

Alias for off method.

removeAllListeners

removeAllListeners(event?: string): void

License

MIT © Fahad Heylaal

Keywords

FAQs

Package last updated on 12 May 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