@betterdb/semantic-cache
Advanced tools
+25
-3
@@ -48,2 +48,3 @@ "use strict"; | ||
| const EVENT_PREFIX = 'semantic_cache:'; | ||
| const TELEMETRY_USER_AGENT = 'BetterDB-SemanticCache/node'; | ||
| // Build-time placeholders — replaced by scripts/inject-telemetry-defaults.mjs | ||
@@ -131,2 +132,9 @@ // When the placeholder is NOT replaced, the startsWith('__') guard treats it as unset. | ||
| } | ||
| function isFrozenServerless() { | ||
| const env = process.env; | ||
| return Boolean(env.AWS_LAMBDA_FUNCTION_NAME || | ||
| env.K_SERVICE || | ||
| env.FUNCTION_TARGET || | ||
| env.FUNCTIONS_WORKER_RUNTIME); | ||
| } | ||
| class PostHogAnalytics { | ||
@@ -192,2 +200,5 @@ posthog; | ||
| } | ||
| if (props.$raw_user_agent === undefined) { | ||
| props.$raw_user_agent = TELEMETRY_USER_AGENT; | ||
| } | ||
| this.posthog.capture({ | ||
@@ -231,7 +242,18 @@ distinctId: this.distinctId, | ||
| // waitUntil so the invocation stays alive until it completes. The setInterval | ||
| // that long-lived servers rely on is frozen between invocations. | ||
| // that long-lived servers rely on is frozen between invocations. On frozen | ||
| // serverless with no waitUntil (AWS Lambda, Cloud Functions, Azure) delivery | ||
| // is best-effort: the flush is fire-and-forget and the container freezes on | ||
| // return, so it only completes if a later invocation thaws this container. | ||
| // Events are lost if it is reaped while idle. No delivery guarantee exists | ||
| // on these runtimes without a waitUntil equivalent. | ||
| const waitUntil = getRequestWaitUntil(); | ||
| if (!waitUntil) | ||
| if (waitUntil) { | ||
| this.emitSnapshotIfDue(waitUntil); | ||
| return; | ||
| this.emitSnapshotIfDue(waitUntil); | ||
| } | ||
| if (isFrozenServerless()) { | ||
| this.emitSnapshotIfDue((p) => { | ||
| void p; | ||
| }); | ||
| } | ||
| } | ||
@@ -238,0 +260,0 @@ snapshotTick() { |
+1
-1
| { | ||
| "name": "@betterdb/semantic-cache", | ||
| "version": "0.11.1", | ||
| "version": "0.12.0", | ||
| "description": "Valkey-native semantic cache for LLM applications with built-in OpenTelemetry and Prometheus instrumentation", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
414811
0.23%6842
0.32%