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
| Parameter | Type | Default | Description |
|---|---|---|---|
request | Request | - | The incoming HTTP request |
token | string | - | Your registry API key |
type | string | "installed" | Event type: "installed", "viewed", or "downloaded" |
config | object | {} | Optional configuration override |
Config Options
| Property | Type | Description |
|---|---|---|
apiUrl | string | Override 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