Skip to content

Commit

Permalink
ref(grouping-title-ui): Remove title tree label code (#76589)
Browse files Browse the repository at this point in the history
  • Loading branch information
priscilawebdev committed Aug 28, 2024
1 parent ea9d533 commit 6658357
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 216 deletions.
1 change: 0 additions & 1 deletion static/app/components/eventOrGroupHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ describe('EventOrGroupHeader', function () {
type: 'ReferenceError',
filename: 'webpack-internal:///./app/components/tabs/tabList.tsx',
function: 'useOverflowTabs',
display_title_with_tree_label: false,
},
actor: UserFixture(),
isTombstone: true,
Expand Down
5 changes: 0 additions & 5 deletions static/app/components/eventOrGroupHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ interface EventOrGroupHeaderProps {
data: Event | Group | GroupTombstoneHelper;
organization: Organization;
eventId?: string;
/* is issue breakdown? */
grouping?: boolean;
hideIcons?: boolean;
hideLevel?: boolean;
index?: number;
Expand All @@ -44,7 +42,6 @@ function EventOrGroupHeader({
onClick,
hideIcons,
eventId,
grouping = false,
source,
}: EventOrGroupHeaderProps) {
const location = useLocation();
Expand All @@ -61,11 +58,9 @@ function EventOrGroupHeader({
<ErrorBoundary customComponent={<EventTitleError />} mini>
<StyledEventOrGroupTitle
data={data}
organization={organization}
// hasSeen is undefined for GroupTombstone
hasSeen={hasSeen === undefined ? true : hasSeen}
withStackTracePreview
grouping={grouping}
query={query}
/>
</ErrorBoundary>
Expand Down
1 change: 0 additions & 1 deletion static/app/components/eventOrGroupTitle.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ describe('EventOrGroupTitle', function () {
type: 'ReferenceError',
filename: 'webpack-internal:///./app/components/tabs/tabList.tsx',
function: 'useOverflowTabs',
display_title_with_tree_label: false,
},
actor: UserFixture(),
isTombstone: true,
Expand Down
18 changes: 3 additions & 15 deletions static/app/components/eventOrGroupTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,27 @@ import styled from '@emotion/styled';

import type {Event} from 'sentry/types/event';
import type {BaseGroup, GroupTombstoneHelper} from 'sentry/types/group';
import type {Organization} from 'sentry/types/organization';
import {getTitle, isTombstone} from 'sentry/utils/events';
import withOrganization from 'sentry/utils/withOrganization';

import EventTitleTreeLabel from './eventTitleTreeLabel';
import GroupPreviewTooltip from './groupPreviewTooltip';

interface EventOrGroupTitleProps {
data: Event | BaseGroup | GroupTombstoneHelper;
organization: Organization;
className?: string;
/* is issue breakdown? */
grouping?: boolean;
query?: string;
withStackTracePreview?: boolean;
}

function EventOrGroupTitle({
organization,
data,
withStackTracePreview,
grouping = false,
className,
query,
}: EventOrGroupTitleProps) {
const {id, groupID} = data as Event;

const {title, subtitle, treeLabel} = getTitle(data, organization?.features, grouping);
const titleLabel = treeLabel ? (
<EventTitleTreeLabel treeLabel={treeLabel} />
) : (
title ?? ''
);
const {title, subtitle} = getTitle(data);
const titleLabel = title ?? '';

return (
<Wrapper className={className}>
Expand All @@ -62,7 +50,7 @@ function EventOrGroupTitle({
);
}

export default withOrganization(EventOrGroupTitle);
export default EventOrGroupTitle;

/**
* &nbsp; is used instead of margin/padding to split title and subtitle
Expand Down
82 changes: 0 additions & 82 deletions static/app/components/eventTitleTreeLabel.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ const makeEventWithFrames = (frames: Frame[]): Event => {
packages: {},
type: EventOrGroupType.ERROR,
metadata: {
display_title_with_tree_label: false,
filename: 'sentry/controllers/welcome_controller.rb',
finest_tree_label: [
{filebase: 'welcome_controller.rb', function: '/'},
{filebase: 'welcome_controller.rb', function: 'index'},
],
function: '/',
type: 'ZeroDivisionError',
value: 'divided by 0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ const makeEventWithThreads = (threads: Thread[]): Event => {
packages: {},
type: EventOrGroupType.ERROR,
metadata: {
display_title_with_tree_label: false,
filename: 'sentry/controllers/welcome_controller.rb',
finest_tree_label: [
{filebase: 'welcome_controller.rb', function: '/'},
{filebase: 'welcome_controller.rb', function: 'index'},
],
function: '/',
type: 'ZeroDivisionError',
value: 'divided by 0',
Expand Down
14 changes: 0 additions & 14 deletions static/app/components/events/interfaces/threads.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,7 @@ describe('Threads', function () {
packages: {},
type: EventOrGroupType.ERROR,
metadata: {
display_title_with_tree_label: false,
filename: 'sentry/controllers/welcome_controller.rb',
finest_tree_label: [
{filebase: 'welcome_controller.rb', function: '/'},
{filebase: 'welcome_controller.rb', function: 'index'},
],
function: '/',
type: 'ZeroDivisionError',
value: 'divided by 0',
Expand Down Expand Up @@ -828,15 +823,6 @@ describe('Threads', function () {
},
type: EventOrGroupType.ERROR,
metadata: {
display_title_with_tree_label: true,
finest_tree_label: [
{
function: 'ViewController.causeCrash',
},
{
function: 'main',
},
],
function: 'ViewController.causeCrash',
value:
'Attempted to dereference null pointer.\nOriginated at or in a subcall of ViewController.causeCrash(Any) -> ()',
Expand Down
73 changes: 1 addition & 72 deletions static/app/utils/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import type {
EntryRequest,
EntryThreads,
Event,
EventMetadata,
ExceptionValue,
Frame,
Thread,
TreeLabelPart,
} from 'sentry/types/event';
import {EntryType, EventOrGroupType} from 'sentry/types/event';
import type {
Expand Down Expand Up @@ -76,55 +74,7 @@ export function getLocation(event: Event | BaseGroup | GroupTombstoneHelper) {
return undefined;
}

export function getTreeLabelPartDetails(part: TreeLabelPart) {
// Note: This function also exists in Python in eventtypes/base.py, to make
// porting efforts simpler it's recommended to keep both variants
// structurally similar.
if (typeof part === 'string') {
return part;
}

const label = part?.function || part?.package || part?.filebase || part?.type;
const classbase = part?.classbase;

if (classbase) {
return label ? `${classbase}.${label}` : classbase;
}

return label || '<unknown>';
}

function computeTitleWithTreeLabel(metadata: EventMetadata) {
const {type, current_tree_label, finest_tree_label} = metadata;

const treeLabel = current_tree_label || finest_tree_label;

const formattedTreeLabel = treeLabel
? treeLabel.map(labelPart => getTreeLabelPartDetails(labelPart)).join(' | ')
: undefined;

if (!type) {
return {
title: formattedTreeLabel || metadata.function || '<unknown>',
treeLabel,
};
}

if (!formattedTreeLabel) {
return {title: type, treeLabel: undefined};
}

return {
title: `${type} | ${formattedTreeLabel}`,
treeLabel: [{type}, ...(treeLabel ?? [])],
};
}

export function getTitle(
event: Event | BaseGroup | GroupTombstoneHelper,
features: string[] = [],
grouping = false
) {
export function getTitle(event: Event | BaseGroup | GroupTombstoneHelper) {
const {metadata, type, culprit, title} = event;
const customTitle = metadata?.title;

Expand All @@ -134,36 +84,19 @@ export function getTitle(
return {
title: customTitle,
subtitle: culprit,
treeLabel: undefined,
};
}

const displayTitleWithTreeLabel =
!isTombstone(event) &&
features.includes('grouping-title-ui') &&
(grouping ||
isNativePlatform(event.platform) ||
isMobilePlatform(event.platform));

if (displayTitleWithTreeLabel) {
return {
subtitle: culprit,
...computeTitleWithTreeLabel(metadata),
};
}

return {
subtitle: culprit,
title: metadata.type || metadata.function || '<unknown>',
treeLabel: undefined,
};
}
case EventOrGroupType.CSP:
case EventOrGroupType.NEL:
return {
title: customTitle ?? metadata.directive ?? '',
subtitle: metadata.uri ?? '',
treeLabel: undefined,
};
case EventOrGroupType.EXPECTCT:
case EventOrGroupType.EXPECTSTAPLE:
Expand All @@ -174,27 +107,23 @@ export function getTitle(
return {
title: customTitle ?? (metadata.message || title),
subtitle: metadata.origin ?? '',
treeLabel: undefined,
};
case EventOrGroupType.DEFAULT:
return {
title: customTitle ?? title,
subtitle: '',
treeLabel: undefined,
};
case EventOrGroupType.TRANSACTION:
case EventOrGroupType.GENERIC:
const isIssue = !isTombstone(event) && defined(event.issueCategory);
return {
title: customTitle ?? title,
subtitle: isIssue ? culprit : '',
treeLabel: undefined,
};
default:
return {
title: customTitle ?? title,
subtitle: '',
treeLabel: undefined,
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/discover/eventDetails/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function EventDetailsContent(props: Props) {
const eventSlug = getEventSlug();
const projectSlug = eventSlug.split(':')[0];

const title = generateTitle({eventView, event, organization});
const title = generateTitle({eventView, event});

return (
<SentryDocumentTitle
Expand Down
3 changes: 1 addition & 2 deletions static/app/views/discover/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,11 @@ export class Results extends Component<Props, State> {
};

getDocumentTitle(): string {
const {organization} = this.props;
const {eventView} = this.state;
if (!eventView) {
return '';
}
return generateTitle({eventView, organization});
return generateTitle({eventView});
}

renderTagsTable() {
Expand Down
Loading

0 comments on commit 6658357

Please sign in to comment.