Skip to content

Commit eed44b6

Browse files
fix: remove CategoryInfo.apiName (#95444)
Closes https://linear.app/getsentry/issue/BIL-1036/make-datacategoryinfoapiname-consistent None of the categories have an `apiName` different from `name` so might as well just get rid of `apiName`.
1 parent 9fc1341 commit eed44b6

File tree

11 files changed

+46
-63
lines changed

11 files changed

+46
-63
lines changed

static/app/constants/index.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ const GIGABYTE = 10 ** 9;
246246
export const DATA_CATEGORY_INFO = {
247247
[DataCategoryExact.ERROR]: {
248248
name: DataCategoryExact.ERROR,
249-
apiName: 'error',
250249
plural: DataCategory.ERRORS,
251250
singular: 'error',
252251
displayName: 'error',
@@ -262,7 +261,6 @@ export const DATA_CATEGORY_INFO = {
262261
},
263262
[DataCategoryExact.TRANSACTION]: {
264263
name: DataCategoryExact.TRANSACTION,
265-
apiName: 'transaction',
266264
plural: DataCategory.TRANSACTIONS,
267265
singular: 'transaction',
268266
displayName: 'transaction',
@@ -278,7 +276,6 @@ export const DATA_CATEGORY_INFO = {
278276
},
279277
[DataCategoryExact.ATTACHMENT]: {
280278
name: DataCategoryExact.ATTACHMENT,
281-
apiName: 'attachment',
282279
plural: DataCategory.ATTACHMENTS,
283280
singular: 'attachment',
284281
displayName: 'attachment',
@@ -295,7 +292,6 @@ export const DATA_CATEGORY_INFO = {
295292
},
296293
[DataCategoryExact.PROFILE]: {
297294
name: DataCategoryExact.PROFILE,
298-
apiName: 'profile',
299295
plural: DataCategory.PROFILES,
300296
singular: 'profile',
301297
displayName: 'profile',
@@ -311,7 +307,6 @@ export const DATA_CATEGORY_INFO = {
311307
},
312308
[DataCategoryExact.PROFILE_INDEXED]: {
313309
name: DataCategoryExact.PROFILE_INDEXED,
314-
apiName: 'profileIndexed',
315310
plural: DataCategory.PROFILES_INDEXED,
316311
singular: 'profileIndexed',
317312
displayName: 'indexed profile',
@@ -323,7 +318,6 @@ export const DATA_CATEGORY_INFO = {
323318
},
324319
[DataCategoryExact.REPLAY]: {
325320
name: DataCategoryExact.REPLAY,
326-
apiName: 'replay',
327321
plural: DataCategory.REPLAYS,
328322
singular: 'replay',
329323
displayName: 'replay',
@@ -339,7 +333,6 @@ export const DATA_CATEGORY_INFO = {
339333
},
340334
[DataCategoryExact.USER_REPORT_V2]: {
341335
name: DataCategoryExact.USER_REPORT_V2,
342-
apiName: 'feedback',
343336
plural: DataCategory.USER_REPORT_V2,
344337
singular: 'feedback',
345338
displayName: 'user feedback',
@@ -355,7 +348,6 @@ export const DATA_CATEGORY_INFO = {
355348
},
356349
[DataCategoryExact.TRANSACTION_PROCESSED]: {
357350
name: DataCategoryExact.TRANSACTION_PROCESSED,
358-
apiName: 'transactions',
359351
plural: DataCategory.TRANSACTIONS_PROCESSED,
360352
singular: 'transactionProcessed',
361353
displayName: 'transaction',
@@ -370,7 +362,6 @@ export const DATA_CATEGORY_INFO = {
370362
},
371363
[DataCategoryExact.TRANSACTION_INDEXED]: {
372364
name: DataCategoryExact.TRANSACTION_INDEXED,
373-
apiName: 'transactionIndexed',
374365
plural: DataCategory.TRANSACTIONS_INDEXED,
375366
singular: 'transactionIndexed',
376367
displayName: 'indexed transaction',
@@ -382,7 +373,6 @@ export const DATA_CATEGORY_INFO = {
382373
},
383374
[DataCategoryExact.MONITOR]: {
384375
name: DataCategoryExact.MONITOR,
385-
apiName: 'monitor',
386376
plural: DataCategory.MONITOR,
387377
singular: 'monitor',
388378
displayName: 'monitor check-in',
@@ -397,7 +387,6 @@ export const DATA_CATEGORY_INFO = {
397387
},
398388
[DataCategoryExact.SPAN]: {
399389
name: DataCategoryExact.SPAN,
400-
apiName: 'span',
401390
plural: DataCategory.SPANS,
402391
singular: 'span',
403392
displayName: 'span',
@@ -413,7 +402,6 @@ export const DATA_CATEGORY_INFO = {
413402
},
414403
[DataCategoryExact.MONITOR_SEAT]: {
415404
name: DataCategoryExact.MONITOR_SEAT,
416-
apiName: 'monitorSeat',
417405
plural: DataCategory.MONITOR_SEATS,
418406
singular: 'monitorSeat',
419407
displayName: 'cron monitor',
@@ -429,7 +417,6 @@ export const DATA_CATEGORY_INFO = {
429417
},
430418
[DataCategoryExact.SPAN_INDEXED]: {
431419
name: DataCategoryExact.SPAN_INDEXED,
432-
apiName: 'span_indexed',
433420
plural: DataCategory.SPANS_INDEXED,
434421
singular: 'spanIndexed',
435422
displayName: 'stored span',
@@ -442,7 +429,6 @@ export const DATA_CATEGORY_INFO = {
442429
},
443430
[DataCategoryExact.PROFILE_DURATION]: {
444431
name: DataCategoryExact.PROFILE_DURATION,
445-
apiName: 'profile_duration',
446432
plural: DataCategory.PROFILE_DURATION,
447433
singular: 'profileDuration',
448434
displayName: 'continuous profile hour',
@@ -459,7 +445,6 @@ export const DATA_CATEGORY_INFO = {
459445
},
460446
[DataCategoryExact.PROFILE_CHUNK]: {
461447
name: DataCategoryExact.PROFILE_CHUNK,
462-
apiName: 'profile_chunk',
463448
plural: DataCategory.PROFILE_CHUNKS,
464449
singular: 'profileChunk',
465450
displayName: 'profile chunk',
@@ -471,7 +456,6 @@ export const DATA_CATEGORY_INFO = {
471456
},
472457
[DataCategoryExact.PROFILE_DURATION_UI]: {
473458
name: DataCategoryExact.PROFILE_DURATION_UI,
474-
apiName: 'profile_duration_ui',
475459
plural: DataCategory.PROFILE_DURATION_UI,
476460
singular: 'profileDurationUI',
477461
displayName: 'UI profile hour',
@@ -488,7 +472,6 @@ export const DATA_CATEGORY_INFO = {
488472
},
489473
[DataCategoryExact.PROFILE_CHUNK_UI]: {
490474
name: DataCategoryExact.PROFILE_CHUNK_UI,
491-
apiName: 'profile_chunk_ui',
492475
plural: DataCategory.PROFILE_CHUNKS_UI,
493476
singular: 'profileChunkUI',
494477
displayName: 'UI profile chunk',
@@ -501,7 +484,6 @@ export const DATA_CATEGORY_INFO = {
501484

502485
[DataCategoryExact.UPTIME]: {
503486
name: DataCategoryExact.UPTIME,
504-
apiName: 'uptime',
505487
plural: DataCategory.UPTIME,
506488
singular: 'uptime',
507489
displayName: 'uptime monitor',
@@ -517,7 +499,6 @@ export const DATA_CATEGORY_INFO = {
517499
},
518500
[DataCategoryExact.LOG_ITEM]: {
519501
name: DataCategoryExact.LOG_ITEM,
520-
apiName: 'log_item',
521502
plural: DataCategory.LOG_ITEM,
522503
singular: 'logItem',
523504
displayName: 'log',
@@ -532,7 +513,6 @@ export const DATA_CATEGORY_INFO = {
532513
},
533514
[DataCategoryExact.LOG_BYTE]: {
534515
name: DataCategoryExact.LOG_BYTE,
535-
apiName: 'log_byte',
536516
plural: DataCategory.LOG_BYTE,
537517
singular: 'logByte',
538518
displayName: 'log byte',
@@ -548,7 +528,6 @@ export const DATA_CATEGORY_INFO = {
548528
},
549529
[DataCategoryExact.SEER_AUTOFIX]: {
550530
name: DataCategoryExact.SEER_AUTOFIX,
551-
apiName: 'seer_autofix',
552531
plural: DataCategory.SEER_AUTOFIX,
553532
singular: 'seerAutofix',
554533
displayName: 'issue fix',
@@ -563,7 +542,6 @@ export const DATA_CATEGORY_INFO = {
563542
},
564543
[DataCategoryExact.SEER_SCANNER]: {
565544
name: DataCategoryExact.SEER_SCANNER,
566-
apiName: 'seer_scanner',
567545
plural: DataCategory.SEER_SCANNER,
568546
singular: 'seerScanner',
569547
displayName: 'issue scan',

static/app/types/core.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export enum DataCategoryExact {
127127
}
128128

129129
export interface DataCategoryInfo {
130-
apiName: string;
131130
displayName: string;
132131
isBilledCategory: boolean;
133132
name: DataCategoryExact;

static/app/views/organizationStats/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
9090
) {
9191
return {
9292
...info,
93-
apiName: 'span_indexed',
93+
name: DataCategoryExact.SPAN_INDEXED,
9494
};
9595
}
9696

@@ -106,6 +106,10 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
106106
return this.dataCategoryInfo.titleName;
107107
}
108108

109+
get dataCategoryApiName() {
110+
return this.dataCategoryInfo.name;
111+
}
112+
109113
get dataDatetime(): DateTimeObject {
110114
const params = this.props.selection.datetime;
111115

@@ -330,8 +334,8 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
330334
projectIds={this.projectIds}
331335
organization={organization}
332336
dataCategory={this.dataCategory}
333-
dataCategoryName={this.dataCategoryInfo.titleName}
334-
dataCategoryApiName={this.dataCategoryInfo.apiName}
337+
dataCategoryName={this.dataCategoryName}
338+
dataCategoryApiName={this.dataCategoryApiName}
335339
dataDatetime={this.dataDatetime}
336340
chartTransform={this.chartTransform}
337341
clientDiscard={this.clientDiscard}

static/app/views/organizationStats/usageStatsOrg.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {DEFAULT_STATS_PERIOD} from 'sentry/constants';
2020
import {IconSettings} from 'sentry/icons';
2121
import {t, tct} from 'sentry/locale';
2222
import {space} from 'sentry/styles/space';
23-
import type {DataCategory, DataCategoryInfo, IntervalPeriod} from 'sentry/types/core';
23+
import type {
24+
DataCategory,
25+
DataCategoryExact,
26+
DataCategoryInfo,
27+
IntervalPeriod,
28+
} from 'sentry/types/core';
2429
import type {Organization} from 'sentry/types/organization';
2530
import {trackAnalytics} from 'sentry/utils/analytics';
2631
import {shouldUse24Hours} from 'sentry/utils/dates';
@@ -292,8 +297,8 @@ function ChartContainer({children}: {children: React.ReactNode}) {
292297

293298
export interface UsageStatsOrganizationProps {
294299
dataCategory: DataCategory;
295-
dataCategoryApiName: DataCategoryInfo['apiName'];
296-
dataCategoryName: string;
300+
dataCategoryApiName: DataCategoryExact;
301+
dataCategoryName: DataCategoryInfo['titleName'];
297302
dataDatetime: DateTimeObject;
298303
handleChangeState: (state: {
299304
clientDiscard?: boolean;

static/app/views/organizationStats/usageStatsPerMin.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import styled from '@emotion/styled';
22

33
import {t} from 'sentry/locale';
4-
import type {DataCategory, DataCategoryInfo} from 'sentry/types/core';
5-
import {Outcome} from 'sentry/types/core';
4+
import type {DataCategory} from 'sentry/types/core';
5+
import {DataCategoryExact, Outcome} from 'sentry/types/core';
66
import type {Organization} from 'sentry/types/organization';
77
import {useApiQuery} from 'sentry/utils/queryClient';
88

@@ -11,7 +11,7 @@ import {formatUsageWithUnits, getFormatUsageOptions} from './utils';
1111

1212
type Props = {
1313
dataCategory: DataCategory;
14-
dataCategoryApiName: DataCategoryInfo['apiName'];
14+
dataCategoryApiName: DataCategoryExact;
1515
organization: Organization;
1616
projectIds: number[];
1717
};
@@ -67,13 +67,12 @@ function UsageStatsPerMin({
6767
const eventsLastMin = groups.reduce((count, group) => {
6868
const {category, outcome} = group.by;
6969

70-
if (dataCategoryApiName === 'span_indexed') {
71-
if (category !== 'span_indexed' || outcome !== Outcome.ACCEPTED) {
70+
if (dataCategoryApiName === DataCategoryExact.SPAN_INDEXED) {
71+
if (category !== DataCategoryExact.SPAN_INDEXED || outcome !== Outcome.ACCEPTED) {
7272
return count;
7373
}
7474
} else {
75-
// HACK: The backend enum are singular, but the frontend enums are plural
76-
if (!dataCategory.includes(`${category}`) || outcome !== Outcome.ACCEPTED) {
75+
if (dataCategoryApiName !== category || outcome !== Outcome.ACCEPTED) {
7776
return count;
7877
}
7978
}

static/app/views/organizationStats/usageStatsProjects.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
1717
import {t} from 'sentry/locale';
1818
import {space} from 'sentry/styles/space';
1919
import type {DataCategoryInfo} from 'sentry/types/core';
20-
import {Outcome} from 'sentry/types/core';
20+
import {DataCategoryExact, Outcome} from 'sentry/types/core';
2121
import type {Project} from 'sentry/types/project';
2222
import {hasDynamicSamplingCustomFeature} from 'sentry/utils/dynamicSampling/features';
2323
import {useApiQuery} from 'sentry/utils/queryClient';
@@ -89,22 +89,24 @@ export function UsageStatsProjects({
8989
};
9090

9191
const groupBy = ['outcome', 'project'];
92-
const category: string[] = [dataCategory.apiName];
92+
const category: string[] = [dataCategory.name];
9393

9494
if (
9595
hasDynamicSamplingCustomFeature(organization) &&
96-
dataCategory.apiName === 'span'
96+
dataCategory.name === DataCategoryExact.SPAN
9797
) {
9898
groupBy.push('category');
99-
category.push('span_indexed');
99+
category.push(DataCategoryExact.SPAN_INDEXED);
100100
}
101101
if (
102-
dataCategory.apiName === 'profile_duration' ||
103-
dataCategory.apiName === 'profile_duration_ui'
102+
dataCategory.name === DataCategoryExact.PROFILE_DURATION ||
103+
dataCategory.name === DataCategoryExact.PROFILE_DURATION_UI
104104
) {
105105
groupBy.push('category');
106106
category.push(
107-
dataCategory.apiName === 'profile_duration' ? 'profile_chunk' : 'profile_chunk_ui'
107+
dataCategory.name === DataCategoryExact.PROFILE_DURATION
108+
? DataCategoryExact.PROFILE_CHUNK
109+
: DataCategoryExact.PROFILE_CHUNK_UI
108110
);
109111
}
110112

@@ -458,7 +460,7 @@ export function UsageStatsProjects({
458460
const tableData = useMemo(() => {
459461
const showStoredOutcome =
460462
hasDynamicSamplingCustomFeature(organization) &&
461-
dataCategory.apiName === 'span' &&
463+
dataCategory.name === DataCategoryExact.SPAN &&
462464
seriesData.hasStoredOutcome;
463465

464466
return {

static/gsAdmin/components/customers/customerStats.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {Fragment, memo, useMemo} from 'react';
22
import {useTheme} from '@emotion/react';
33
import styled from '@emotion/styled';
44
import cloneDeep from 'lodash/cloneDeep';
5-
import snakeCase from 'lodash/snakeCase';
65
import startCase from 'lodash/startCase';
76
import moment from 'moment-timezone';
87

@@ -15,6 +14,7 @@ import LoadingError from 'sentry/components/loadingError';
1514
import LoadingIndicator from 'sentry/components/loadingIndicator';
1615
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
1716
import {space} from 'sentry/styles/space';
17+
import type {DataCategoryExact} from 'sentry/types/core';
1818
import type {DataPoint} from 'sentry/types/echarts';
1919
import type {Organization} from 'sentry/types/organization';
2020
import type {Project} from 'sentry/types/project';
@@ -23,8 +23,6 @@ import getDynamicText from 'sentry/utils/getDynamicText';
2323
import {useApiQuery} from 'sentry/utils/queryClient';
2424
import useRouter from 'sentry/utils/useRouter';
2525

26-
import type {DataType} from 'admin/components/customers/customerStatsFilters';
27-
2826
enum SeriesName {
2927
ACCEPTED = 'Accepted',
3028
FILTERED = 'Filtered (Server)',
@@ -326,7 +324,7 @@ function FooterLegend({points}: LegendProps) {
326324
}
327325

328326
type Props = {
329-
dataType: DataType;
327+
dataType: DataCategoryExact;
330328
orgSlug: Organization['slug'];
331329
onDemandPeriodEnd?: string;
332330
onDemandPeriodStart?: string;
@@ -394,7 +392,7 @@ export const CustomerStats = memo(
394392
interval: getInterval(dataDatetime),
395393
groupBy: ['outcome', 'reason'],
396394
field: 'sum(quantity)',
397-
category: snakeCase(dataType), // TODO(isabella): remove snakeCase when .apiName is consistent
395+
category: dataType,
398396
...(projectId ? {project: projectId} : {}),
399397
},
400398
},

static/gsAdmin/components/customers/customerStatsFilters.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ import useRouter from 'sentry/utils/useRouter';
1616

1717
const ON_DEMAND_PERIOD_KEY = 'onDemand';
1818

19-
export type DataType =
20-
(typeof DATA_CATEGORY_INFO)[keyof typeof DATA_CATEGORY_INFO]['apiName'];
21-
2219
type Props = {
23-
dataType: DataType;
24-
onChange: (dataType: DataType) => void;
20+
dataType: DataCategoryExact;
21+
onChange: (dataType: DataCategoryExact) => void;
2522
organization: Organization;
2623
onDemandPeriodEnd?: string;
2724
onDemandPeriodStart?: string;
@@ -110,7 +107,7 @@ export function CustomerStatsFilters({
110107
options={Object.entries(DATA_CATEGORY_INFO)
111108
.filter(([_, categoryInfo]) => categoryInfo.statsInfo.showInternalStats)
112109
.map(([category, categoryInfo]) => ({
113-
value: categoryInfo.apiName,
110+
value: categoryInfo.name,
114111
label:
115112
category === DataCategoryExact.SPAN
116113
? 'Accepted Spans'

0 commit comments

Comments
 (0)