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 🙏

© 2026 – Pkg Stats / Ryan Hefner

flowgrid-sdk

v1.4.1

Published

A TypeScript SDK for tracking user events, feature usage, experiments, and feature flags with Flowgrid.

Readme

Flowgrid SDK

npm license types

A production-grade, framework-agnostic TypeScript SDK for product analytics, ecommerce, experiments, and enterprise insights — with a single unified entry point that works in any JavaScript environment (Node, browsers, edge runtimes, React, Vue, Next, Nuxt, Svelte, Angular, etc.).

import { FlowGrid } from "flowgrid-sdk";

// One line. Sane defaults. Auto-instruments sessions, page views,
// performance, heatmaps, and attribution out of the box.
const fg = FlowGrid.init({ webId: "wx_123", apiKey: "pk_xxx" });

// Opt in to session replay (rrweb) when you want it:
FlowGrid.init({
  webId: "wx_123",
  apiKey: "pk_xxx",
  user: { userId: "u_1", traits: { plan: "pro" } },
  replay: { sampleRate: 0.25, maskAllInputs: true },
});

await fg.track("signup_completed", { plan: "pro" });
await fg.experiment("checkout_v2", { variant: "B", userId: "u_1" });
await fg.products.view({ productId: "sku_1", name: "T-Shirt", price: 29, currency: "USD" });

Highlights

  • One class, every featurenew FlowGrid(...) exposes analytics, ecommerce, experiments, and enterprise modules as lazy properties.
  • Framework-agnostic — zero peer dependencies. Works with React, Vue, Next.js, Nuxt, Svelte, Astro, plain Node, Cloudflare Workers, etc.
  • Tree-shake-friendly — also export individual modules (Events, Products, Experiment, …) for minimal bundles.
  • Privacy & consent built-in — DNT/GPC support, ConsentManager, bot filtering.
  • Resilient transport — retry with exponential backoff, sendBeacon fallback, offline localStorage buffering, 10KB payload guard.
  • Identity layer — visitor + session lifecycle, SSR-safe, backwards-compatible with track.js cookies.
  • Strict TypeScript — strong types for every config and response.

Installation

npm install flowgrid-sdk
# or
pnpm add flowgrid-sdk
# or
yarn add flowgrid-sdk

Requires Node >= 18.12. No peer dependencies.


Quick Start

Unified client (recommended)

import { FlowGrid } from "flowgrid-sdk";

const fg = new FlowGrid(
  "web_123",                       // webId
  "https://core.flow-grid.xyz",     // endpoint
  "key_xxx"                        // apiKey
);

// Analytics
await fg.pageViews.track({ url: "/pricing", title: "Pricing" });
await fg.events.track({ eventName: "cta_click", properties: { id: "hero" } });
await fg.identify.identify({ userId: "u_1", traits: { plan: "pro" } });

// Ecommerce
await fg.cart.addItem({
  product: { productId: "sku_1", name: "Widget", price: 29.99, currency: "USD" },
  quantity: 1,
  cartId: "cart_abc",
});

// Experiments
const variant = await fg.experiments.assign({
  experimentId: "checkout_v2",
  userId: "u_1",
});

// Enterprise
await fg.churn.score({ userId: "u_1" });

Available namespaces on FlowGrid:

| Group | Properties | | ----------- | ----------------------------------------------------------------------------------------------------------------------- | | Core | activation, features, prompts, experiments | | Analytics | pageViews, sessions, events, identify, funnels, retention, attribution, heatmaps, performance, replay | | Ecommerce | products, cart, checkout, purchases, refunds, promotions, wishlist, ltv, search, subscriptions | | Enterprise | engagement, cohorts, churn, monetization, multiPathFunnels, support, acquisition, paths, alerts, security, forecasting |

Direct module imports (tree-shaking)

import { Events, Products } from "flowgrid-sdk";

const events = new Events("web_123", "https://core.flow-grid.xyz", "key_xxx");
await events.track({ eventName: "signup", properties: { plan: "pro" } });

Browser script tag (CMS / no-build)

<script src="https://cdn.flow-grid.xyz/flowgrid.min.js"></script>
<script>
  FlowGrid.init({
    webId: "web_abc123",
    apiKey: "key_xxx",
  });

  FlowGrid.track("signup_clicked", { placement: "hero" });
  FlowGrid.identify("user_123", { plan: "pro" });
  FlowGrid.productView({ productId: "sku_1", name: "T-Shirt", price: 29 });
  FlowGrid.addToCart({ productId: "sku_1", name: "T-Shirt", price: 29 }, 1);
</script>

The script-tag API is intentionally small: init, track, page, identify, experiment, productView, addToCart, purchase, consent helpers, and instance() for the full SDK. FlowGrid.init() auto-instruments sessions, page views, SPA route changes, scroll depth, time on page, performance, heatmaps, and attribution by default; session replay is opt-in with replay: true.


