Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal UI - Current URL #567

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions internal-ui/src/components/DashboardComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const DashboardComponent = () => {
const [thumbsUp, setThumbsUpCount] = useState(0);
const [thumbsDown, setThumbsDownCount] = useState(0);
const [averageSessionTime, setAverageSessionTime] = useState(0);
// checking which pages were used the most
const [pagesUsed, setPagesUsed] = useState<{ [key: string]: number }>({});

const [contactAdminUsage, setContactAdminUsage] = useState(0);
const [requestTamUsage, setRequestTamUsage] = useState(0);
Expand Down Expand Up @@ -189,6 +191,7 @@ export const DashboardComponent = () => {
let durations = 0; // total time in all filtered sessions

const intentCounts: { [key: string]: number } = {};
const pagesUsed: { [key: string]: number } = {};

filtered.forEach((session) => {
session.messages.forEach((msg) => {
Expand Down Expand Up @@ -233,6 +236,18 @@ export const DashboardComponent = () => {
}

userMessageCount++;
} else if (isTypeMessageSlot(msg)) {
if (msg.data.name === 'current_url') {
const url = msg.data.value;
console.log(url);
if (typeof url !== 'string') {
return
}
if (!pagesUsed[url]) {
pagesUsed[url] = 0;
}
pagesUsed[url]++;
}
}
});

Expand All @@ -245,6 +260,7 @@ export const DashboardComponent = () => {
setFirstTimeUsers(firstTimeUsers);

setIntentCounts(intentCounts);
setPagesUsed(pagesUsed);

setContactAdminUsage(contactAdminUsage);
setRequestTamUsage(requestTamUsage);
Expand Down Expand Up @@ -488,6 +504,27 @@ export const DashboardComponent = () => {
</CardFooter>
</Card>
</GridItem>
<GridItem span={4} rowSpan={4}>
<Card>
<CardTitle>Pages users talk to the bot on</CardTitle>
<Chart
ariaTitle="Pages"
containerComponent={<ChartVoronoiContainer labels={({ datum }) => `${datum.y} ${datum.x}`} />}
name="by_page"
themeColor="multi"
>
<ChartAxis tickValues={[]} />
<ChartAxis dependentAxis showGrid />
<ChartGroup>
{Object.entries(pagesUsed).map(([key, value]) => (
<ChartBar
data={[{ x: key, y: value }]}
/>
))}
</ChartGroup>
</Chart>
</Card>
</GridItem>
</Grid>
</PageSection>
);
Expand Down
Loading
Loading