Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.0 KB
Raw Blame
/**
 * chatCore request gamification event (Quality Gate v2 / Fase 9 — chatCore god-file
 * decomposition, #3501).
 *
 * Extracted from handleChatCore: emits the per-request "request" gamification event,
 * fire-and-forget and fail-open. Shared by the non-streaming and streaming success paths (the
 * inline block was duplicated verbatim in both). Guards on a missing api-key id and never throws
 * to the caller — the underlying emit is intentionally not awaited; behaviour is byte-identical to
 * the previous inline blocks.
 */

export async function emitRequestGamificationEvent(args: {
  apiKeyId: string | null | undefined;
  model: string | null | undefined;
  provider: string | null | undefined;
}): Promise<void> {
  if (!args.apiKeyId) return;
  try {
    const { emitGamificationEvent } = await import("@/lib/gamification/events");
    emitGamificationEvent({
      apiKeyId: args.apiKeyId,
      action: "request",
      metadata: { model: args.model, provider: args.provider },
    });
  } catch (_) {
    /* gamification optional */
  }
}