-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(feedback): frontend to display summary #93567
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
Changes from 56 commits
1af771f
a15f6f7
9ba5ee5
3b80ac2
937f1bf
860cdb1
376de16
019c174
0a3360f
aba030a
1956230
b16637f
b34742f
7368e0f
c20e77a
4a1b805
5da9100
a22d4c6
7493363
55bfad7
6a9430d
faf5701
40dd6cc
d497108
c6e3051
d630eef
5cda5e8
43ce9a4
a451cef
72cb051
fa40586
b3a5395
ee740d1
571004b
6cd136f
e378da1
3b03f7d
5e2648e
2c525a4
f0fe0dc
2407346
04b5f2c
e383dd0
03c7aa2
f3df413
2783134
88e5262
a0ed6c3
3645bbc
59c98db
bd44743
5062dfe
ece7000
5827c79
e1e7f99
4a81d56
d6fdea2
607e8da
8232c5d
dc83c6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| import useFeedbackSummary from 'sentry/components/feedback/list/useFeedbackSummary'; | ||
| import LoadingError from 'sentry/components/loadingError'; | ||
| import Placeholder from 'sentry/components/placeholder'; | ||
| import {IconSeer} from 'sentry/icons/iconSeer'; | ||
| import {t} from 'sentry/locale'; | ||
| import {space} from 'sentry/styles/space'; | ||
| import useOrganization from 'sentry/utils/useOrganization'; | ||
|
|
||
| export default function FeedbackSummary() { | ||
| const {isError, isPending, summary, tooFewFeedbacks} = useFeedbackSummary(); | ||
|
|
||
| const organization = useOrganization(); | ||
|
|
||
| if (!organization.features.includes('user-feedback-ai-summaries')) { | ||
| return null; | ||
| } | ||
|
|
||
| if (isError) { | ||
| return <LoadingError message={t('There was an error loading the summary')} />; | ||
| } | ||
|
|
||
| if (isPending) { | ||
| return <Placeholder height="100px" />; | ||
| } | ||
|
|
||
| if (tooFewFeedbacks) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <SummaryIconContainer> | ||
| <IconSeer size="xs" /> | ||
| <SummaryContainer> | ||
| <SummaryHeader>{t('Feedback Summary')}</SummaryHeader> | ||
| <SummaryContent>{summary}</SummaryContent> | ||
| </SummaryContainer> | ||
| </SummaryIconContainer> | ||
| ); | ||
| } | ||
|
|
||
| const SummaryContainer = styled('div')` | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: ${space(1)}; | ||
| width: 100%; | ||
| `; | ||
|
|
||
| const SummaryHeader = styled('p')` | ||
| font-size: ${p => p.theme.fontSizeMedium}; | ||
| font-weight: ${p => p.theme.fontWeightBold}; | ||
| margin: 0; | ||
| `; | ||
|
|
||
| const SummaryContent = styled('p')` | ||
| font-size: ${p => p.theme.fontSizeSmall}; | ||
| color: ${p => p.theme.subText}; | ||
| margin: 0; | ||
| `; | ||
|
|
||
| const SummaryIconContainer = styled('div')` | ||
| display: flex; | ||
| flex-direction: row; | ||
vishnupsatish marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| gap: ${space(1)}; | ||
| padding: ${space(2)}; | ||
| border: 1px solid ${p => p.theme.border}; | ||
| border-radius: ${p => p.theme.borderRadius}; | ||
| align-items: baseline; | ||
| `; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse'; | ||
| import {useApiQuery} from 'sentry/utils/queryClient'; | ||
| import useOrganization from 'sentry/utils/useOrganization'; | ||
| import usePageFilters from 'sentry/utils/usePageFilters'; | ||
|
|
||
| type FeedbackSummaryResponse = { | ||
| numFeedbacksUsed: number; | ||
| success: boolean; | ||
| summary: string | null; | ||
| }; | ||
|
|
||
| export default function useFeedbackSummary(): { | ||
| isError: boolean; | ||
| isPending: boolean; | ||
| summary: string | null; | ||
| tooFewFeedbacks: boolean; | ||
| } { | ||
| const organization = useOrganization(); | ||
|
|
||
| const {selection} = usePageFilters(); | ||
|
|
||
| const normalizedDateRange = normalizeDateTimeParams(selection.datetime); | ||
|
Comment on lines
+20
to
+22
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the way the date range filtering is done and from my testing (and looking at the code) this seems to work. Can you please have a look @ryan953 @michellewzhang?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woo, fewer weird things going on! |
||
|
|
||
| const {data, isPending, isError} = useApiQuery<FeedbackSummaryResponse>( | ||
| [ | ||
| `/organizations/${organization.slug}/feedback-summary/`, | ||
| { | ||
| query: { | ||
| ...normalizedDateRange, | ||
| project: selection.projects, | ||
| }, | ||
| }, | ||
| ], | ||
| { | ||
| staleTime: 5000, | ||
| enabled: | ||
| Boolean(normalizedDateRange) && | ||
| organization.features.includes('user-feedback-ai-summaries'), | ||
| retry: 1, | ||
| } | ||
| ); | ||
|
|
||
| if (isPending) { | ||
| return { | ||
| summary: null, | ||
| isPending: true, | ||
| isError: false, | ||
| tooFewFeedbacks: false, | ||
| }; | ||
| } | ||
|
|
||
| if (isError) { | ||
| return { | ||
| summary: null, | ||
| isPending: false, | ||
| isError: true, | ||
| tooFewFeedbacks: false, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| summary: data.summary, | ||
| isPending: false, | ||
| isError: false, | ||
| tooFewFeedbacks: data.numFeedbacksUsed === 0 && data.success === false, | ||
vishnupsatish marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.