Skip to content

Commit 6b072c1

Browse files
authored
ref(✂️): remove unused code from discover (#90150)
1 parent 09b3bc5 commit 6b072c1

File tree

4 files changed

+23
-171
lines changed

4 files changed

+23
-171
lines changed

static/app/utils/discover/fieldRenderers.tsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,32 +1133,3 @@ export function getFieldRenderer(
11331133
}
11341134
return partial(FIELD_FORMATTERS.string.renderFunc, fieldName);
11351135
}
1136-
1137-
type FieldTypeFormatterRenderFunctionPartial = (
1138-
data: EventData,
1139-
baggage?: RenderFunctionBaggage
1140-
) => React.ReactNode;
1141-
1142-
/**
1143-
* Get the field renderer for the named field only based on its type from the given
1144-
* metadata.
1145-
*
1146-
* @param {String} field name
1147-
* @param {object} metadata mapping.
1148-
* @param {boolean} isAlias convert the name with getAggregateAlias
1149-
* @returns {Function}
1150-
*/
1151-
export function getFieldFormatter(
1152-
field: string,
1153-
meta: MetaType,
1154-
isAlias = true
1155-
): FieldTypeFormatterRenderFunctionPartial {
1156-
const fieldName = isAlias ? getAggregateAlias(field) : field;
1157-
const fieldType = meta[fieldName] || meta.fields?.[fieldName];
1158-
1159-
if (FIELD_FORMATTERS.hasOwnProperty(fieldType)) {
1160-
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
1161-
return partial(FIELD_FORMATTERS[fieldType].renderFunc, fieldName);
1162-
}
1163-
return partial(FIELD_FORMATTERS.string.renderFunc, fieldName);
1164-
}

static/app/utils/discover/fields.tsx

Lines changed: 23 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -205,23 +205,6 @@ export const SIZE_UNIT_MULTIPLIERS: Record<SizeUnit, number> = {
205205
exabyte: 1000 ** 6,
206206
};
207207

