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

insight-sdk

v1.1.9

Published

A React SDK for displaying insights with interactive charts and data visualizations

Downloads

4,238

Readme

Insight SDK

A React SDK for displaying insights with interactive charts and data visualizations. Built with TypeScript and powered by Recharts.

Features

  • 📊 Interactive Charts: Trend and contributor insights with responsive visualizations
  • 🎨 Customizable: Flexible styling and configuration options
  • 📱 Responsive: Mobile-friendly charts that adapt to different screen sizes
  • TypeScript: Full type safety and IntelliSense support
  • 🪝 React Hooks: Modern React patterns with hooks for state management
  • 🧹 Linting: ESLint configured for code quality
  • Error Handling: Shows errors for wrong data, empty array for 0 data
  • 🦴 Skeleton Loading: Animated skeleton states during data fetch
  • Prop Validation: TypeScript interfaces ensure valid props
  • 💾 Caching: In-memory caching for performance
  • 🔄 Polling: refreshInterval={3000} for data updates
  • 🛡️ Error Boundary: Catches and handles component errors
  • 📦 Min Dependencies: Only tslib, peer deps for React

Installation

npm install insight-sdk
npm install react react-dom  # Peer deps

Quick Start

import { Insight } from "insight-sdk";

const dataResolver = async (metric, grain, fromTime, toTime) => {
  // Fetch your data
  return [{ date: "2024-01-01", value: 1200 }];
};

<Insight
  type="trend"
  metric="page_views"
  timeGrain="daily"
  timeRange={30}
  dataResolver={dataResolver}
/>;

API Reference

<Insight /> Component

The main component for rendering insights.

Props

| Prop | Type | Required | Description | | ------------------------- | ---------------------------------- | -------- | ---------------------------------------------------------------------------- | | type | "trend" \| "contributor" | ✅ | Type of insight to display | | metric | string | ✅ | The metric to analyze (e.g., "page_views", "revenue") | | dimension | string | ❌ | Dimension for contributor insights (e.g., "country", "device") | | timeGrain | "daily" \| "weekly" \| "monthly" | ✅ | Time granularity for data aggregation | | timeRange | number | ✅ | Number of days to look back from today | | dataResolver | function | ✅ | Async function to fetch metric data | | dimensionValuesResolver | function | ❌ | Async function to fetch dimension values (required for contributor insights) | | width | string \| number | ❌ | Width of the chart (default: "100%") | | height | string \| number | ❌ | Height of the chart (default: "400px") | | refreshInterval | number | ❌ | Polling interval in ms (default: 0, no polling) |

Usage Examples

Trend Insight

Displays a line chart showing how a metric changes over time.

import { Insight } from "insight-sdk";

const dataResolver = async (metric, grain, fromTime, toTime) => {
  // Example: Fetch daily page views for the last 30 days
  const data = [
    { date: "2024-01-01", value: 1200 },
    { date: "2024-01-02", value: 1350 },
    { date: "2024-01-03", value: 1180 },
  ];
  return data;
};

<Insight
  type="trend"
  metric="page_views"
  timeGrain="daily"
  timeRange={30}
  dataResolver={dataResolver}
/>;

Contributor Insight

Displays a stacked bar chart showing how different dimension values contribute to the metric.

import { Insight } from "insight-sdk";

const dataResolver = async (metric, grain, fromTime, toTime) => {
  // Example: Fetch contributor data
  const data = [
    { dimension: "desktop", value: 800 },
    { dimension: "mobile", value: 600 },
    { dimension: "tablet", value: 200 },
  ];
  return data;
};

const dimensionValuesResolver = async (metric, dimension) => {
  // Return available dimension values
  return ["desktop", "mobile", "tablet"];
};

<Insight
  type="contributor"
  metric="page_views"
  dimension="device"
  timeGrain="daily"
  timeRange={30}
  dataResolver={dataResolver}
  dimensionValuesResolver={dimensionValuesResolver}
/>;

License

ISC License - see LICENSE file for details. "