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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@census-ai/census-sdk

v0.4.6

Published

Official Census SDK for integrating feedback, knowledge base, and analytics into your application

Readme

@census-ai/census-sdk

Official Census SDK for integrating feedback collection, knowledge base, and analytics into your application.

Installation

npm install @census-ai/census-sdk
# or
yarn add @census-ai/census-sdk
# or
pnpm add @census-ai/census-sdk

Quick Start

Vanilla JavaScript/TypeScript

import { createCensus } from '@census-ai/census-sdk';

// Initialize the SDK
const census = createCensus({
  apiKey: 'cs_live_your_key_here',
  debug: true, // Enable debug logging (optional)
});

// Identify users
await census.identify({
  userId: 'user_123',
  email: '[email protected]',
  name: 'John Doe',
  organizationId: 'org_456',
  organizationName: 'Acme Inc',
});

// Submit feedback
await census.submitFeedback({
  type: 'bug_report',
  message: 'The submit button is not working on Firefox',
});

// Get knowledge base articles
const { articles } = await census.getArticles();
const article = await census.getArticle('getting-started');

// Track custom events
await census.track('button_clicked', { buttonId: 'cta' });

React

import { CensusProvider, FeedbackButton, KnowledgeBase } from '@census-ai/census-sdk/react';

function App() {
  return (
    <CensusProvider
      apiKey="cs_live_your_key_here"
      user={{ userId: 'user_123', email: '[email protected]' }}
    >
      <YourApp />
      <FeedbackButton position="bottom-right" />
    </CensusProvider>
  );
}

function HelpPage() {
  return <KnowledgeBase showSearch showCategories />;
}

API Reference

Core Client

createCensus(config)

Creates a new Census client instance.

const census = createCensus({
  apiKey: string;      // Required: Your Census API key
  baseUrl?: string;    // Optional: Custom API base URL
  debug?: boolean;     // Optional: Enable debug logging
});

census.identify(user)

Identify a user for tracking. Call this when a user logs in.

await census.identify({
  userId: string;           // Required: Unique user ID
  email?: string;           // User's email
  name?: string;            // User's display name
  avatarUrl?: string;       // URL to avatar image
  metadata?: object;        // Custom properties
  organizationId?: string;  // User's organization ID
  organizationName?: string;
});

census.submitFeedback(options)

Submit feedback, bug reports, or feature requests.

await census.submitFeedback({
  type: 'feedback' | 'bug_report' | 'feature_request' | 'article_rating';
  message?: string;     // Required for non-article_rating types
  rating?: number;      // 1-5, for article ratings
  helpful?: boolean;    // For article ratings
  articleId?: string;   // For article ratings
  metadata?: object;    // Additional data
});

census.getArticles(options?)

Fetch published articles from the knowledge base.

const { articles, pagination } = await census.getArticles({
  category?: string;   // Filter by category
  search?: string;     // Search query
  limit?: number;      // Max results (default: 50)
  offset?: number;     // Pagination offset
});

census.getArticle(slugOrId)

Fetch a single article by slug or ID.

const article = await census.getArticle('getting-started');

census.track(eventType, properties?)

Track custom analytics events.

await census.track('page_viewed', { page: '/pricing' });
await census.track('button_clicked', { buttonId: 'signup' });

React Components

<CensusProvider>

Wrap your app with this provider to use Census hooks and components.

<CensusProvider
  apiKey="cs_live_xxx"
  user={{ userId: 'user_123', email: '[email protected]' }}
  theme={{ primaryColor: '#6366f1' }}
>
  {children}
</CensusProvider>

<FeedbackButton>

Floating feedback button with modal form.

<FeedbackButton
  position="bottom-right"     // Position on screen
  text="Feedback"             // Button text
  allowedTypes={['feedback', 'bug_report', 'feature_request']}
  onSubmit={(feedback) => console.log('Submitted:', feedback)}
/>

<KnowledgeBase>

Embeddable knowledge base component.

<KnowledgeBase
  showSearch={true}
  showCategories={true}
  defaultCategory="getting-started"
  onArticleView={(article) => console.log('Viewed:', article.title)}
/>

React Hooks

useCensus()

Access the Census client directly.

const census = useCensus();
await census.track('event_name');

useFeedback()

Submit feedback with loading/success state.

const { submitFeedback, isSubmitting, isSuccess, error } = useFeedback();

useArticles(options?)

Fetch articles with loading state.

const { articles, isLoading, error, refetch } = useArticles({ category: 'guides' });

useArticle(slugOrId)

Fetch a single article.

const { article, isLoading, error } = useArticle('getting-started');

useIdentify()

Identify users with loading state.

const { identify, isIdentifying, isIdentified } = useIdentify();

useTrack()

Track events.

const { track, trackBatch } = useTrack();
await track('button_clicked', { buttonId: 'cta' });

TypeScript

The SDK is written in TypeScript and includes full type definitions. All types are exported from the main package:

import type {
  CensusConfig,
  UserIdentity,
  FeedbackOptions,
  Article,
  ArticlesResponse,
} from '@census-ai/census-sdk';

License

MIT