Implementation of MCP for LLM Observability capture to PostHig
Some checks failed
CI - Semantic Release / Semantic Release (push) Failing after 7m48s
Some checks failed
CI - Semantic Release / Semantic Release (push) Failing after 7m48s
This commit is contained in:
32
src/controllers/posthog-llm.controller.ts
Normal file
32
src/controllers/posthog-llm.controller.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Logger } from '../utils/logger.util.js';
|
||||
import { ControllerResponse } from '../types/common.types.js';
|
||||
import postHogLlmService from '../services/posthog-llm.service.js';
|
||||
|
||||
const logger = Logger.forContext('controllers/posthog-llm.controller.ts');
|
||||
|
||||
async function capture(args: {
|
||||
eventName: string;
|
||||
distinctId: string;
|
||||
properties: Record<string, unknown>;
|
||||
}): Promise<ControllerResponse> {
|
||||
const methodLogger = logger.forMethod('capture');
|
||||
methodLogger.debug('Capturing PostHog event...');
|
||||
methodLogger.debug('Arguments:', args);
|
||||
|
||||
try {
|
||||
await postHogLlmService.capture(args);
|
||||
return {
|
||||
content: 'Event captured successfully.',
|
||||
};
|
||||
} catch (error) {
|
||||
methodLogger.error('Error capturing event:', error);
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : 'Unknown error';
|
||||
methodLogger.error('Error capturing event:', errorMessage);
|
||||
return {
|
||||
content: `Failed to capture event: ${errorMessage}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default { capture };
|
||||
Reference in New Issue
Block a user