Skip to content

ref(insights): remove eap conditions web vitals #95228

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
Show file tree
Hide file tree
Changes from 4 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 @@ -6,14 +6,16 @@ import type {Plottable} from 'sentry/views/dashboards/widgets/timeSeriesWidget/p
import {Thresholds} from 'sentry/views/dashboards/widgets/timeSeriesWidget/plottables/thresholds';
import {WEB_VITAL_FULL_NAME_MAP} from 'sentry/views/insights/browser/webVitals/components/webVitalDescription';
import {Referrer} from 'sentry/views/insights/browser/webVitals/referrers';
import {FIELD_ALIASES} from 'sentry/views/insights/browser/webVitals/settings';
import {
DEFAULT_QUERY_FILTER,
FIELD_ALIASES,
} from 'sentry/views/insights/browser/webVitals/settings';
import type {WebVitals} from 'sentry/views/insights/browser/webVitals/types';
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import {
PERFORMANCE_SCORE_MEDIANS,
PERFORMANCE_SCORE_P90S,
} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds';
import {useDefaultWebVitalsQuery} from 'sentry/views/insights/browser/webVitals/utils/useDefaultQuery';
// eslint-disable-next-line no-restricted-imports
import {InsightsLineChartWidget} from 'sentry/views/insights/common/components/insightsLineChartWidget';
import type {DiscoverSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
Expand All @@ -34,11 +36,10 @@ export function WebVitalStatusLineChart({
browserTypes,
subregions,
}: Props) {
const defaultQuery = useDefaultWebVitalsQuery();
const webVitalP90 = webVital ? PERFORMANCE_SCORE_P90S[webVital] : 0;
const webVitalMedian = webVital ? PERFORMANCE_SCORE_MEDIANS[webVital] : 0;

const search = new MutableSearch(defaultQuery);
const search = new MutableSearch(DEFAULT_QUERY_FILTER);
const referrer = Referrer.WEB_VITAL_STATUS_LINE_CHART;

if (transaction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {useProjectRawWebVitalsQuery} from 'sentry/views/insights/browser/webVita
import {getWebVitalScoresFromTableDataRow} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/getWebVitalScoresFromTableDataRow';
import {useProjectWebVitalsScoresQuery} from 'sentry/views/insights/browser/webVitals/queries/storedScoreQueries/useProjectWebVitalsScoresQuery';
import {useSpanSamplesCategorizedQuery} from 'sentry/views/insights/browser/webVitals/queries/useSpanSamplesCategorizedQuery';
import {useTransactionSamplesCategorizedQuery} from 'sentry/views/insights/browser/webVitals/queries/useTransactionSamplesCategorizedQuery';
import type {
SpanSampleRowWithScore,
TransactionSampleRowWithScore,
Expand All @@ -38,7 +37,6 @@ import type {
import decodeBrowserTypes from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import useProfileExists from 'sentry/views/insights/browser/webVitals/utils/useProfileExists';
import {SampleDrawerBody} from 'sentry/views/insights/common/components/sampleDrawerBody';
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
import {useDomainViewFilters} from 'sentry/views/insights/pages/useFilters';
import {SpanIndexedField, type SubregionCode} from 'sentry/views/insights/types';
import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceHeader/breadcrumbs';
Expand Down Expand Up @@ -85,7 +83,6 @@ export function PageOverviewWebVitalsDetailPanel({
const routes = useRoutes();
const {replayExists} = useReplayExists();
const domainViewFilters = useDomainViewFilters();
const useEap = useInsightsEap();

const browserTypes = decodeBrowserTypes(location.query[SpanIndexedField.BROWSER_NAME]);
const subregions = location.query[
Expand Down Expand Up @@ -124,24 +121,11 @@ export function PageOverviewWebVitalsDetailPanel({

const projectScore = getWebVitalScoresFromTableDataRow(projectScoresData?.[0]);

const {data: transactionsTableData, isLoading: isTransactionWebVitalsQueryLoading} =
useTransactionSamplesCategorizedQuery({
transaction: transaction ?? '',
webVital,
enabled:
Boolean(webVital) &&
!useEap &&
(!isInp || (!isSpansWebVital && useSpansWebVitals)),
browserTypes,
subregions,
});

const {data: spansTableData, isLoading: isSpansLoading} =
useSpanSamplesCategorizedQuery({
transaction: transaction ?? '',
webVital,
enabled:
Boolean(webVital) && (useEap || isInp || (isSpansWebVital && useSpansWebVitals)),
enabled: Boolean(webVital),
browserTypes,
subregions,
});
Expand All @@ -150,10 +134,6 @@ export function PageOverviewWebVitalsDetailPanel({
spansTableData.filter(row => row['profile.id']).map(row => row['profile.id'])
);

const getProjectSlug = (row: TransactionSampleRowWithScore): string => {
return project && !Array.isArray(location.query.project) ? project.slug : row.project;
};

const renderHeadCell = (col: Column) => {
if (col.key === 'transaction') {
return <NoOverflow>{col.name}</NoOverflow>;
Expand Down Expand Up @@ -192,99 +172,6 @@ export function PageOverviewWebVitalsDetailPanel({
return getDuration(value / 1000, 2, true);
};

const renderBodyCell = (col: Column, row: TransactionSampleRowWithScore) => {
const {key} = col;
const projectSlug = getProjectSlug(row);
if (key === 'score') {
if (row[`measurements.${webVital}` as keyof typeof row] !== undefined) {
return (
<AlignCenter>
<PerformanceBadge
score={row[`${webVital}Score` as keyof typeof row] as number}
/>
</AlignCenter>
);
}
return null;
}
if (col.key === 'webVital') {
// @ts-expect-error TS(2551): Property 'measurements.null' does not exist on typ... Remove this comment to see the full error message
const value = row[`measurements.${webVital}`];
if (value === undefined) {
return (
<AlignRight>
<NoValue>{t('(no value)')}</NoValue>
</AlignRight>
);
}
const formattedValue =
webVital === 'cls' ? value?.toFixed(2) : getFormattedDuration(value);
return <AlignRight>{formattedValue}</AlignRight>;
}
if (key === 'id') {
const eventTarget = generateLinkToEventInTraceView({
eventId: row.id,
traceSlug: row.trace,
timestamp: row.timestamp,
organization,
location,
view: domainViewFilters.view,
source: TraceViewSources.WEB_VITALS_MODULE,
});
return (
<NoOverflow>
<Link to={eventTarget}>{getShortEventId(row.id)}</Link>
</NoOverflow>
);
}
if (key === 'replayId') {
const replayTarget =
row['transaction.duration'] !== undefined &&
replayLinkGenerator(
organization,
{
replayId: row.replayId,
id: row.id,
'transaction.duration': row['transaction.duration'],
timestamp: row.timestamp,
},
undefined
);

return row.replayId && replayTarget && replayExists(row[key]) ? (
<AlignCenter>
<Link to={replayTarget}>{getShortEventId(row.replayId)}</Link>
</AlignCenter>
) : (
<AlignCenter>
<NoValue>{t('(no value)')}</NoValue>
</AlignCenter>
);
}
if (key === 'profile.id') {
if (!defined(project) || !defined(row['profile.id'])) {
return (
<AlignCenter>
<NoValue>{t('(no value)')}</NoValue>
</AlignCenter>
);
}
const target = generateProfileFlamechartRoute({
organization,
projectSlug,
profileId: String(row['profile.id']),
});

return (
<AlignCenter>
<Link to={target}>{getShortEventId(row['profile.id'])}</Link>
</AlignCenter>
);
}
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
return <AlignRight>{row[key]}</AlignRight>;
};

const renderSpansBodyCell = (col: Column, row: SpanSampleRowWithScore) => {
const {key} = col;
if (key === 'score') {
Expand Down Expand Up @@ -319,11 +206,7 @@ export function PageOverviewWebVitalsDetailPanel({
{
replayId: row.replayId,
id: '', // id doesn't actually matter here. Just to satisfy type.
'transaction.duration':
useEap || isInp || (isSpansWebVital && useSpansWebVitals)
? row[SpanIndexedField.SPAN_SELF_TIME]
: // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
row['transaction.duration'],
'transaction.duration': row[SpanIndexedField.SPAN_SELF_TIME],
timestamp: row.timestamp,
},
undefined
Expand Down Expand Up @@ -381,13 +264,6 @@ export function PageOverviewWebVitalsDetailPanel({
}
return <NoOverflow>{NO_VALUE}</NoOverflow>;
}
if (key === SpanIndexedField.SPAN_DESCRIPTION) {
return (
<NoOverflow>
<Tooltip title={row[key]}>{row[key]}</Tooltip>
</NoOverflow>
);
}
if (key === 'id') {
const eventTarget =
project?.slug &&
Expand Down Expand Up @@ -460,7 +336,7 @@ export function PageOverviewWebVitalsDetailPanel({
renderBodyCell: renderSpansBodyCell,
}}
/>
) : useEap || (isSpansWebVital && useSpansWebVitals) ? (
) : (
<GridEditable
data={spansTableData}
isLoading={isSpansLoading}
Expand All @@ -475,17 +351,6 @@ export function PageOverviewWebVitalsDetailPanel({
renderBodyCell: renderSpansBodyCell,
}}
/>
) : (
<GridEditable
data={transactionsTableData as any as TransactionSampleRowWithScore[]} // TODO: fix typing
isLoading={isTransactionWebVitalsQueryLoading}
columnOrder={PAGELOADS_COLUMN_ORDER}
columnSortBy={[sort]}
grid={{
renderHeadCell,
renderBodyCell,
}}
/>
)}
</TableContainer>
<PageAlert />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ describe('PagePerformanceTable', function () {
'count_scores(measurements.score.inp)': 985,
'count_scores(measurements.score.total)': 985,
'performance_score(measurements.score.total)': 0.847767385770207,
'total_opportunity_score()': 6.956683571915815e-5,
'opportunity_score(measurements.score.total)': 179.76662400002692,
'opportunity_score(measurements.score.total)': 0.0001,
'p75(measurements.inp)': 144.0,
'p75(measurements.ttfb)': 783.125,
'p75(measurements.lcp)': 700.2999782562256,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('WebVitalsDetailPanel', function () {
'count()',
],
query:
'transaction.op:[pageload,""] span.op:[ui.interaction.click,ui.interaction.hover,ui.interaction.drag,ui.interaction.press,ui.webvital.cls,ui.webvital.lcp,""] !transaction:"<< unparameterized >>"',
'span.op:[ui.interaction.click,ui.interaction.hover,ui.interaction.drag,ui.interaction.press,ui.webvital.cls,ui.webvital.lcp,pageload,""] !transaction:"<< unparameterized >>"',
}),
})
);
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('WebVitalsDetailPanel', function () {
'sum(measurements.score.weight.lcp)',
],
query:
'transaction.op:[pageload,""] span.op:[ui.interaction.click,ui.interaction.hover,ui.interaction.drag,ui.interaction.press,ui.webvital.cls,ui.webvital.lcp,""] !transaction:"<< unparameterized >>"',
'span.op:[ui.interaction.click,ui.interaction.hover,ui.interaction.drag,ui.interaction.press,ui.webvital.cls,ui.webvital.lcp,pageload,""] !transaction:"<< unparameterized >>"',
}),
})
);
Expand Down Expand Up @@ -133,10 +133,10 @@ describe('WebVitalsDetailPanel', function () {
'count_scores(measurements.score.inp)',
'count_scores(measurements.score.ttfb)',
'count_scores(measurements.score.total)',
'total_opportunity_score()',
'opportunity_score(measurements.score.total)',
],
query:
'transaction.op:[pageload,""] span.op:[ui.interaction.click,ui.interaction.hover,ui.interaction.drag,ui.interaction.press,ui.webvital.cls,ui.webvital.lcp,""] !transaction:"<< unparameterized >>" avg(measurements.score.total):>=0 count_scores(measurements.score.lcp):>0',
'span.op:[ui.interaction.click,ui.interaction.hover,ui.interaction.drag,ui.interaction.press,ui.webvital.cls,ui.webvital.lcp,pageload,\"\"] !transaction:\"<< unparameterized >>\" avg(measurements.score.total):>=0 count_scores(measurements.score.lcp):>0',
}),
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import type {
} from 'sentry/views/insights/browser/webVitals/types';
import decodeBrowserTypes from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import {SampleDrawerBody} from 'sentry/views/insights/common/components/sampleDrawerBody';
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
import {useModuleURL} from 'sentry/views/insights/common/utils/useModuleURL';
import {
ModuleName,
Expand Down Expand Up @@ -65,8 +64,6 @@ export function WebVitalsDetailPanel({webVital}: {webVital: WebVitals | null}) {
location.query[SpanIndexedField.USER_GEO_SUBREGION]
) as SubregionCode[];

const useEap = useInsightsEap();

const {data: projectData} = useProjectRawWebVitalsQuery({browserTypes, subregions});
const {data: projectScoresData} = useProjectWebVitalsScoresQuery({
weightWebVital: webVital ?? 'total',
Expand Down Expand Up @@ -97,11 +94,8 @@ export function WebVitalsDetailPanel({webVital}: {webVital: WebVitals | null}) {
if (!data) {
return [];
}
const sumWeights = useEap
? 1
: webVital
? projectScoresData?.[0]?.[`sum(measurements.score.weight.${webVital})`] || 0
: 0;
const sumWeights = 1;

return data
.map(row => ({
...row,
Expand All @@ -117,7 +111,7 @@ export function WebVitalsDetailPanel({webVital}: {webVital: WebVitals | null}) {
return b.opportunity - a.opportunity;
})
.slice(0, MAX_ROWS);
}, [data, projectScoresData, webVital, useEap]);
}, [data]);

useEffect(() => {
if (webVital !== null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {Tag} from 'sentry/types/group';
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
import {DEFAULT_QUERY_FILTER} from 'sentry/views/insights/browser/webVitals/settings';
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import {useDefaultWebVitalsQuery} from 'sentry/views/insights/browser/webVitals/utils/useDefaultQuery';
import {useMetrics} from 'sentry/views/insights/common/queries/useDiscover';
import {SpanMetricsField, type SubregionCode} from 'sentry/views/insights/types';

Expand All @@ -19,7 +19,6 @@ export const useProjectRawWebVitalsQuery = ({
subregions,
}: Props = {}) => {
const search = new MutableSearch([]);
const defaultQuery = useDefaultWebVitalsQuery();
if (transaction) {
search.addFilterValue('transaction', transaction);
}
Expand All @@ -35,7 +34,7 @@ export const useProjectRawWebVitalsQuery = ({

return useMetrics(
{
search: [defaultQuery, search.formatString()].join(' ').trim(),
search: [DEFAULT_QUERY_FILTER, search.formatString()].join(' ').trim(),
limit: 50,
fields: [
'p75(measurements.lcp)',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {getInterval} from 'sentry/components/charts/utils';
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
import usePageFilters from 'sentry/utils/usePageFilters';
import {DEFAULT_QUERY_FILTER} from 'sentry/views/insights/browser/webVitals/settings';
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import {useDefaultWebVitalsQuery} from 'sentry/views/insights/browser/webVitals/utils/useDefaultQuery';
import {useMetricsSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
import {SpanIndexedField, type SubregionCode} from 'sentry/views/insights/types';

type Props = {
Expand All @@ -19,8 +18,6 @@ export const useProjectRawWebVitalsValuesTimeseriesQuery = ({
subregions,
}: Props) => {
const pageFilters = usePageFilters();
const defaultQuery = useDefaultWebVitalsQuery();
const useEap = useInsightsEap();
const search = new MutableSearch([]);

if (transaction) {
Expand All @@ -33,12 +30,10 @@ export const useProjectRawWebVitalsValuesTimeseriesQuery = ({
search.addDisjunctionFilterValues(SpanIndexedField.USER_GEO_SUBREGION, subregions);
}

const interval = useEap ? 'spans-low' : 'low';

const result = useMetricsSeries(
{
search: [defaultQuery, search.formatString()].join(' ').trim(),
interval: getInterval(pageFilters.selection.datetime, interval),
search: [DEFAULT_QUERY_FILTER, search.formatString()].join(' ').trim(),
interval: getInterval(pageFilters.selection.datetime, 'spans-low'),
yAxis: [
'p75(measurements.lcp)',
'p75(measurements.fcp)',
Expand Down
Loading
Loading