mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-01 05:00:46 +00:00
fix(insight): count only user interactions in metrics
- Update totalMessages to count only user messages and slash commands - Update heatmap to reflect only user interactions - Update activeHours to reflect only user interactions - Update tests to verify slash commands are counted correctly This ensures the insight report accurately reflects actual user engagement rather than including internal tool calls and system events. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
c948e0c6e9
commit
f47bef1ded
2 changed files with 23 additions and 6 deletions
|
|
@ -872,6 +872,16 @@ describe('DataProcessor', () => {
|
|||
cwd: '',
|
||||
version: '',
|
||||
},
|
||||
{
|
||||
sessionId: 'session1',
|
||||
timestamp: '2025-01-15T10:01:00Z',
|
||||
type: 'system',
|
||||
subtype: 'slash_command',
|
||||
uuid: '',
|
||||
parentUuid: null,
|
||||
cwd: '',
|
||||
version: '',
|
||||
},
|
||||
{
|
||||
sessionId: 'session1',
|
||||
timestamp: '2025-01-15T10:05:00Z',
|
||||
|
|
@ -909,7 +919,7 @@ describe('DataProcessor', () => {
|
|||
).generateMetrics(files);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
totalMessages: 3,
|
||||
totalMessages: 2,
|
||||
totalSessions: 1,
|
||||
heatmap: expect.any(Object),
|
||||
activeHours: expect.any(Object),
|
||||
|
|
|
|||
|
|
@ -842,7 +842,6 @@ None captured`;
|
|||
for (const fileInfo of batch) {
|
||||
try {
|
||||
const records = await readJsonlFile<ChatRecord>(fileInfo.path);
|
||||
totalMessages += records.length;
|
||||
|
||||
// Process each record
|
||||
for (const record of records) {
|
||||
|
|
@ -850,11 +849,19 @@ None captured`;
|
|||
const dateKey = this.formatDate(timestamp);
|
||||
const hour = timestamp.getHours();
|
||||
|
||||
// Update heatmap (count of interactions per day)
|
||||
heatmap[dateKey] = (heatmap[dateKey] || 0) + 1;
|
||||
// Count user messages and slash commands (actual user interactions)
|
||||
const isUserMessage = record.type === 'user';
|
||||
const isSlashCommand =
|
||||
record.type === 'system' && record.subtype === 'slash_command';
|
||||
if (isUserMessage || isSlashCommand) {
|
||||
totalMessages++;
|
||||
|
||||
// Update active hours
|
||||
activeHours[hour] = (activeHours[hour] || 0) + 1;
|
||||
// Update heatmap (count of user interactions per day)
|
||||
heatmap[dateKey] = (heatmap[dateKey] || 0) + 1;
|
||||
|
||||
// Update active hours
|
||||
activeHours[hour] = (activeHours[hour] || 0) + 1;
|
||||
}
|
||||
|
||||
// Track session times
|
||||
if (!sessionStartTimes[record.sessionId]) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue