Node.js SDK

Install

npm i @bucketco/node-sdk

Initialize bucket

import bucket from "@bucketco/node-sdk"

Create release on Bucket

See Create your first Release

Flag evaluation and feature tracking

Evaluate feature flag

const evaluator = new bucket.flags.Evaluator('sec_prod_G4CYp0UPSs9Qt3fI74jPeX')
const flags = await evaluator.getFeatureFlags({
  context: {
    user: { id: "john_doe" },
    company: { id: "acme_inc" },
  },
});

Track feature usage

// init the script with your publishable key
bucket.init("sec_prod_G4CYp0UPSs9Qt3fI74jPeX", {});

// set current user
bucket.user("john_doe", { name: "John Doe" });

// set current company
bucket.company("acme_inc", { name: "Acme Inc", plan: "pro" });

// track events
bucket.track("sent_message", { foo: "bar" });

Full documentation

Full documentation coming soon.

Last updated