Skip to content

feat(grouping-settings): Show super user the derived grouping enhancements information #88475

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

Merged
merged 6 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions static/app/data/forms/projectIssueGrouping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ stack.function:mylibrary_* +app`}
validate: () => [],
visible: true,
},
derivedGroupingEnhancements: {
name: 'derivedGroupingEnhancements',
type: 'string',
label: 'Derived Grouping Enhancements (super user only)',
hideLabel: true,
placeholder: '',
multiline: true,
monospace: true,
autosize: true,
inline: false,
maxRows: 20,
saveOnBlur: false,
saveMessageAlertType: 'info',
saveMessage: '',
formatMessageValue: false,
help: () => (
<RuleDescription>
These rules are automatically derived for some languages for customers that have
the GitHub integration and the language has been marked to derive in-app rules.
These rules are not editable but they can be negated by adding their own rules in
the Stack Trace Rules section.
</RuleDescription>
),
validate: () => [],
visible: true,
},
} satisfies Record<string, Field>;

const RuleDescription = styled('div')`
Expand Down
39 changes: 39 additions & 0 deletions static/app/views/settings/projectIssueGrouping/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixt
import {initializeOrg} from 'sentry-test/initializeOrg';
import {render, screen} from 'sentry-test/reactTestingLibrary';

import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
import ProjectIssueGrouping from 'sentry/views/settings/projectIssueGrouping';

jest.mock('sentry/utils/isActiveSuperuser', () => ({
isActiveSuperuser: jest.fn(),
}));

describe('projectIssueGrouping', () => {
const {organization, projects} = initializeOrg();
const project = projects[0]!;
Expand Down Expand Up @@ -49,4 +54,38 @@ describe('projectIssueGrouping', () => {
await screen.findByText('Failed to load grouping configs')
).toBeInTheDocument();
});

it('shows derived grouping enhancements only for superusers', async () => {
// Mock the API response
MockApiClient.addMockResponse({
url: `/projects/${organization.slug}/${project.slug}/grouping-configs/`,
body: [],
});

// First render with a non-superuser
const {rerender} = render(
<ProjectIssueGrouping
organization={organization}
project={project}
{...RouteComponentPropsFixture()}
/>
);

// Verify the section is not visible for non-superuser
expect(await screen.findByText('Issue Grouping')).toBeInTheDocument();
expect(screen.queryByText(/Derived Grouping Enhancements/)).not.toBeInTheDocument();

// Re-render for superuser
jest.mocked(isActiveSuperuser).mockReturnValue(true);
rerender(
<ProjectIssueGrouping
organization={organization}
project={project}
{...RouteComponentPropsFixture()}
/>
);

// Verify the section is visible for superuser
expect(screen.getByText(/Derived Grouping Enhancements/)).toBeInTheDocument();
});
});
10 changes: 10 additions & 0 deletions static/app/views/settings/projectIssueGrouping/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {EventGroupingConfig} from 'sentry/types/event';
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
import type {Organization} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
import {useApiQuery} from 'sentry/utils/queryClient';
import routeTitleGen from 'sentry/utils/routeTitle';
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
Expand Down Expand Up @@ -50,6 +51,7 @@ export default function ProjectIssueGrouping({organization, project, params}: Pr
const endpoint = `/projects/${organization.slug}/${project.slug}/`;

const access = new Set(organization.access.concat(project.access));
const activeSuperUser = isActiveSuperuser();
const hasAccess = hasEveryAccess(['project:write'], {organization, project});

const jsonFormProps = {
Expand Down Expand Up @@ -100,6 +102,14 @@ export default function ProjectIssueGrouping({organization, project, params}: Pr
title={t('Stack Trace Rules')}
fields={[fields.groupingEnhancements]}
/>

{activeSuperUser && (
<JsonForm
{...jsonFormProps}
title={t('Derived Grouping Enhancements')}
fields={[fields.derivedGroupingEnhancements!]}
/>
)}
</Form>
</SentryDocumentTitle>
);
Expand Down
Loading