Insightcn

captureRegistryEvent

Track a registry installation event.

Track a registry installation event. Validates the request before sending.

Signature

function captureRegistryEvent(
  request: Request,
  token: string,
  type?: "installed" | "viewed" | "downloaded",
  config?: InsightcnConfig
): Promise<void>;

Parameters

ParameterTypeDefaultDescription
requestRequest-The incoming HTTP request
tokenstring-Your registry API key
typestring"installed"Event type: "installed", "viewed", or "downloaded"
configobject{}Optional configuration override

Config Options

PropertyTypeDescription
apiUrlstringOverride default API URL

Example

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

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

await captureRegistryEvent(request, "your-api-key", "installed");

Errors

Throws an error if:

  • The request path doesn't match the expected format
  • The user-agent header is missing
  • The API key is invalid
  • The backend request fails

On this page