claude-roi 0.8.8 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/metrics.js +23 -8
package/package.json
CHANGED
package/src/metrics.js
CHANGED
|
@@ -581,8 +581,10 @@ export function computeMetrics(correlatedSessions, organicCommits, commitsByRepo
|
|
|
581
581
|
day.totalTokens += dayData.inputTokens + dayData.outputTokens + dayData.cacheReadTokens + (dayData.cacheCreationTokens || 0);
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
// Session count attributed to
|
|
585
|
-
|
|
584
|
+
// Session count attributed to each day it had activity
|
|
585
|
+
for (const date of Object.keys(usage)) {
|
|
586
|
+
ensureDay(date).sessions++;
|
|
587
|
+
}
|
|
586
588
|
|
|
587
589
|
// Commits attributed to their own timestamps
|
|
588
590
|
for (const commit of session.commits) {
|
|
@@ -740,12 +742,25 @@ export function computeMetrics(correlatedSessions, organicCommits, commitsByRepo
|
|
|
740
742
|
if (dateStr === todayStr) { costByPeriod.today.cost += dayData.cost; costByPeriod.today.tokens += dTok; }
|
|
741
743
|
}
|
|
742
744
|
|
|
743
|
-
// Sessions count
|
|
744
|
-
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
745
|
+
// Sessions count if they had any activity in the period (via dailyUsage dates)
|
|
746
|
+
const usageDates = Object.keys(usage);
|
|
747
|
+
const hasActivityToday = usageDates.includes(todayStr);
|
|
748
|
+
const hasActivityThisWeek = usageDates.some(d => new Date(d + 'T12:00:00') >= startOfWeek);
|
|
749
|
+
const hasActivityThisMonth = usageDates.some(d => new Date(d + 'T12:00:00') >= startOfMonth);
|
|
750
|
+
costByPeriod.allTime.sessions++;
|
|
751
|
+
if (hasActivityThisMonth) costByPeriod.month.sessions++;
|
|
752
|
+
if (hasActivityThisWeek) costByPeriod.week.sessions++;
|
|
753
|
+
if (hasActivityToday) costByPeriod.today.sessions++;
|
|
754
|
+
|
|
755
|
+
// Commits count by their actual commit date, not session start date
|
|
756
|
+
for (const commit of (session.commits || [])) {
|
|
757
|
+
const commitDateStr = toDateStr(commit.timestamp);
|
|
758
|
+
const commitDate = new Date(commitDateStr + 'T12:00:00');
|
|
759
|
+
costByPeriod.allTime.commits++;
|
|
760
|
+
if (commitDate >= startOfMonth) costByPeriod.month.commits++;
|
|
761
|
+
if (commitDate >= startOfWeek) costByPeriod.week.commits++;
|
|
762
|
+
if (commitDateStr === todayStr) costByPeriod.today.commits++;
|
|
763
|
+
}
|
|
749
764
|
}
|
|
750
765
|
|
|
751
766
|
const summary = {
|