-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Open
vishnupsatish
wants to merge
60
commits into
master
Choose a base branch
from
vishnupsatish/uf-summary-frontend
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+145
−4
Open
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
1af771f
feedback usecase to generate summary and parse it, and testing it
vishnupsatish a15f6f7
update tests and some config
vishnupsatish 9ba5ee5
update based on review - rename, strip consecutive whitespaces, etc.
vishnupsatish 3b80ac2
add max tokens and add comment back
vishnupsatish 937f1bf
create endpoint, very rough and no tests
vishnupsatish 860cdb1
create test file using cursor, need to change so it actually works an…
vishnupsatish 376de16
trying out tests and creating user feedbacks using kafka
vishnupsatish 019c174
write endpoint test that actually works
vishnupsatish 0a3360f
more tests for the API endpoint
vishnupsatish aba030a
format
vishnupsatish 1956230
fix docstring for endpoint
vishnupsatish b16637f
update comments
vishnupsatish b34742f
remove custom exception for parse, fix failing test
vishnupsatish 7368e0f
format tests
vishnupsatish c20e77a
remove default=True for user-feedback-ui
vishnupsatish 4a1b805
Merge branch 'master' into vishnupsatish/uf-summary-api-endpoint
vishnupsatish 5da9100
update based on review
vishnupsatish a22d4c6
log more stuff
vishnupsatish 7493363
cache summary and write tests for the caching aspect
vishnupsatish 55bfad7
update based on review
vishnupsatish 6a9430d
update url
vishnupsatish faf5701
gate behind feature flag
vishnupsatish 40dd6cc
test for nonexistent feature flag, test for different project qparam …
vishnupsatish d497108
Merge branch 'vishnupsatish/uf-summary-api-endpoint' into vishnupsati…
vishnupsatish c6e3051
merge master, why is a test_create_feedback test failing?
vishnupsatish d630eef
use monkeypatch instead of patch, but it is still not cleaning up pro…
vishnupsatish 5cda5e8
revert to how it was before as monkeypatch isnt fixing the issue
vishnupsatish 43ce9a4
update based on review, mock generate_summary instead of openai
vishnupsatish a451cef
Merge branch 'vishnupsatish/uf-summary-api-endpoint' into vishnupsati…
vishnupsatish 72cb051
update cache tests
vishnupsatish fa40586
fix type so that it is string
vishnupsatish b3a5395
cnt
vishnupsatish ee740d1
update url
vishnupsatish 571004b
Merge branch 'vishnupsatish/uf-summary-api-endpoint' into vishnupsati…
vishnupsatish 6cd136f
merge
vishnupsatish e378da1
barebones frontend
vishnupsatish 3b03f7d
merge master
vishnupsatish 5e2648e
fix frontend bugs and run query
vishnupsatish 2c525a4
hide it behind feature flag
vishnupsatish f0fe0dc
make summary fit in the correct spot based on the grid
vishnupsatish 2407346
add icon
vishnupsatish 04b5f2c
make the summary not part of the grid anymore, update error, loading,…
vishnupsatish e383dd0
formatting and some other small fixes
vishnupsatish 03c7aa2
more refactors
vishnupsatish f3df413
line clamping logic, cursor helped
vishnupsatish 2783134
gate behind feature flag
vishnupsatish 88e5262
clean up code
vishnupsatish a0ed6c3
removed the line clamp logic, nice to have so we can worry about it l…
vishnupsatish 3645bbc
revert endpoint changes
vishnupsatish 59c98db
revert feature flags
vishnupsatish bd44743
not enough feedbacks, ensure success is false too
vishnupsatish 5062dfe
update based on review
vishnupsatish ece7000
num_feedbacks_used -> numFeedbacksUsed in the frontend too
vishnupsatish 5827c79
Merge remote-tracking branch 'origin/master' into vishnupsatish/uf-su…
vishnupsatish e1e7f99
change the way date and time are sent to the backend, still draft-ish
vishnupsatish 4a81d56
update based on review
vishnupsatish d6fdea2
reset feature flags
vishnupsatish 607e8da
update based on reviews
vishnupsatish 8232c5d
Merge remote-tracking branch 'origin/master' into vishnupsatish/uf-su…
vishnupsatish dc83c6d
nit
vishnupsatish 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 hidden or 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,64 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import useFeedbackSummary from 'sentry/components/feedback/list/useFeedbackSummary'; | ||
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') || | ||
tooFewFeedbacks || | ||
isError | ||
) { | ||
return null; | ||
} | ||
|
||
if (isPending) { | ||
return <Placeholder height="100px" />; | ||
} | ||
|
||
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; | ||
gap: ${space(1)}; | ||
padding: ${space(2)}; | ||
border: 1px solid ${p => p.theme.border}; | ||
border-radius: ${p => p.theme.borderRadius}; | ||
align-items: baseline; | ||
`; |
67 changes: 67 additions & 0 deletions
67
static/app/components/feedback/list/useFeedbackSummary.tsx
This file contains hidden or 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,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); | ||
|
||
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, | ||
}; | ||
} |
This file contains hidden or 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
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.
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?
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.
woo, fewer weird things going on!