-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
/insights #6511
Merged
Merged
/insights #6511
Changes from 59 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
09143be
init page
PeerRich a177a8e
init insights frontend
PeerRich 016b6fe
nit
PeerRich 49635a4
nit
PeerRich 53987c9
nit
PeerRich 717cdba
merge
PeerRich 79b9bb7
merge
PeerRich 1aa07a0
fixed icons
PeerRich ee4078d
i18n, needs features
PeerRich 8ffc7e1
Merge branch 'main' into 6507-cal-803-analytics
PeerRich 1dffc8e
Merge branch 'main' of ssh://github.com/calcom/cal.com into 6507-cal-…
alannnc efcda16
Init insights trpc
alannnc 6341fd1
Using trpc on client
alannnc 2fe5c31
Merge with main
alannnc c72382f
Added events timeline
alannnc 1f63304
Seed analytics script
alannnc dd95b3e
connect ui with trpc
alannnc 6745f0e
Added and fixed event time lines
alannnc a5d983f
merge with main
alannnc 6a46537
WIP popular days and avg time duration event type
alannnc f6fe6c2
Merge with main
alannnc 983d855
Merge branch 'main' of ssh://github.com/calcom/cal.com into 6507-cal-…
alannnc 2a11c12
added new metric graphs
alannnc 2e29225
improved upgrade tip
PeerRich 84dc305
always show upgrade screen
PeerRich 4328cc5
Merge with main
alannnc a8294e5
Merge branch 'main' of ssh://github.com/calcom/cal.com into 6507-cal-…
alannnc e9832ef
upgrade tremor.so and select inputs for page
alannnc 962896c
Remove log
alannnc 6b77b6c
merge with main
alannnc 6df9bdc
Merge branch 'main' into 6507-cal-803-analytics
PeerRich da8dd60
Merge branch 'main' into 6507-cal-803-analytics
PeerRich 01327a4
Merge branch 'main' of ssh://github.com/calcom/cal.com into 6507-cal-…
alannnc 5f0559e
Move everything to components and add context
alannnc 6ce8880
Merge branch 'main' of ssh://github.com/calcom/cal.com into 6507-cal-…
alannnc 5eeff83
Fix select types using calcom ui one
alannnc 6de52c2
Adding translations
alannnc 9929504
Merge branch 'main' of ssh://github.com/calcom/cal.com into 6507-cal-…
alannnc b16eab2
Add missing translations
alannnc 4cf508a
Add more translations
alannnc 43a6821
min fix
alannnc 552c5fb
Fixes for date select
alannnc 6c68ad3
Prefer early return and mobile design fixes
alannnc e417e53
Fix style for mobile
alannnc 175b928
Fix data with userId filter from popular events
alannnc da22675
add user id to average time duration
alannnc 2f22aca
Merge branch 'main' into 6507-cal-803-analytics
PeerRich b986371
Merge branch 'main' into 6507-cal-803-analytics
zomars 6dc346b
Removed submodules
zomars 432f88a
Delete website
zomars b192ff7
Update yarn.lock
zomars fe2f86e
Code organization and type fixes
zomars 32c7aa5
trpc fixes
zomars afdba4d
Builds are now passing
zomars b215e64
Relocates server code
zomars 9d0b99c
Cleanup
zomars 10a8a45
Merge branch 'main' into 6507-cal-803-analytics
zomars 0925317
Medium size screen fixes
zomars a7dbbf9
Added TODO
zomars 6578e5d
Merge branch 'main' into 6507-cal-803-analytics
zomars File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { | ||
zomars marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AverageEventDurationChart, | ||
BookingKPICards, | ||
BookingStatusLineChart, | ||
LeastBookedTeamMembersTable, | ||
MostBookedTeamMembersTable, | ||
PopularEventsTable, | ||
} from "@calcom/features/insights/components"; | ||
import { FiltersProvider } from "@calcom/features/insights/context/FiltersProvider"; | ||
import { useFilterContext } from "@calcom/features/insights/context/provider"; | ||
import { Filters } from "@calcom/features/insights/filters"; | ||
import Shell from "@calcom/features/shell/Shell"; | ||
import { UpgradeTip } from "@calcom/features/tips"; | ||
import { WEBAPP_URL } from "@calcom/lib/constants"; | ||
import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
import { trpc } from "@calcom/trpc"; | ||
import { Button, ButtonGroup } from "@calcom/ui"; | ||
import { FiRefreshCcw, FiUserPlus, FiUsers } from "@calcom/ui/components/icon"; | ||
|
||
const Heading = () => { | ||
const { t } = useLocale(); | ||
const { | ||
filter: { selectedTeamName }, | ||
} = useFilterContext(); | ||
return ( | ||
<div className="min-w-52"> | ||
<p className="text-lg font-semibold"> | ||
{t("analytics_for_organisation", { | ||
organisationName: selectedTeamName, | ||
})} | ||
</p> | ||
<p>{t("subtitle_analytics")}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default function InsightsPage() { | ||
const { t } = useLocale(); | ||
const { data: user } = trpc.viewer.me.useQuery(); | ||
const features = [ | ||
{ | ||
icon: <FiUsers className="h-5 w-5 text-red-500" />, | ||
title: t("view_bookings_across"), | ||
description: t("view_bookings_across_description"), | ||
}, | ||
{ | ||
icon: <FiRefreshCcw className="h-5 w-5 text-blue-500" />, | ||
title: t("identify_booking_trends"), | ||
description: t("identify_booking_trends_description"), | ||
}, | ||
{ | ||
icon: <FiUserPlus className="h-5 w-5 text-green-500" />, | ||
title: t("spot_popular_event_types"), | ||
description: t("spot_popular_event_types_description"), | ||
}, | ||
]; | ||
|
||
return ( | ||
<div> | ||
<Shell> | ||
<UpgradeTip | ||
title={t("make_informed_decisions")} | ||
description={t("make_informed_decisions_description")} | ||
features={features} | ||
background="/banners/insights.jpg" | ||
buttons={ | ||
<div className="space-y-2 rtl:space-x-reverse sm:space-x-2"> | ||
<ButtonGroup> | ||
<Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}> | ||
{t("create_team")} | ||
</Button> | ||
<Button color="secondary" href="https://go.cal.com/insights" target="_blank"> | ||
{t("learn_more")} | ||
</Button> | ||
</ButtonGroup> | ||
</div> | ||
}> | ||
{!user ? ( | ||
<></> | ||
) : ( | ||
<FiltersProvider> | ||
<div className="mb-4 ml-auto flex w-full flex-wrap justify-between"> | ||
<Heading /> | ||
<Filters /> | ||
</div> | ||
<div className="mb-4 space-y-6"> | ||
<BookingKPICards /> | ||
|
||
<BookingStatusLineChart /> | ||
|
||
<div className="grid grid-cols-1 gap-5 md:grid-cols-2"> | ||
<PopularEventsTable /> | ||
|
||
<AverageEventDurationChart /> | ||
</div> | ||
<div className="grid grid-cols-1 gap-5 md:grid-cols-2"> | ||
<MostBookedTeamMembersTable /> | ||
<LeastBookedTeamMembersTable /> | ||
</div> | ||
<small className="block text-center text-gray-600"> | ||
{t("looking_for_more_analytics")} | ||
<a | ||
className="text-blue-500 hover:underline" | ||
href="mailto:updates@cal.com?subject=Feature%20Request%3A%20More%20Analytics&body=Hey%20Cal.com%20Team%2C%20I%20love%20the%20analytics%20page%20but%20I%20am%20looking%20for%20..."> | ||
{" "} | ||
{t("contact_support")} | ||
</a> | ||
</small> | ||
</div> | ||
</FiltersProvider> | ||
)} | ||
</UpgradeTip> | ||
</Shell> | ||
</div> | ||
); | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
Binary file not shown.
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
38 changes: 38 additions & 0 deletions
38
packages/features/insights/components/AverageEventDurationChart.tsx
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,38 @@ | ||
import { Card, LineChart, Title } from "@tremor/react"; | ||
|
||
import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
import { trpc } from "@calcom/trpc"; | ||
|
||
import { useFilterContext } from "../context/provider"; | ||
import { valueFormatter } from "../lib/valueFormatter"; | ||
|
||
export const AverageEventDurationChart = () => { | ||
const { t } = useLocale(); | ||
const { filter } = useFilterContext(); | ||
const { dateRange, selectedUserId } = filter; | ||
const [startDate, endDate] = dateRange; | ||
const { selectedTeamId: teamId } = filter; | ||
|
||
const { data, isSuccess } = trpc.viewer.insights.averageEventDuration.useQuery({ | ||
startDate: startDate.toISOString(), | ||
endDate: endDate.toISOString(), | ||
teamId, | ||
userId: selectedUserId ?? undefined, | ||
}); | ||
|
||
if (!isSuccess || data?.length == 0 || !startDate || !endDate || !teamId) return null; | ||
|
||
return ( | ||
<Card> | ||
<Title>{t("average_event_duration")}</Title> | ||
<LineChart | ||
className="mt-4 h-80" | ||
data={data} | ||
index="Date" | ||
categories={["Average"]} | ||
colors={["blue"]} | ||
valueFormatter={valueFormatter} | ||
/> | ||
</Card> | ||
); | ||
}; |
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,62 @@ | ||
import { Grid } from "@tremor/react"; | ||
|
||
import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
import { trpc } from "@calcom/trpc"; | ||
|
||
import { useFilterContext } from "../context/provider"; | ||
import { KPICard } from "./KPICard"; | ||
|
||
export const BookingKPICards = () => { | ||
const { t } = useLocale(); | ||
const { filter } = useFilterContext(); | ||
const { dateRange, selectedEventTypeId, selectedUserId } = filter; | ||
const [startDate, endDate] = dateRange; | ||
|
||
const { selectedTeamId: teamId } = filter; | ||
|
||
const { data, isSuccess } = trpc.viewer.insights.eventsByStatus.useQuery({ | ||
startDate: startDate.toISOString(), | ||
endDate: endDate.toISOString(), | ||
teamId, | ||
eventTypeId: selectedEventTypeId ?? undefined, | ||
userId: selectedUserId ?? undefined, | ||
}); | ||
|
||
const categories: { | ||
title: string; | ||
index: "created" | "completed" | "rescheduled" | "cancelled"; | ||
}[] = [ | ||
{ | ||
title: t("events_created"), | ||
index: "created", | ||
}, | ||
{ | ||
title: t("events_completed"), | ||
index: "completed", | ||
}, | ||
{ | ||
title: t("events_rescheduled"), | ||
index: "rescheduled", | ||
}, | ||
{ | ||
title: t("events_cancelled"), | ||
index: "cancelled", | ||
}, | ||
]; | ||
|
||
if (!isSuccess || !startDate || !endDate || !teamId || data?.empty) return null; | ||
|
||
return ( | ||
<Grid numColsSm={2} numColsLg={4} className="gap-x-6 gap-y-6"> | ||
{categories.map((item) => ( | ||
<KPICard | ||
key={item.title} | ||
title={item.title} | ||
value={data[item.index].count} | ||
previousMetricData={data[item.index]} | ||
previousDateRange={data.previousRange} | ||
/> | ||
))} | ||
</Grid> | ||
); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest tremor version