Skip to content

Commit 36034c2

Browse files
armenzgscttcpergetsantry[bot]
authored
feat(grouping-settings): Show super user the derived grouping enhancements information (#88475)
This will help if we need to debug automatically derived in-app stack trace rules. This will only show when the user is signed in as a superuser. <img width="473" alt="image" src="https://github.com/user-attachments/assets/eca8e2ea-4f7c-4fe6-9217-93bbc9259e3b" /> --------- Co-authored-by: Scott Cooper <scttcper@gmail.com> Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 78f6981 commit 36034c2

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

static/app/data/forms/projectIssueGrouping.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,32 @@ stack.function:mylibrary_* +app`}
9797
validate: () => [],
9898
visible: true,
9999
},
100+
derivedGroupingEnhancements: {
101+
name: 'derivedGroupingEnhancements',
102+
type: 'string',
103+
label: 'Derived Grouping Enhancements (super user only)',
104+
hideLabel: true,
105+
placeholder: '',
106+
multiline: true,
107+
monospace: true,
108+
autosize: true,
109+
inline: false,
110+
maxRows: 20,
111+
saveOnBlur: false,
112+
saveMessageAlertType: 'info',
113+
saveMessage: '',
114+
formatMessageValue: false,
115+
help: () => (
116+
<RuleDescription>
117+
These rules are automatically derived for some languages for customers that have
118+
the GitHub integration and the language has been marked to derive in-app rules.
119+
These rules are not editable but they can be negated by adding their own rules in
120+
the Stack Trace Rules section.
121+
</RuleDescription>
122+
),
123+
validate: () => [],
124+
visible: true,
125+
},
100126
} satisfies Record<string, Field>;
101127

102128
const RuleDescription = styled('div')`

static/app/views/settings/projectIssueGrouping/index.spec.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixt
33
import {initializeOrg} from 'sentry-test/initializeOrg';
44
import {render, screen} from 'sentry-test/reactTestingLibrary';
55

6+
import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
67
import ProjectIssueGrouping from 'sentry/views/settings/projectIssueGrouping';
78

9+
jest.mock('sentry/utils/isActiveSuperuser', () => ({
10+
isActiveSuperuser: jest.fn(),
11+
}));
12+
813
describe('projectIssueGrouping', () => {
914
const {organization, projects} = initializeOrg();
1015
const project = projects[0]!;
@@ -49,4 +54,38 @@ describe('projectIssueGrouping', () => {
4954
await screen.findByText('Failed to load grouping configs')
5055
).toBeInTheDocument();
5156
});
57+
58+
it('shows derived grouping enhancements only for superusers', async () => {
59+
// Mock the API response
60+
MockApiClient.addMockResponse({
61+
url: `/projects/${organization.slug}/${project.slug}/grouping-configs/`,
62+
body: [],
63+
});
64+
65+
// First render with a non-superuser
66+
const {rerender} = render(
67+
<ProjectIssueGrouping
68+
organization={organization}
69+
project={project}
70+
{...RouteComponentPropsFixture()}
71+
/>
72+
);
73+
74+
// Verify the section is not visible for non-superuser
75+
expect(await screen.findByText('Issue Grouping')).toBeInTheDocument();
76+
expect(screen.queryByText(/Derived Grouping Enhancements/)).not.toBeInTheDocument();
77+
78+
// Re-render for superuser
79+
jest.mocked(isActiveSuperuser).mockReturnValue(true);
80+
rerender(
81+
<ProjectIssueGrouping
82+
organization={organization}
83+
project={project}
84+
{...RouteComponentPropsFixture()}
85+
/>
86+
);
87+
88+
// Verify the section is visible for superuser
89+
expect(screen.getByText(/Derived Grouping Enhancements/)).toBeInTheDocument();
90+
});
5291
});

static/app/views/settings/projectIssueGrouping/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {EventGroupingConfig} from 'sentry/types/event';
1212
import type {RouteComponentProps} from 'sentry/types/legacyReactRouter';
1313
import type {Organization} from 'sentry/types/organization';
1414
import type {Project} from 'sentry/types/project';
15+
import {isActiveSuperuser} from 'sentry/utils/isActiveSuperuser';
1516
import {useApiQuery} from 'sentry/utils/queryClient';
1617
import routeTitleGen from 'sentry/utils/routeTitle';
1718
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
@@ -50,6 +51,7 @@ export default function ProjectIssueGrouping({organization, project, params}: Pr
5051
const endpoint = `/projects/${organization.slug}/${project.slug}/`;
5152

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

5557
const jsonFormProps = {
@@ -100,6 +102,14 @@ export default function ProjectIssueGrouping({organization, project, params}: Pr
100102
title={t('Stack Trace Rules')}
101103
fields={[fields.groupingEnhancements]}
102104
/>
105+
106+
{activeSuperUser && (
107+
<JsonForm
108+
{...jsonFormProps}
109+
title={t('Derived Grouping Enhancements')}
110+
fields={[fields.derivedGroupingEnhancements!]}
111+
/>
112+
)}
103113
</Form>
104114
</SentryDocumentTitle>
105115
);

0 commit comments

Comments
 (0)