forked from pipecat-ai/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
257 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useEffect, useRef, useState } from "react"; | ||
|
||
import styles from "./styles.module.css"; | ||
|
||
interface StatsProps { | ||
statsAggregator: StatsAggregator; | ||
} | ||
|
||
const Stats = React.memo( | ||
({ statsAggregator }: StatsProps) => { | ||
const [currentStats, setCurrentStats] = useState<TransformedStats>( | ||
statsAggregator.transformStats() | ||
); | ||
const intervalRef = useRef(0); | ||
|
||
useEffect(() => { | ||
intervalRef.current = setInterval(() => { | ||
setCurrentStats(statsAggregator.transformStats()); | ||
}, 1000); | ||
|
||
return () => { | ||
if (intervalRef.current) { | ||
clearInterval(intervalRef.current); | ||
} | ||
}; | ||
}, [statsAggregator]); | ||
|
||
useEffect(() => () => clearInterval(intervalRef.current), []); // Cleanup | ||
|
||
return ( | ||
<div className={styles.container}> | ||
{currentStats && | ||
Object.entries(currentStats).map(([service, stat]) => ( | ||
<div key={service} className={styles.serviceStat}> | ||
<div className={styles.serviceName}>{service}</div> | ||
<div className={styles.value}> | ||
{stat.metric}: {stat.value.toFixed(2)}s | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}, | ||
() => true | ||
); | ||
|
||
export default Stats; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.container { | ||
display: flex; | ||
flex-flow: row; | ||
gap: 1rem; | ||
} | ||
|
||
.serviceStat { | ||
display: flex; | ||
flex-flow: column wrap; | ||
font-size: var(--font-size-sm); | ||
} | ||
|
||
.serviceName { | ||
font-weight: 500; | ||
} | ||
|
||
.value { | ||
font-family: var(--font-mono); | ||
font-size: var(--font-size-xs); | ||
text-transform: uppercase; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
type Metric = "ttfb"; | ||
|
||
type Stat = [string, Metric, number, number]; | ||
type TransformedStats = { | ||
[key: string]: { | ||
metric: Metric; | ||
value: number; | ||
timeseries: number[] | null; | ||
median: number | null; | ||
high: number | null; | ||
low: number | null; | ||
}; | ||
}; | ||
|
||
interface IStatsAggregator { | ||
stats: Stat[]; | ||
|
||
addStat(stat: Stat): void; | ||
transformStats(): TransformedStats; | ||
} | ||
|
||
declare class StatsAggregator implements IStatsAggregator { | ||
stats: Stat[]; | ||
|
||
constructor(); | ||
addStat(stat: Stat): void; | ||
transformStats(): TransformedStats; | ||
} |
Empty file.
Oops, something went wrong.