-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: hackathon metalytics (tracking team usage metrics) #26304
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
faf9a05
wip
benjackwhite d631978
Add actual scope info
benjackwhite a699ede
fix
benjackwhite 7b3910a
feat: creating API end point that writes to kafkta
56dac9d
Added app metrics 2 to hogql
benjackwhite 0e32e8e
Merge branch 'hackathon/metalytics' of github.com:PostHog/posthog int…
benjackwhite ac7867c
Fixes
benjackwhite 0656952
Update query snapshots
github-actions[bot] 987da60
Update UI snapshots for `chromium` (2)
github-actions[bot] 99629a1
Fix
benjackwhite 371f082
Fixes
benjackwhite 45b0758
Merge branch 'hackathon/metalytics' of github.com:PostHog/posthog int…
benjackwhite 8e4b622
Update UI snapshots for `webkit` (2)
github-actions[bot] 9eff497
Update UI snapshots for `chromium` (1)
github-actions[bot] 16cbc1b
Update UI snapshots for `chromium` (2)
github-actions[bot] de074f4
Fix
benjackwhite ed84770
Merge branch 'hackathon/metalytics' of github.com:PostHog/posthog int…
benjackwhite f90bbe8
feat: Add members logic and user view tracking in metalytics component
89961eb
refactor: Separate view count and recent users loaders in metalyticsL…
76736c1
refactor: Update SQL query timestamp and interval syntax in metalytic…
913f846
feat: Add selectors for recent user members in metalyticsLogic
e2ed316
feat: Add console log for recentUserMembers in metalyticsLogic
b866feb
Fixes
benjackwhite 1aea873
feature: person bubbles
07e7d64
feat: Add new icons and IconWithCount component to MetalyticsSummary
bb9a16d
style: Add margin between IconPulse and IconDashboard in MetalyticsSu…
63f2975
Added opener
benjackwhite 3123cbe
fix: MetalyticsSummary component
67cb581
pulse icon
5d5f4e3
adding the pulse icon
2d2503b
Fixes
benjackwhite 6eb546c
Fix
benjackwhite 2240d16
feat: Add view count display to SidePanelActivityMetalytics component
fe40166
feat: Add recentUserMembers to SidePanelActivityMetalytics component
7685d59
feat: Replace UserBasicType with ProfileBubbles in SidePanelActivityM…
667764c
feat: Add ProfileBubbles for recent viewers in SidePanelActivityMetal…
8ff1c67
refactor: Adjust recent viewers section and ProfileBubbles limit
3fae703
feat: Make SidePanelActivityMetalytics scrollable with max height
790691d
refactor: Update Metalytics activity query to include timestamp and 3…
8a7fdc3
refactor: Improve HogQL query indentation in SidePanelActivityMetalytics
ec560b3
style: Place Total Views and Recent Viewers side by side in flex cont…
6c21efd
feat: Add feature flag for MetalyticsSummary component in TopBar
20e38ba
fix: sql query, styling and remvoing feature flag code
6e4699b
putting things behind a feature flag
surbhi-posthog 39e88b3
fix: fixing feature styling
surbhi-posthog 63c4172
Fixes
benjackwhite a0badd2
Fix up
benjackwhite 779704f
Fixes
benjackwhite e87c922
Fixes
benjackwhite 613f039
Fix
benjackwhite 1b06679
Fix
benjackwhite 1b6db67
Fixes
benjackwhite 65c2b90
Merge branch 'master' into hackathon/metalytics
benjackwhite 6475d5d
Fix
benjackwhite db0021c
Fix
benjackwhite 3df86e6
Niceties
benjackwhite 4cbae02
Fix
benjackwhite f5387e8
fix
benjackwhite 50ee5bb
Remove query
benjackwhite 37bd9c6
Merge branch 'master' into hackathon/metalytics
benjackwhite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
74 changes: 74 additions & 0 deletions
74
...tend/src/layout/navigation-3000/sidepanel/panels/activity/SidePanelActivityMetalytics.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,74 @@ | ||
import { Spinner, Tooltip } from '@posthog/lemon-ui' | ||
import { useValues } from 'kea' | ||
import { humanizeScope } from 'lib/components/ActivityLog/humanizeActivity' | ||
import { metalyticsLogic } from 'lib/components/Metalytics/metalyticsLogic' | ||
import { ProfileBubbles } from 'lib/lemon-ui/ProfilePicture/ProfileBubbles' | ||
|
||
export function SidePanelActivityMetalytics(): JSX.Element { | ||
const { scope, instanceId, viewCount, recentUserMembers, viewCountLoading, recentUsersLoading } = | ||
useValues(metalyticsLogic) | ||
|
||
if (!instanceId) { | ||
return ( | ||
<p className="border-dashed "> | ||
You can see internal analytics of how your Organization members are using PostHog for things such as | ||
Dashboards, Insights, Playlists etc. Open an app to see the viewership data here. | ||
</p> | ||
) | ||
} | ||
|
||
const humanizedScope = `this ${scope ? humanizeScope(scope, true) : 'app'}` | ||
|
||
return ( | ||
<div className="space-y-4 "> | ||
<p> | ||
You are viewing "meta" analytics of how your organization members are interacting with{' '} | ||
<b>{humanizedScope}</b>. | ||
</p> | ||
<div className="flex flex-wrap gap-4"> | ||
<Tooltip | ||
title={`The total number of times ${humanizedScope} has been viewed by members of your organization.`} | ||
placement="top" | ||
> | ||
<div className="flex-1 p-4 border rounded bg-bg-light min-w-40"> | ||
<div className="text-sm text-muted">Views</div> | ||
<div className="text-2xl font-semibold"> | ||
{viewCountLoading ? <Spinner /> : viewCount?.views ?? 0} | ||
</div> | ||
</div> | ||
</Tooltip> | ||
|
||
<Tooltip | ||
title={`The total number of unique organization members who have viewed ${humanizedScope}.`} | ||
placement="top" | ||
> | ||
<div className="flex-1 p-4 border rounded bg-bg-light min-w-40"> | ||
<div className="text-sm text-muted">Viewers</div> | ||
<div className="text-2xl font-semibold"> | ||
{viewCountLoading ? <Spinner /> : viewCount?.users ?? 0} | ||
</div> | ||
</div> | ||
</Tooltip> | ||
|
||
<Tooltip title={`The most recent 30 users who have viewed ${humanizedScope}.`} placement="top"> | ||
<div className="flex-1 p-4 border rounded bg-bg-light min-w-40"> | ||
<div className="text-sm text-muted">Recent viewers (30 days)</div> | ||
{recentUsersLoading ? ( | ||
<Spinner /> | ||
) : ( | ||
<ProfileBubbles | ||
className="mt-2" | ||
people={recentUserMembers.map((member) => ({ | ||
email: member.user.email, | ||
name: member.user.first_name, | ||
title: member.user.email, | ||
}))} | ||
limit={3} | ||
/> | ||
)} | ||
</div> | ||
</Tooltip> | ||
</div> | ||
</div> | ||
) | ||
} |
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
39 changes: 39 additions & 0 deletions
39
frontend/src/lib/components/Metalytics/MetalyticsSummary.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,39 @@ | ||
import { IconPulse } from '@posthog/icons' | ||
import { LemonBadge, LemonButton } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
|
||
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic' | ||
import { SidePanelTab } from '~/types' | ||
|
||
import { metalyticsLogic } from './metalyticsLogic' | ||
|
||
export function MetalyticsSummary(): JSX.Element | null { | ||
const { instanceId, viewCount, viewCountLoading } = useValues(metalyticsLogic) | ||
const safeViewCount = viewCount?.views ?? 0 | ||
const safeUniqueUsers = viewCount?.users ?? 0 | ||
const { openSidePanel } = useActions(sidePanelStateLogic) | ||
|
||
if (!instanceId || viewCountLoading) { | ||
return null | ||
} | ||
|
||
return ( | ||
<span className="relative inline-flex"> | ||
<LemonButton | ||
loading={viewCountLoading} | ||
icon={<IconPulse />} | ||
size="small" | ||
onClick={() => openSidePanel(SidePanelTab.Activity, 'metalytics')} | ||
tooltip={`${safeUniqueUsers} PostHog members have viewed this a total of ${safeViewCount} times. Click to see more.`} | ||
/> | ||
<LemonBadge.Number | ||
count={safeViewCount} | ||
size="small" | ||
position="top-right" | ||
showZero={false} | ||
status="primary" | ||
maxDigits={3} | ||
/> | ||
</span> | ||
) | ||
} |
Oops, something went wrong.
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.
Looks like you got it right here.