fix(langfuse): align startup fanout gate

This commit is contained in:
Ravi Kumar L 2026-07-10 21:34:20 +02:00
parent eb93d48608
commit d303de5742
3 changed files with 22 additions and 3 deletions

View file

@ -104,6 +104,8 @@ afterEach(() => {
delete process.env.ANALYTICS_GTM_ID;
delete process.env.CUSTOM_FOOTER;
delete process.env.HELP_AND_FAQ_URL;
delete process.env.LANGFUSE_FANOUT_ENABLED;
delete process.env.LANGFUSE_FANOUT_COLLECTOR_URL;
});
describe('GET /api/config', () => {
@ -383,6 +385,23 @@ describe('GET /api/config', () => {
expect(response.body.conversationImportMaxFileSize).toBe(5000000);
});
it('should advertise Langfuse fanout only when the toggle and collector URL are configured', async () => {
mockGetAppConfig.mockResolvedValue(baseAppConfig);
process.env.LANGFUSE_FANOUT_ENABLED = 'true';
const app = createApp(mockUser);
let response = await request(app).get('/api/config');
expect(response.body.langfuseFanoutEnabled).toBe(false);
process.env.LANGFUSE_FANOUT_COLLECTOR_URL = ' ';
response = await request(app).get('/api/config');
expect(response.body.langfuseFanoutEnabled).toBe(false);
process.env.LANGFUSE_FANOUT_COLLECTOR_URL = 'http://langfuse-fanout:4318';
response = await request(app).get('/api/config');
expect(response.body.langfuseFanoutEnabled).toBe(true);
});
it('should include post-login informational fields', async () => {
process.env.ANALYTICS_GTM_ID = 'GTM-XYZ';
process.env.CUSTOM_FOOTER = 'authenticated footer text';

View file

@ -1,6 +1,7 @@
const express = require('express');
const {
isEnabled,
isLangfuseFanoutEnabled,
getBalanceConfig,
getCloudFrontConfig,
resolveBuildInfo,
@ -277,9 +278,7 @@ router.get('/', async function (req, res) {
conversationImportMaxFileSize: process.env.CONVERSATION_IMPORT_MAX_FILE_SIZE_BYTES
? parseInt(process.env.CONVERSATION_IMPORT_MAX_FILE_SIZE_BYTES, 10)
: 0,
langfuseFanoutEnabled: /^(true|1|yes|on)$/i.test(
(process.env.LANGFUSE_FANOUT_ENABLED ?? '').trim(),
),
langfuseFanoutEnabled: isLangfuseFanoutEnabled(),
...(cloudFront ? { cloudFront } : {}),
...(rum ? { rum } : {}),
};

View file

@ -1,2 +1,3 @@
export * from './feedback';
export * from './trace';
export { isLangfuseFanoutEnabled } from './config';