From 7f86335cfa1960a86aacadbcd8949ecced0c1f41 Mon Sep 17 00:00:00 2001 From: enesgules Date: Thu, 30 Oct 2025 11:46:03 +0300 Subject: [PATCH] feat: log sse usage counter --- src/index.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/index.ts b/src/index.ts index 592db17..237a311 100644 --- a/src/index.ts +++ b/src/index.ts @@ -69,6 +69,18 @@ const CLI_PORT = (() => { // Store SSE transports by session ID const sseTransports: Record = {}; +// Counter for SSE deprecation notice usage +let sseDeprecationCounter = 0; + +/** + * Tracks SSE deprecation notice usage and logs every 10th occurrence + */ +function trackSseDeprecation(): void { + sseDeprecationCounter++; + if (sseDeprecationCounter % 10 === 0) { + console.error(`SSE deprecated usage count: ${sseDeprecationCounter}`); + } +} function getClientIp(req: IncomingMessage): string | undefined { // Check both possible header casings @@ -166,6 +178,11 @@ For ambiguous queries, request clarification before proceeding with a best-guess const resultsText = formatSearchResults(searchResponse); + // Track SSE deprecation usage + if (transportType === "sse") { + trackSseDeprecation(); + } + const responseText = `${transportType === "sse" ? sseDeprecationNotice + "\n\n" : ""}Available Libraries (top matches): Each result includes: @@ -240,6 +257,11 @@ ${resultsText}`; }; } + // Track SSE deprecation usage + if (transportType === "sse") { + trackSseDeprecation(); + } + const responseText = (transportType === "sse" ? sseDeprecationNotice + "\n\n" : "") + fetchDocsResponse;