-
-
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(feedback): add spam detection to project settings #66740
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0da2fab
fix(feedback): update typo in feedback proj settings
michellewzhang 7dc11b3
feat(feedback): add spam detection to project settings
michellewzhang decfff6
rm change
michellewzhang 667c73e
rm change
michellewzhang f7b6544
rm comment
michellewzhang 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type {JsonFormObject} from 'sentry/components/forms/types'; | ||
|
||
export const route = '/settings/:orgId/projects/:projectId/user-feedback-processing/'; | ||
|
||
const formGroups: JsonFormObject[] = [ | ||
{ | ||
title: 'Settings', | ||
fields: [ | ||
{ | ||
name: 'sentry:feedback_ai_spam_detection', | ||
type: 'boolean', | ||
|
||
// additional data/props that is related to rendering of form field rather than data | ||
label: 'Enable Spam Detection', | ||
help: 'Toggles whether or not to enable auto spam detection in User Feedback.', | ||
getData: data => ({options: data}), | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
export default formGroups; |
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
55 changes: 55 additions & 0 deletions
55
static/app/views/settings/project/projectUserFeedbackProcessing.spec.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,55 @@ | ||
import {ProjectFixture} from 'sentry-fixture/project'; | ||
|
||
import {initializeOrg} from 'sentry-test/initializeOrg'; | ||
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import ProjectUserFeedbackProcessing from 'sentry/views/settings/project/projectUserFeedbackProcessing'; | ||
|
||
describe('ProjectUserFeedbackProcessing', function () { | ||
const {routerProps, organization, project, routerContext} = initializeOrg(); | ||
const url = `/projects/${organization.slug}/${project.slug}/`; | ||
|
||
beforeEach(function () { | ||
MockApiClient.clearMockResponses(); | ||
MockApiClient.addMockResponse({ | ||
url, | ||
method: 'GET', | ||
body: ProjectFixture(), | ||
}); | ||
MockApiClient.addMockResponse({ | ||
url: `${url}keys/`, | ||
method: 'GET', | ||
body: [], | ||
}); | ||
}); | ||
|
||
it('can toggle spam detection', async function () { | ||
render( | ||
<ProjectUserFeedbackProcessing | ||
{...routerProps} | ||
organization={organization} | ||
project={project} | ||
/>, | ||
{ | ||
context: routerContext, | ||
} | ||
); | ||
|
||
const mock = MockApiClient.addMockResponse({ | ||
url, | ||
method: 'PUT', | ||
}); | ||
|
||
await userEvent.click(screen.getByRole('checkbox', {name: 'Enable Spam Detection'})); | ||
|
||
expect(mock).toHaveBeenCalledWith( | ||
url, | ||
expect.objectContaining({ | ||
method: 'PUT', | ||
data: { | ||
options: {'sentry:feedback_ai_spam_detection': true}, | ||
}, | ||
}) | ||
); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
static/app/views/settings/project/projectUserFeedbackProcessing.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,52 @@ | ||
import type {RouteComponentProps} from 'react-router'; | ||
|
||
import Access from 'sentry/components/acl/access'; | ||
import {Button} from 'sentry/components/button'; | ||
import Form from 'sentry/components/forms/form'; | ||
import JsonForm from 'sentry/components/forms/jsonForm'; | ||
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; | ||
import formGroups from 'sentry/data/forms/userFeedbackProcessing'; | ||
import {t} from 'sentry/locale'; | ||
import type {Organization, Project} from 'sentry/types'; | ||
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader'; | ||
import PermissionAlert from 'sentry/views/settings/project/permissionAlert'; | ||
|
||
type RouteParams = { | ||
projectId: string; | ||
}; | ||
type Props = RouteComponentProps<RouteParams, {}> & { | ||
organization: Organization; | ||
project: Project; | ||
}; | ||
|
||
function ProjectUserFeedbackProcessingSettings({ | ||
project, | ||
organization, | ||
params: {projectId}, | ||
}: Props) { | ||
return ( | ||
<SentryDocumentTitle title={t('User Feedback')} projectSlug={project.slug}> | ||
<SettingsPageHeader | ||
title={t('User Feedback')} | ||
action={ | ||
<Button external href="https://docs.sentry.io/product/user-feedback/"> | ||
{t('Read the docs')} | ||
</Button> | ||
} | ||
/> | ||
<PermissionAlert project={project} /> | ||
<Form | ||
saveOnBlur | ||
apiMethod="PUT" | ||
apiEndpoint={`/projects/${organization.slug}/${projectId}/`} | ||
initialData={project.options} | ||
> | ||
<Access access={['project:write']} project={project}> | ||
{({hasAccess}) => <JsonForm disabled={!hasAccess} forms={formGroups} />} | ||
</Access> | ||
</Form> | ||
</SentryDocumentTitle> | ||
); | ||
} | ||
|
||
export default ProjectUserFeedbackProcessingSettings; |
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 can't find an import for this one
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.
copied from a previous file, but in those i see this:
// Export route to make these forms searchable by label/help
so maybe it's necessary