getDownloadIdentity (downloadMetrics.ts)

clawhub · download-tracking, metrics-aggregation, deduping, time-windowing, analytics

Multilayer mounts nested Kubernetes volumes into container storage layers.

import { v } from "convex/values";
import { internal } from "./_generated/api";
import type { Id } from "./_generated/dataModel";
import { internalMutation } from "./functions";
import { getClientIp } from "./lib/httpRateLimit";
import { RETENTION_STANDARD_BATCH_SIZE } from "./lib/retentionPolicy";
import { hashToken } from "./lib/tokens";
import { insertStatEvent } from "./skillStatEvents";

const DAY_MS = 86_400_000;
const DEDUPE_RETENTION_MS = 14 * DAY_MS;
const PRUNE_BATCH_SIZE = RETENTION_STANDARD_BATCH_SIZE;

const identityKindValidator = v.union(v.literal("user"), v.literal("ip"));

const targetValidator = v.union(
  v.object({ kind: v.literal("skill"), id: v.id("skills") }),
  v.object({ kind: v.literal("package"), id: v.id("packages") }),
);

type DownloadIdentityKind = "user" | "

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key