MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / StatsProvider

Function StatsProvider

src/context/stats.tsx:109–130  ·  view source on GitHub ↗
({ store: externalStore, children }: Props)

Source from the content-addressed store, hash-verified

107};
108
109export function StatsProvider({ store: externalStore, children }: Props): React.ReactNode {
110 const internalStore = useMemo(() => createStatsStore(), []);
111 const store = externalStore ?? internalStore;
112
113 useEffect(() => {
114 const flush = () => {
115 const metrics = store.getAll();
116 if (Object.keys(metrics).length > 0) {
117 saveCurrentProjectConfig(current => ({
118 ...current,
119 lastSessionMetrics: metrics,
120 }));
121 }
122 };
123 process.on('exit', flush);
124 return () => {
125 process.off('exit', flush);
126 };
127 }, [store]);
128
129 return <StatsContext.Provider value={store}>{children}</StatsContext.Provider>;
130}
131
132export function useStats(): StatsStore {
133 const store = useContext(StatsContext);

Callers

nothing calls this directly

Calls 3

createStatsStoreFunction · 0.85
onMethod · 0.65
offMethod · 0.65

Tested by

no test coverage detected