-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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(releases): add error free session rate chart to frontend insights #84834
base: master
Are you sure you want to change the base?
Conversation
const { | ||
data: sessionsData, | ||
isPending, | ||
error, | ||
} = useApiQuery<SessionApiResponse>( | ||
[ | ||
`/organizations/${organization.slug}/sessions/`, | ||
{query: {...location.query, field: ['sum(session)'], groupBy: ['session.status']}}, | ||
], | ||
{staleTime: 0} | ||
); | ||
|
||
if (!sessionsData) { | ||
return null; | ||
} | ||
|
||
// Get the healthy sessions series data | ||
const healthySessionsSeries = | ||
sessionsData.groups.find(group => group.by['session.status'] === 'healthy')?.series[ | ||
'sum(session)' | ||
] ?? []; | ||
|
||
// Calculate total sessions for each interval | ||
const totalSessionsByInterval = sessionsData.groups[0]?.series['sum(session)']?.map( | ||
(_, intervalIndex) => | ||
sessionsData.groups.reduce( | ||
(acc, group) => acc + (group.series['sum(session)']?.[intervalIndex] ?? 0), | ||
0 | ||
) | ||
); | ||
|
||
// Calculate percentage for each interval | ||
const healthySessionsPercentageData = healthySessionsSeries.map( | ||
(healthyCount, index) => { |
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.
i should probably move all this calculation stuff into a separate hook
<InsightsLineChartWidget | ||
title={t('Error Free Session Rate')} | ||
series={[ | ||
{ | ||
data: healthySessionsPercentageData.map((val, idx) => { | ||
return {name: sessionsData.intervals[idx] ?? '', value: val}; | ||
}), | ||
seriesName: 'Error free session rate', | ||
meta: { | ||
fields: { | ||
'Error free session rate': 'percentage', | ||
time: 'date', | ||
}, | ||
units: { | ||
'Error free session rate': '%', | ||
}, | ||
}, | ||
}, | ||
]} | ||
isLoading={isPending} | ||
error={error} | ||
/> |
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.
this could also be a separate component
a798306
to
09c1f7e
Compare
Bundle ReportChanges will increase total bundle size by 47.57kB (0.14%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: app-webpack-bundle-array-pushAssets Changed:
Files in
|
data: healthySessionsPercentageData.map((val, idx) => { | ||
return {name: sessionsData.intervals[idx] ?? '', value: val}; | ||
}), | ||
seriesName: 'Error free session rate', |
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.
the name "error free session rate" is super vague, maybe we need a question tooltip or something to clarify what this means?
Screen.Recording.2025-02-07.at.5.05.21.PM.mov
the full screen behavior after clicking on the legend is a bit janky but is consistent w/ other widgets in insights
relates to https://github.com/getsentry/team-replay/issues/540