Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,21 @@ describe('EventCustomPerformanceMetrics', function () {
expect(screen.getByText('Show events with values greater than')).toBeInTheDocument();
expect(screen.getByText('Show events with values less than')).toBeInTheDocument();
});

it('should render custom performance metrics custom unit', function () {
const {router, organization} = initializeOrg();
const event = TestStubs.Event({
measurements: {
'custom.unit': {unit: 'customunit', value: 456},
},
});
render(
<EventCustomPerformanceMetrics
location={router.location}
organization={organization}
event={event}
/>
);
expect(screen.getByText('456 customunit')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export function getFieldTypeFromUnit(unit) {
if (unit === 'none') {
return 'integer';
}
return 'string';
}
return 'number';
}
Expand All @@ -108,13 +109,14 @@ function EventCustomPerformanceMetric({
}

const fieldType = getFieldTypeFromUnit(unit);
const renderValue = fieldType === 'string' ? `${value} ${unit}` : value;
const rendered = fieldType
? FIELD_FORMATTERS[fieldType].renderFunc(
name,
{[name]: value},
{[name]: renderValue},
{location, organization, unit}
)
: value;
: renderValue;

function generateLinkWithQuery(query: string) {
const eventView = EventView.fromLocation(location);
Expand Down