Session Replay

Replay is opt-in and browser-only. It uses rrweb dynamically, records DOM/input/scroll/mouse events, and sends sequenced chunks to core with call=replay_chunk.

const fg = FlowGrid.init({
  webId: "wx_123",
  apiKey: "pk_xxx",
  user: { userId: "u_1" },
  replay: {
    sampleRate: 0.25,
    maskAllInputs: true,
    flushIntervalMs: 5000,
    flushBytes: 512 * 1024,
    onFlush: ({ sessionId, sequence, eventsCount }) => {
      console.debug("replay chunk", sessionId, sequence, eventsCount);
    },
  },
});

fg.replay.identify("u_1");
await fg.replay.flush();
fg.replay.stop();

Manual lifecycle control is available when you do not want init-time recording:

const stop = await fg.replay.start({ sampleRate: 1, maskAllInputs: true });
const status = fg.replay.status();

await fg.replay.flush("manual");
stop();

Each replay chunk includes the core ingestion fields web_id, visitor_id, session_id, sequence, started_at, captured_at, events, plus replay metadata such as page_url, idempotency_key, compression, is_final, privacy, flush_reason, dropped_events, and recorder_version.


Server-side / Edge Usage

Works in any JavaScript runtime that supports fetch — Node, Bun, Deno, Cloudflare Workers, Vercel Edge, etc.

// app/api/track/route.ts (Next.js example, but works anywhere)
import { FlowGrid } from "flowgrid-sdk";

const fg = new FlowGrid("web_123", "https://core.flow-grid.xyz", process.env.FG_API_KEY!);

export async function POST(req: Request) {
  const { userId } = await req.json();
  await fg.events.track({ eventName: "server_event", properties: { userId } });
  return Response.json({ ok: true });
}

For Node-style batch jobs, simply create a FlowGrid instance, fire your tracking calls, and let the process exit — events use sendBeacon/fetch and a localStorage-style buffer for resilience.


Cookie Consent

The SDK ships a framework-agnostic ConsentManager. Render your own banner UI in whatever framework you use, and call into the manager to persist preferences.

import { ConsentManager, FlowGridTransport } from "flowgrid-sdk";

const consent = new ConsentManager({
  cookieDomain: ".example.com",
  cookieExpiry: 365,
  respectDNT: true,
  onChange: (prefs) => {
    FlowGridTransport.setConsent({
      analytics: prefs.analytics,
      marketing: prefs.marketing,
    });
  },
});

consent.acceptAll();
consent.rejectNonEssential();
consent.update({ analytics: true, marketing: false, preferences: true });
consent.hasCategory("analytics"); // boolean
consent.reset();

CookieBannerConfig and CookieBannerTheme types are exported from flowgrid-sdk/consent if you want a typed config object to pass to your own banner component.

You can also gate the transport directly without ConsentManager:

import { FlowGridTransport } from "flowgrid-sdk";

FlowGridTransport.setConsent({ analytics: true, marketing: false });
FlowGridTransport.hasConsent("analytics"); // true

Identity & Storage Helpers

import {
  FlowGrid,
  IdentityManager,
  getVisitorId,
  getSessionId,
  getWebId,
  getUTM,
  getUTMHistory,
} from "flowgrid-sdk";

const identity = new IdentityManager({ cookieDomain: ".example.com" });
const visitorId = identity.getVisitorId();

// Pass to FlowGrid for shared identity across modules
const fg = new FlowGrid(
  "web_123",
  "https://core.flow-grid.xyz",
  "key_xxx",
  visitorId,
  identity
);

Package Exports

| Import path | Description | | -------------------------- | ------------------------------------------------ | | flowgrid-sdk | Unified FlowGrid class + every feature module | | flowgrid-sdk/analytics | Analytics modules only | | flowgrid-sdk/ecommerce | Ecommerce modules only | | flowgrid-sdk/core | Core modules (activation, experiments, prompts) | | flowgrid-sdk/consent | ConsentManager + types | | flowgrid-sdk/types | Shared TypeScript type definitions |


Configuration

The transport accepts an optional FlowGridTransportConfig as its 6th argument:

new FlowGrid(webId, endpoint, apiKey, visitorId, identityManager, {
  botDetection: "block",   // "block" | "tag" | "disabled"
  respectDNT: true,         // honour Do-Not-Track / GPC
  sampleRate: 1.0,          // 0.0 – 1.0
});

Defaults: botDetection: "block", respectDNT: true, sampleRate: 1.0.


Scripts

npm run build          # tsc + webpack production build
npm run build:browser  # browser UMD bundle (flowgrid.min.js)
npm run build:all      # both
npm run build:types    # emit .d.ts only
npm test               # run audit-fixes test suite

Documentation

Full reference: https://flow-grid.xyz/documentation

Contributing

Issues and PRs welcome on GitHub.

License

MIT © Brandon Roulstone