208-
export const SIZE_UNIT_LABELS: Record<SizeUnit, string> = {
209-
bit: 'b',
210-
byte: 'B',
211-
kibibyte: 'KiB',
212-
kilobyte: 'KB',
213-
mebibyte: 'MiB',
214-
megabyte: 'MB',
215-
gibibyte: 'GiB',
216-
gigabyte: 'GB',
217-
tebibyte: 'TiB',
218-
terabyte: 'TB',
219-
pebibyte: 'PiB',
220-
petabyte: 'PB',
221-
exbibyte: 'EiB',
222-
exabyte: 'EB',
223-
};
224-
225208
export enum RateUnit {
226209
PER_SECOND = '1/second',
227210
PER_MINUTE = '1/minute',
@@ -611,7 +594,7 @@ export const AGGREGATIONS = {
611594
} as const;
612595

613596
// TPM and TPS are aliases that are only used in Performance
614-
export const ALIASES = {
597+
const ALIASES = {
615598
tpm: AggregationKey.EPM,
616599
tps: AggregationKey.EPS,
617600
};
@@ -840,8 +823,8 @@ export const ERRORS_AGGREGATION_FUNCTIONS = [
840823
// This list contains fields/functions that are available with profiling feature.
841824
export const PROFILING_FIELDS: string[] = [FieldKey.PROFILE_ID];
842825

843-
export const MEASUREMENT_PATTERN = /^measurements\.([a-zA-Z0-9-_.]+)$/;
844-
export const SPAN_OP_BREAKDOWN_PATTERN = /^spans\.([a-zA-Z0-9-_.]+)$/;
826+
const MEASUREMENT_PATTERN = /^measurements\.([a-zA-Z0-9-_.]+)$/;
827+
const SPAN_OP_BREAKDOWN_PATTERN = /^spans\.([a-zA-Z0-9-_.]+)$/;
845828

846829
export function isMeasurement(field: string): boolean {
847830
return MEASUREMENT_PATTERN.test(field);
@@ -899,7 +882,7 @@ function _lookback(columnText: string, j: number, str: string) {
899882
return columnText.substring(j - str.length, j) === str;
900883
}
901884

902-
export function parseArguments(columnText: string): string[] {
885+
function parseArguments(columnText: string): string[] {
903886
const args: string[] = [];
904887

905888
let quoted = false;
@@ -961,7 +944,7 @@ export function parseArguments(columnText: string): string[] {
961944
// `|` is an invalid field character, so it is used to determine whether a field is an equation or not
962945
export const EQUATION_PREFIX = 'equation|';
963946
const EQUATION_ALIAS_PATTERN = /^equation\[(\d+)\]$/;
964-
export const CALCULATED_FIELD_PREFIX = 'calculated|';
947+
const CALCULATED_FIELD_PREFIX = 'calculated|';
965948

966949
export function isEquation(field: string): boolean {
967950
return field.startsWith(EQUATION_PREFIX);
@@ -1041,7 +1024,7 @@ export function generateAggregateFields(
10411024
return fields.map(field => ({field})) as Field[];
10421025
}
10431026

1044-
export function isDerivedMetric(field: string): boolean {
1027+
function isDerivedMetric(field: string): boolean {
10451028
return field.startsWith(CALCULATED_FIELD_PREFIX);
10461029
}
10471030

@@ -1132,7 +1115,7 @@ export function isAggregateFieldOrEquation(field: string): boolean {
11321115
* Temporary hardcoded hack to enable testing derived metrics.
11331116
* Can be removed after we get rid of getAggregateFields
11341117
*/
1135-
export function isNumericMetrics(field: string): boolean {
1118+
function isNumericMetrics(field: string): boolean {
11361119
return [
11371120
'session.crash_free_rate',
11381121
'session.crashed',
@@ -1142,7 +1125,7 @@ export function isNumericMetrics(field: string): boolean {
11421125
].includes(field);
11431126
}
11441127

1145-
export function getAggregateFields(fields: string[]): string[] {
1128+
function getAggregateFields(fields: string[]): string[] {
11461129
return fields.filter(
11471130
field =>
11481131
isAggregateField(field) || isAggregateEquation(field) || isNumericMetrics(field)
@@ -1311,34 +1294,6 @@ export function errorsAndTransactionsAggregateFunctionOutputType(
13111294
return null;
13121295
}
13131296

1314-
export function sessionsAggregateFunctionOutputType(
1315-
funcName: string,
1316-
firstArg: string | undefined
1317-
): AggregationOutputType | null {
1318-
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
1319-
const aggregate = SESSIONS_OPERATIONS[funcName];
1320-
1321-
// Attempt to use the function's outputType.
1322-
if (aggregate?.outputType) {
1323-
return aggregate.outputType;
1324-
}
1325-
1326-
// If the first argument is undefined and it is not required,
1327-
// then we attempt to get the default value.
1328-
if (!firstArg && aggregate?.parameters?.[0]) {
1329-
if (aggregate.parameters[0].required === false) {
1330-
firstArg = aggregate.parameters[0].defaultValue;
1331-
}
1332-
}
1333-
1334-
if (firstArg && SESSIONS_FIELDS.hasOwnProperty(firstArg)) {
1335-
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
1336-
return SESSIONS_FIELDS[firstArg].type as AggregationOutputType;
1337-
}
1338-
1339-
return null;
1340-
}
1341-
13421297
/**
13431298
* Get the multi-series chart type for an aggregate function.
13441299
*/
@@ -1439,7 +1394,7 @@ export function getSpanOperationName(field: string): string | null {
14391394
return null;
14401395
}
14411396

1442-
export function getColumnType(column: Column): ColumnType {
1397+
function getColumnType(column: Column): ColumnType {
14431398
if (column.kind === 'function') {
14441399
const outputType = aggregateFunctionOutputType(
14451400
column.function[0],
@@ -1474,7 +1429,7 @@ export function hasDuplicate(columnList: Column[], column: Column): boolean {
14741429
// Search categorizations for the new `SearchQueryBuilder` component.
14751430
// Each Insights module page will have different points of interest for searching, so use these on a case-by-case basis
14761431

1477-
export const TRANSACTION_FILTERS: FilterKeySection = {
1432+
const TRANSACTION_FILTERS: FilterKeySection = {
14781433
value: 'transaction_event_filters',
14791434
label: 'Event',
14801435
children: [
@@ -1490,7 +1445,7 @@ export const TRANSACTION_FILTERS: FilterKeySection = {
14901445
],
14911446
};
14921447

1493-
export const USER_FILTERS: FilterKeySection = {
1448+
const USER_FILTERS: FilterKeySection = {
14941449
value: 'user_filters',
14951450
label: 'User',
14961451
children: [
@@ -1503,7 +1458,7 @@ export const USER_FILTERS: FilterKeySection = {
15031458
],
15041459
};
15051460

1506-
export const GEO_FILTERS: FilterKeySection = {
1461+
const GEO_FILTERS: FilterKeySection = {
15071462
value: 'geo_filters',
15081463
label: 'Geo',
15091464
children: [
@@ -1514,7 +1469,7 @@ export const GEO_FILTERS: FilterKeySection = {
15141469
],
15151470
};
15161471

1517-
export const HTTP_FILTERS: FilterKeySection = {
1472+
const HTTP_FILTERS: FilterKeySection = {
15181473
value: 'http_filters',
15191474
label: 'HTTP',
15201475
children: [
@@ -1525,7 +1480,7 @@ export const HTTP_FILTERS: FilterKeySection = {
15251480
],
15261481
};
15271482

1528-
export const WEB_VITAL_FILTERS: FilterKeySection = {
1483+
const WEB_VITAL_FILTERS: FilterKeySection = {
15291484
value: 'web_filters',
15301485
label: 'Web Vitals',
15311486
children: [
@@ -1539,7 +1494,7 @@ export const WEB_VITAL_FILTERS: FilterKeySection = {
15391494
],
15401495
};
15411496

1542-
export const MOBILE_VITAL_FILTERS: FilterKeySection = {
1497+
const MOBILE_VITAL_FILTERS: FilterKeySection = {
15431498
value: 'mobile_vitals_filters',
15441499
label: 'Mobile Vitals',
15451500
children: [
@@ -1559,7 +1514,7 @@ export const MOBILE_VITAL_FILTERS: FilterKeySection = {
15591514
],
15601515
};
15611516

1562-
export const DEVICE_FILTERS: FilterKeySection = {
1517+
const DEVICE_FILTERS: FilterKeySection = {
15631518
value: 'device_filters',
15641519
label: 'Device',
15651520
children: [
@@ -1583,7 +1538,7 @@ export const DEVICE_FILTERS: FilterKeySection = {
15831538
],
15841539
};
15851540

1586-
export const RELEASE_FILTERS: FilterKeySection = {
1541+
const RELEASE_FILTERS: FilterKeySection = {
15871542
value: 'release_filters',
15881543
label: 'Release',
15891544
children: [
@@ -1595,23 +1550,7 @@ export const RELEASE_FILTERS: FilterKeySection = {
15951550
],
15961551
};
15971552

1598-
export const STACKTRACE_FILTERS: FilterKeySection = {
1599-
value: 'stacktrace_filters',
1600-
label: 'Stacktrace',
1601-
children: [
1602-
FieldKey.STACK_ABS_PATH,
1603-
FieldKey.STACK_COLNO,
1604-
FieldKey.STACK_FILENAME,
1605-
FieldKey.STACK_FUNCTION,
1606-
FieldKey.STACK_IN_APP,
1607-
FieldKey.STACK_LINENO,
1608-
FieldKey.STACK_MODULE,
1609-
FieldKey.STACK_PACKAGE,
1610-
FieldKey.STACK_STACK_LEVEL,
1611-
],
1612-
};
1613-
1614-
export const ERROR_DETAIL_FILTERS: FilterKeySection = {
1553+
const ERROR_DETAIL_FILTERS: FilterKeySection = {
16151554
value: 'error_detail_filters',
16161555
label: 'Error',
16171556
children: [
@@ -1627,23 +1566,7 @@ export const ERROR_DETAIL_FILTERS: FilterKeySection = {
16271566
],
16281567
};
16291568

1630-
export const MISC_FILTERS: FilterKeySection = {
1631-
value: 'misc_filters',
1632-
label: 'Misc',
1633-
children: [FieldKey.HAS, FieldKey.DIST],
1634-
};
1635-
1636-
export const TRANSACTION_EVENT_FILTERS: FilterKeySection = {
1637-
value: 'transaction_event_filters',
1638-
label: 'Event',
1639-
children: [
1640-
...TRANSACTION_FILTERS.children,
1641-
...HTTP_FILTERS.children,
1642-
...RELEASE_FILTERS.children,
1643-
],
1644-
};
1645-
1646-
export const ERROR_EVENT_FILTERS: FilterKeySection = {
1569+
const ERROR_EVENT_FILTERS: FilterKeySection = {
16471570
value: 'error_event_filters',
16481571
label: 'Event',
16491572
children: [
@@ -1653,7 +1576,7 @@ export const ERROR_EVENT_FILTERS: FilterKeySection = {
16531576
],
16541577
};
16551578

1656-
export const COMBINED_EVENT_FILTERS: FilterKeySection = {
1579+
const COMBINED_EVENT_FILTERS: FilterKeySection = {
16571580
value: 'combined_event_filters',
16581581
label: 'Event',
16591582
children: [
@@ -1664,7 +1587,7 @@ export const COMBINED_EVENT_FILTERS: FilterKeySection = {
16641587
],
16651588
};
16661589

1667-
export const USER_CONTEXT_FILTERS: FilterKeySection = {
1590+
const USER_CONTEXT_FILTERS: FilterKeySection = {
16681591
value: 'user_context_filters',
16691592
label: 'User',
16701593
children: [
@@ -1674,7 +1597,7 @@ export const USER_CONTEXT_FILTERS: FilterKeySection = {
16741597
],
16751598
};
16761599

1677-
export const PERFORMANCE_FILTERS: FilterKeySection = {
1600+
const PERFORMANCE_FILTERS: FilterKeySection = {
16781601
value: 'performance_filters',
16791602
label: 'Performance',
16801603
children: [...WEB_VITAL_FILTERS.children, ...MOBILE_VITAL_FILTERS.children],
@@ -1702,7 +1625,7 @@ export const COMBINED_DATASET_FILTER_KEY_SECTIONS: FilterKeySection[] = [
17021625
// will take in a project platform key, and output only the relevant filter key sections.
17031626
// This way, users will not be suggested mobile fields for a backend transaction, for example.
17041627

1705-
export const TYPED_TAG_KEY_RE = /tags\[([^\s]*),([^\s]*)\]/;
1628+
const TYPED_TAG_KEY_RE = /tags\[([^\s]*),([^\s]*)\]/;
17061629

17071630
export function classifyTagKey(key: string): FieldKind {
17081631
const result = key.match(TYPED_TAG_KEY_RE);

static/app/views/discover/chartFooter.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import type {SelectValue} from 'sentry/types/core';
1111
import type EventView from 'sentry/utils/discover/eventView';
1212
import {TOP_EVENT_MODES} from 'sentry/utils/discover/types';
1313

14-
export const PROCESSED_BASELINE_TOGGLE_KEY = 'show-processed-baseline';
15-
1614
type Props = {
1715
displayMode: string;
1816
displayOptions: Array<SelectValue<string>>;

0 commit comments

Comments
 (0)