Insightcn

Event Tracking

Track component usage with Insightcn.

Event tracking is the core feature of Insightcn. It allows you to track when users install, view, or download components from your registry.

Event Types

Insightcn supports three types of events:

Event TypeDescription
installedUser installed a component via CLI
viewedUser viewed a component in browser
downloadedUser downloaded a component file

How It Works

  1. User performs an action (install, view, or download)
  2. Your app receives the HTTP request
  3. You call captureRegistryEvent with the request
  4. SDK validates the request (checks path and user-agent)
  5. SDK sends the event to the Insightcn backend
  6. You can view analytics in the dashboard

Basic Usage

import { captureRegistryEvent } from "@insightcn/sdk";

const request = new Request("https://your-registry.com/r/ui/button.json", {
  method: "GET",
  headers: { "user-agent": "node-fetch" },
});

// Track an installation event
await captureRegistryEvent(request, "your-api-key", "installed");

Private Events

If you need to track events without validation (e.g., for internal events), use capturePrivateRegistryEvent:

import { capturePrivateRegistryEvent } from "@insightcn/sdk";

// Track without validation
await capturePrivateRegistryEvent(request, "your-api-key", "installed");

Event Data

Each event contains:

  • registryId - The registry identifier
  • type - The event type (installed, viewed, or downloaded)
  • timestamp - When the event occurred
  • ip - Anonymized client IP address
  • userAgent - Client user agent string
  • componentPath - Path to the component in the registry

On this page