mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
25 lines
688 B
TypeScript
25 lines
688 B
TypeScript
import {getAggregateAlias} from 'sentry/utils/discover/fields';
|
|
import type {WebVitals} from 'sentry/views/performance/browser/webVitals/utils/types';
|
|
|
|
export const mapWebVitalToOrderBy = (
|
|
webVital?: WebVitals | null,
|
|
aggregateFunction?: 'avg' | 'p75'
|
|
) => {
|
|
let webVitalKey = webVital ? WEBVITAL_TO_KEY[webVital] : undefined;
|
|
if (!webVitalKey) {
|
|
return undefined;
|
|
}
|
|
if (aggregateFunction) {
|
|
webVitalKey = getAggregateAlias(`${aggregateFunction}(${webVitalKey})`);
|
|
}
|
|
return `-${webVitalKey}`;
|
|
};
|
|
|
|
const WEBVITAL_TO_KEY = {
|
|
lcp: 'measurements.lcp',
|
|
fcp: 'measurements.fcp',
|
|
cls: 'measurements.cls',
|
|
ttfb: 'measurements.ttfb',
|
|
fid: 'measurements.fid',
|
|
};
|