get_analytics
Retrieve usage statistics for personas from local data to track engagement patterns and optimize persona selection strategies.
Instructions
페르소나 사용 통계를 조회합니다 (로컬 데이터만)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:414-421 (registration)Registers the 'get_analytics' tool in the ListTools response, providing name, description, and empty input schema (no parameters required).{ name: 'get_analytics', description: '페르소나 사용 통계를 조회합니다 (로컬 데이터만)', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:581-609 (handler)The main handler for the 'get_analytics' tool. Loads analytics data, sorts and formats usage statistics and top context patterns, and returns a formatted text block with the results.case 'get_analytics': { const analytics = await loadAnalytics(); const usageList = Object.entries(analytics.usage) .sort((a, b) => b[1] - a[1]) .map(([name, count]) => ` ${name}: ${count} uses`) .join('\n'); const topPatterns: Record<string, string[]> = {}; Object.entries(analytics.contextPatterns).forEach(([persona, patterns]) => { const sorted = Object.entries(patterns) .sort((a, b) => b[1] - a[1]) .slice(0, 3); topPatterns[persona] = sorted.map(([kw]) => kw); }); const patternsList = Object.entries(topPatterns) .map(([persona, keywords]) => ` ${persona}: ${keywords.join(', ')}`) .join('\n'); return { content: [ { type: 'text', text: `📊 Persona Usage Analytics\n\n사용 횟수:\n${usageList || ' (no data)'}\n\n주요 컨텍스트 패턴:\n${patternsList || ' (no data)'}\n\n💡 이 데이터는 로컬에만 저장되며 전송되지 않습니다.`, }, ], }; }
- src/index.ts:143-149 (helper)Helper function that loads the analytics data from the local JSON file '~/.persona/.analytics.json', returning default empty object if file doesn't exist.async function loadAnalytics(): Promise<Analytics> { try { const data = await fs.readFile(ANALYTICS_FILE, 'utf-8'); return JSON.parse(data) as Analytics; } catch { return { usage: {}, contextPatterns: {} }; }
- src/index.ts:37-40 (schema)TypeScript interface defining the structure of the analytics data used by the get_analytics tool.interface Analytics { usage: Record<string, number>; contextPatterns: Record<string, Record<string, number>>; }