Files
chat/api/server/telemetry.js
zooqueen 48eac75e13 refactor: fork @librechat/api workspace package to @hanzochat/api
Forks the internal @librechat/api workspace package (packages/api) to
@hanzochat/api, matching the app package @hanzochat/chat. De-LibreChats
the package name and puts its build under our control.

Fixes the live prod bug where the deployed chat image shipped a stale
@librechat/api/dist missing the exported handleError(), breaking every
error path with "handleError is not a function" and killing the SSE
stream. A clean build of @hanzochat/api produces dist/index.js that
exports handleError (verified: exports.handleError = handleError).

- packages/api/package.json: name @librechat/api -> @hanzochat/api
- 254 source/config/doc/lockfile sites: @librechat/api -> @hanzochat/api
  (api/, packages/, config/, turbo.json, pnpm-lock.yaml, bun.lock,
   package-lock.json, LLM.md)
- @librechat/api-client (distinct MCP client id string) left untouched
- other @librechat/* packages (client, data-schemas, data-provider)
  left as-is per scope

pnpm install (regenerated lockfile) + build:api green; dist exports
handleError. api/data-schemas/client packages build; full build:packages
and api test:ci are blocked by a PRE-EXISTING, unrelated upstream break
in librechat-data-provider (config.spec.ts / cloudfront-config.spec.ts
reference exports that src/config.ts no longer has) -- out of scope here.
2026-06-19 22:00:19 -07:00

41 lines
941 B
JavaScript

require('dotenv').config();
function isTruthy(value) {
return value?.trim().toLowerCase() === 'true';
}
function isTelemetryEnabled() {
return isTruthy(process.env.OTEL_TRACING_ENABLED) && !isTruthy(process.env.OTEL_SDK_DISABLED);
}
if (isTelemetryEnabled()) {
const {
initializeTelemetry,
telemetryMiddleware,
telemetryErrorMiddleware,
} = require('@hanzochat/api/telemetry');
const controller = initializeTelemetry();
module.exports = {
get enabled() {
return controller.enabled;
},
get status() {
return controller.status;
},
shutdown: controller.shutdown,
telemetryMiddleware,
telemetryErrorMiddleware,
};
} else {
module.exports = {
enabled: false,
get status() {
return 'disabled';
},
shutdown: async () => {},
telemetryMiddleware: (_req, _res, next) => next(),
telemetryErrorMiddleware: (err, _req, _res, next) => next(err),
};
}