Skip to content

feat: show user limit on active users chart #10101

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

Merged
merged 7 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
WIP we have chart
  • Loading branch information
mtojek committed Oct 6, 2023
commit 98b583e6448526652be3e424730770f797e30ba2
10 changes: 10 additions & 0 deletions site/src/components/ActiveUserChart/ActiveUserChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ ChartJS.register(
export interface ActiveUserChartProps {
data: { date: string; amount: number }[];
interval: "day" | "week";
userLimit: number | undefined;
}

export const ActiveUserChart: FC<ActiveUserChartProps> = ({
data,
interval,
userLimit,
}) => {
const theme: Theme = useTheme();

Expand Down Expand Up @@ -106,6 +108,14 @@ export const ActiveUserChart: FC<ActiveUserChartProps> = ({
backgroundColor: theme.palette.info.dark,
fill: "origin",
},
{
label: "User limit",
data: data.map((_) => userLimit),
pointBackgroundColor: theme.palette.warning.light,
pointBorderColor: theme.palette.warning.light,
borderColor: theme.palette.warning.light,
fill: false,
}
],
}}
options={options}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { pageTitle } from "utils/page";
import { GeneralSettingsPageView } from "./GeneralSettingsPageView";
import { useQuery } from "@tanstack/react-query";
import { deploymentDAUs } from "api/queries/deployment";
import { entitlements } from "api/queries/entitlements";

const GeneralSettingsPage: FC = () => {
const { deploymentValues } = useDeploySettings();
const deploymentDAUsQuery = useQuery(deploymentDAUs());
const entitlementsQuery = useQuery(entitlements());

return (
<>
Expand All @@ -19,6 +21,7 @@ const GeneralSettingsPage: FC = () => {
deploymentOptions={deploymentValues.options}
deploymentDAUs={deploymentDAUsQuery.data}
deploymentDAUsError={deploymentDAUsQuery.error}
entitlements={entitlementsQuery.data}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Box from "@mui/material/Box";
import { ClibaseOption, DAUsResponse } from "api/typesGenerated";
import { ClibaseOption, DAUsResponse, Entitlements } from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import {
ActiveUserChart,
Expand All @@ -16,11 +16,13 @@ export type GeneralSettingsPageViewProps = {
deploymentOptions: ClibaseOption[];
deploymentDAUs?: DAUsResponse;
deploymentDAUsError: unknown;
entitlements: Entitlements | undefined;
};
export const GeneralSettingsPageView = ({
deploymentOptions,
deploymentDAUs,
deploymentDAUsError,
entitlements,
}: GeneralSettingsPageViewProps): JSX.Element => {
return (
<>
Expand All @@ -36,7 +38,7 @@ export const GeneralSettingsPageView = ({
{deploymentDAUs && (
<Box height={200} sx={{ mb: 3 }}>
<ChartSection title={<ActiveUsersTitle />}>
<ActiveUserChart data={deploymentDAUs.entries} interval="day" />
<ActiveUserChart data={deploymentDAUs.entries} interval="day" userLimit={entitlements?.features.user_limit.limit} />
</ChartSection>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Helmet } from "react-helmet-async";
import { getTemplatePageTitle } from "../utils";
import { Loader } from "components/Loader/Loader";
import {
Entitlements,
Template,
TemplateAppUsage,
TemplateInsightsResponse,
Expand Down Expand Up @@ -48,6 +49,7 @@ import {
insightsUserLatency,
} from "api/queries/insights";
import { useSearchParams } from "react-router-dom";
import { entitlements } from "api/queries/entitlements";

const DEFAULT_NUMBER_OF_WEEKS = numberOfWeeksOptions[0];

Expand Down Expand Up @@ -75,6 +77,7 @@ export default function TemplateInsightsPage() {
const { data: templateInsights } = useQuery(insightsTemplate(insightsFilter));
const { data: userLatency } = useQuery(insightsUserLatency(commonFilters));
const { data: userActivity } = useQuery(insightsUserActivity(commonFilters));
const { data: entitlementsQuery} = useQuery(entitlements());

return (
<>
Expand Down Expand Up @@ -106,6 +109,7 @@ export default function TemplateInsightsPage() {
userLatency={userLatency}
userActivity={userActivity}
interval={interval}
entitlements={entitlementsQuery}
/>
</>
);
Expand Down Expand Up @@ -146,12 +150,14 @@ export const TemplateInsightsPageView = ({
templateInsights,
userLatency,
userActivity,
entitlements,
controls,
interval,
}: {
templateInsights: TemplateInsightsResponse | undefined;
userLatency: UserLatencyInsightsResponse | undefined;
userActivity: UserActivityInsightsResponse | undefined;
entitlements: Entitlements | undefined;
controls: ReactNode;
interval: InsightsInterval;
}) => {
Expand All @@ -178,6 +184,7 @@ export const TemplateInsightsPageView = ({
<ActiveUsersPanel
sx={{ gridColumn: "span 2" }}
interval={interval}
userLimit={entitlements?.features.user_limit.limit}
data={templateInsights?.interval_reports}
/>
<UsersLatencyPanel data={userLatency} />
Expand All @@ -198,10 +205,12 @@ export const TemplateInsightsPageView = ({
const ActiveUsersPanel = ({
data,
interval,
userLimit,
...panelProps
}: PanelProps & {
data: TemplateInsightsResponse["interval_reports"] | undefined;
interval: InsightsInterval;
userLimit: number | undefined;
}) => {
return (
<Panel {...panelProps}>
Expand All @@ -216,6 +225,7 @@ const ActiveUsersPanel = ({
{data && data.length > 0 && (
<ActiveUserChart
interval={interval}
userLimit={userLimit}
data={data.map((d) => ({
amount: d.active_users,
date: d.start_time,
Expand Down