Skip to content

Commit fad1fc6

Browse files
fix: DataCategoryExact should match Relay (#94663)
Closes https://linear.app/getsentry/issue/BIL-972/make-datacategoryexact-consistent Hence the name :)
1 parent e633087 commit fad1fc6

File tree

12 files changed

+103
-59
lines changed

12 files changed

+103
-59
lines changed

static/app/constants/index.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export const DATA_CATEGORY_INFO = {
248248
name: DataCategoryExact.ERROR,
249249
apiName: 'error',
250250
plural: DataCategory.ERRORS,
251+
singular: 'error',
251252
displayName: 'error',
252253
titleName: t('Errors'),
253254
productName: t('Error Monitoring'),
@@ -263,6 +264,7 @@ export const DATA_CATEGORY_INFO = {
263264
name: DataCategoryExact.TRANSACTION,
264265
apiName: 'transaction',
265266
plural: DataCategory.TRANSACTIONS,
267+
singular: 'transaction',
266268
displayName: 'transaction',
267269
titleName: t('Transactions'),
268270
productName: t('Performance Monitoring'),
@@ -278,6 +280,7 @@ export const DATA_CATEGORY_INFO = {
278280
name: DataCategoryExact.ATTACHMENT,
279281
apiName: 'attachment',
280282
plural: DataCategory.ATTACHMENTS,
283+
singular: 'attachment',
281284
displayName: 'attachment',
282285
titleName: t('Attachments'),
283286
productName: t('Attachments'),
@@ -294,6 +297,7 @@ export const DATA_CATEGORY_INFO = {
294297
name: DataCategoryExact.PROFILE,
295298
apiName: 'profile',
296299
plural: DataCategory.PROFILES,
300+
singular: 'profile',
297301
displayName: 'profile',
298302
titleName: t('Profiles'),
299303
productName: t('Continuous Profiling'),
@@ -309,6 +313,7 @@ export const DATA_CATEGORY_INFO = {
309313
name: DataCategoryExact.PROFILE_INDEXED,
310314
apiName: 'profileIndexed',
311315
plural: DataCategory.PROFILES_INDEXED,
316+
singular: 'profileIndexed',
312317
displayName: 'indexed profile',
313318
titleName: t('Indexed Profiles'),
314319
productName: t('Continuous Profiling'),
@@ -320,6 +325,7 @@ export const DATA_CATEGORY_INFO = {
320325
name: DataCategoryExact.REPLAY,
321326
apiName: 'replay',
322327
plural: DataCategory.REPLAYS,
328+
singular: 'replay',
323329
displayName: 'replay',
324330
titleName: t('Session Replays'),
325331
productName: t('Session Replay'),
@@ -335,6 +341,7 @@ export const DATA_CATEGORY_INFO = {
335341
name: DataCategoryExact.USER_REPORT_V2,
336342
apiName: 'feedback',
337343
plural: DataCategory.USER_REPORT_V2,
344+
singular: 'feedback',
338345
displayName: 'user feedback',
339346
titleName: t('User Feedback'),
340347
productName: t('User Feedback'),
@@ -350,6 +357,7 @@ export const DATA_CATEGORY_INFO = {
350357
name: DataCategoryExact.TRANSACTION_PROCESSED,
351358
apiName: 'transactions',
352359
plural: DataCategory.TRANSACTIONS_PROCESSED,
360+
singular: 'transactionProcessed',
353361
displayName: 'transaction',
354362
titleName: t('Transactions'),
355363
productName: t('Performance Monitoring'),
@@ -364,6 +372,7 @@ export const DATA_CATEGORY_INFO = {
364372
name: DataCategoryExact.TRANSACTION_INDEXED,
365373
apiName: 'transactionIndexed',
366374
plural: DataCategory.TRANSACTIONS_INDEXED,
375+
singular: 'transactionIndexed',
367376
displayName: 'indexed transaction',
368377
titleName: t('Indexed Transactions'),
369378
productName: t('Performance Monitoring'),
@@ -375,6 +384,7 @@ export const DATA_CATEGORY_INFO = {
375384
name: DataCategoryExact.MONITOR,
376385
apiName: 'monitor',
377386
plural: DataCategory.MONITOR,
387+
singular: 'monitor',
378388
displayName: 'monitor check-in',
379389
titleName: t('Monitor Check-Ins'),
380390
productName: t('Cron Monitoring'),
@@ -389,6 +399,7 @@ export const DATA_CATEGORY_INFO = {
389399
name: DataCategoryExact.SPAN,
390400
apiName: 'span',
391401
plural: DataCategory.SPANS,
402+
singular: 'span',
392403
displayName: 'span',
393404
titleName: t('Spans'), // TODO(DS Spans): Update name
394405
productName: t('Tracing'),
@@ -404,6 +415,7 @@ export const DATA_CATEGORY_INFO = {
404415
name: DataCategoryExact.MONITOR_SEAT,
405416
apiName: 'monitorSeat',
406417
plural: DataCategory.MONITOR_SEATS,
418+
singular: 'monitorSeat',
407419
displayName: 'cron monitor',
408420
titleName: t('Cron Monitors'),
409421
productName: t('Cron Monitoring'),
@@ -419,6 +431,7 @@ export const DATA_CATEGORY_INFO = {
419431
name: DataCategoryExact.SPAN_INDEXED,
420432
apiName: 'span_indexed',
421433
plural: DataCategory.SPANS_INDEXED,
434+
singular: 'spanIndexed',
422435
displayName: 'stored span',
423436
titleName: t('Stored Spans'),
424437
productName: t('Tracing'),
@@ -431,6 +444,7 @@ export const DATA_CATEGORY_INFO = {
431444
name: DataCategoryExact.PROFILE_DURATION,
432445
apiName: 'profile_duration',
433446
plural: DataCategory.PROFILE_DURATION,
447+
singular: 'profileDuration',
434448
displayName: 'continuous profile hour',
435449
titleName: t('Continuous Profile Hours'),
436450
productName: t('Continuous Profiling'),
@@ -447,6 +461,7 @@ export const DATA_CATEGORY_INFO = {
447461
name: DataCategoryExact.PROFILE_CHUNK,
448462
apiName: 'profile_chunk',
449463
plural: DataCategory.PROFILE_CHUNKS,
464+
singular: 'profileChunk',
450465
displayName: 'profile chunk',
451466
titleName: t('Profile Chunks'),
452467
productName: t('Continuous Profiling'),
@@ -458,6 +473,7 @@ export const DATA_CATEGORY_INFO = {
458473
name: DataCategoryExact.PROFILE_DURATION_UI,
459474
apiName: 'profile_duration_ui',
460475
plural: DataCategory.PROFILE_DURATION_UI,
476+
singular: 'profileDurationUI',
461477
displayName: 'UI profile hour',
462478
titleName: t('UI Profile Hours'),
463479
productName: t('UI Profiling'),
@@ -474,6 +490,7 @@ export const DATA_CATEGORY_INFO = {
474490
name: DataCategoryExact.PROFILE_CHUNK_UI,
475491
apiName: 'profile_chunk_ui',
476492
plural: DataCategory.PROFILE_CHUNKS_UI,
493+
singular: 'profileChunkUI',
477494
displayName: 'UI profile chunk',
478495
titleName: t('UI Profile Chunks'),
479496
productName: t('UI Profiling'),
@@ -486,6 +503,7 @@ export const DATA_CATEGORY_INFO = {
486503
name: DataCategoryExact.UPTIME,
487504
apiName: 'uptime',
488505
plural: DataCategory.UPTIME,
506+
singular: 'uptime',
489507
displayName: 'uptime monitor',
490508
titleName: t('Uptime Monitors'),
491509
productName: t('Uptime Monitoring'),
@@ -501,6 +519,7 @@ export const DATA_CATEGORY_INFO = {
501519
name: DataCategoryExact.LOG_ITEM,
502520
apiName: 'log_item',
503521
plural: DataCategory.LOG_ITEM,
522+
singular: 'logItem',
504523
displayName: 'log',
505524
titleName: t('Log Counts'), // Only currently visible internally, this name should change if we expose this to users.
506525
productName: t('Logging'),
@@ -515,6 +534,7 @@ export const DATA_CATEGORY_INFO = {
515534
name: DataCategoryExact.LOG_BYTE,
516535
apiName: 'log_byte',
517536
plural: DataCategory.LOG_BYTE,
537+
singular: 'logByte',
518538
displayName: 'log byte',
519539
titleName: t('Logs'),
520540
productName: t('Logging'),
@@ -530,6 +550,7 @@ export const DATA_CATEGORY_INFO = {
530550
name: DataCategoryExact.SEER_AUTOFIX,
531551
apiName: 'seer_autofix',
532552
plural: DataCategory.SEER_AUTOFIX,
553+
singular: 'seerAutofix',
533554
displayName: 'issue fix',
534555
titleName: t('Issue Fixes'),
535556
productName: t('Seer'),
@@ -544,6 +565,7 @@ export const DATA_CATEGORY_INFO = {
544565
name: DataCategoryExact.SEER_SCANNER,
545566
apiName: 'seer_scanner',
546567
plural: DataCategory.SEER_SCANNER,
568+
singular: 'seerScanner',
547569
displayName: 'issue scan',
548570
titleName: t('Issue Scans'),
549571
productName: t('Seer'),

static/app/types/core.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,23 @@ export enum DataCategoryExact {
106106
TRANSACTION = 'transaction',
107107
ATTACHMENT = 'attachment',
108108
PROFILE = 'profile',
109-
PROFILE_INDEXED = 'profileIndexed',
109+
PROFILE_INDEXED = 'profile_indexed',
110110
REPLAY = 'replay',
111-
// TODO: Update processed and indexed transactions to camel case"
112111
TRANSACTION_PROCESSED = 'transaction_processed',
113112
TRANSACTION_INDEXED = 'transaction_indexed',
114113
MONITOR = 'monitor',
115-
MONITOR_SEAT = 'monitorSeat',
116-
PROFILE_DURATION = 'profileDuration',
117-
PROFILE_DURATION_UI = 'profileDurationUI',
118-
PROFILE_CHUNK = 'profileChunk',
119-
PROFILE_CHUNK_UI = 'profileChunkUI',
114+
MONITOR_SEAT = 'monitor_seat',
115+
PROFILE_DURATION = 'profile_duration',
116+
PROFILE_DURATION_UI = 'profile_duration_ui',
117+
PROFILE_CHUNK = 'profile_chunk',
118+
PROFILE_CHUNK_UI = 'profile_chunk_ui',
120119
SPAN = 'span',
121-
SPAN_INDEXED = 'spanIndexed',
120+
SPAN_INDEXED = 'span_indexed',
122121
UPTIME = 'uptime',
123-
LOG_ITEM = 'logItem',
124-
LOG_BYTE = 'logByte',
125-
SEER_AUTOFIX = 'seerAutofix',
126-
SEER_SCANNER = 'seerScanner',
122+
LOG_ITEM = 'log_item',
123+
LOG_BYTE = 'log_byte',
124+
SEER_AUTOFIX = 'seer_autofix',
125+
SEER_SCANNER = 'seer_scanner',
127126
USER_REPORT_V2 = 'feedback',
128127
}
129128

@@ -134,6 +133,7 @@ export interface DataCategoryInfo {
134133
name: DataCategoryExact;
135134
plural: DataCategory;
136135
productName: string;
136+
singular: string; // singular form of `plural`
137137
statsInfo: {
138138
showExternalStats: boolean;
139139
showInternalStats: boolean;

static/app/views/organizationStats/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {
342342

343343
renderEstimationDisclaimer() {
344344
if (
345-
this.dataCategory === DATA_CATEGORY_INFO.profileDuration.plural ||
346-
this.dataCategory === DATA_CATEGORY_INFO.profileDurationUI.plural
345+
this.dataCategory === DATA_CATEGORY_INFO.profile_duration.plural ||
346+
this.dataCategory === DATA_CATEGORY_INFO.profile_duration_ui.plural
347347
) {
348348
return (
349349
<EstimationText data-test-id="estimation-text">

static/app/views/organizationStats/utils.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ describe('formatUsageWithUnits', function () {
153153
it('should format continuous profiling correctly', function () {
154154
const hourInMs = 1000 * 60 * 60;
155155
[
156-
DATA_CATEGORY_INFO.profileDuration.plural,
157-
DATA_CATEGORY_INFO.profileDurationUI.plural,
156+
DATA_CATEGORY_INFO.profile_duration.plural,
157+
DATA_CATEGORY_INFO.profile_duration_ui.plural,
158158
].forEach(dataCategory => {
159159
expect(formatUsageWithUnits(0, dataCategory)).toBe('0');
160160
expect(formatUsageWithUnits(7.6 * hourInMs, dataCategory)).toBe('7.6');

static/app/views/organizationStats/utils.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function formatUsageWithUnits(
3434
): string {
3535
if (
3636
dataCategory === DATA_CATEGORY_INFO.attachment.plural ||
37-
dataCategory === DATA_CATEGORY_INFO.logByte.plural
37+
dataCategory === DATA_CATEGORY_INFO.log_byte.plural
3838
) {
3939
if (options.useUnitScaling) {
4040
return formatBytesBase10(usageQuantity);
@@ -47,8 +47,8 @@ export function formatUsageWithUnits(
4747
}
4848

4949
if (
50-
(dataCategory === DATA_CATEGORY_INFO.profileDuration.plural ||
51-
dataCategory === DATA_CATEGORY_INFO.profileDurationUI.plural) &&
50+
(dataCategory === DATA_CATEGORY_INFO.profile_duration.plural ||
51+
dataCategory === DATA_CATEGORY_INFO.profile_duration_ui.plural) &&
5252
Number.isFinite(usageQuantity)
5353
) {
5454
// Profile duration is in milliseconds, convert to hours
@@ -70,10 +70,10 @@ export function getFormatUsageOptions(dataCategory: DataCategory): FormatOptions
7070
return {
7171
isAbbreviated:
7272
dataCategory !== DATA_CATEGORY_INFO.attachment.plural &&
73-
dataCategory !== DATA_CATEGORY_INFO.logByte.plural,
73+
dataCategory !== DATA_CATEGORY_INFO.log_byte.plural,
7474
useUnitScaling:
7575
dataCategory === DATA_CATEGORY_INFO.attachment.plural ||
76-
dataCategory === DATA_CATEGORY_INFO.logByte.plural,
76+
dataCategory === DATA_CATEGORY_INFO.log_byte.plural,
7777
};
7878
}
7979

static/gsApp/components/addEventsCTA.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import withApi from 'sentry/utils/withApi';
1010

1111
import {sendAddEventsRequest, sendUpgradeRequest} from 'getsentry/actionCreators/upsell';
1212
import StartTrialButton from 'getsentry/components/startTrialButton';
13-
import type {Subscription} from 'getsentry/types';
13+
import {BILLED_DATA_CATEGORY_INFO} from 'getsentry/constants';
14+
import type {BilledDataCategoryInfo, Subscription} from 'getsentry/types';
1415
import {
1516
displayBudgetName,
1617
getBestActionToIncreaseEventLimits,
@@ -26,10 +27,23 @@ import {openOnDemandBudgetEditModal} from 'getsentry/views/onDemandBudgets/editO
2627
*/
2728
export type EventType = {
2829
[K in keyof typeof DATA_CATEGORY_INFO]: (typeof DATA_CATEGORY_INFO)[K]['isBilledCategory'] extends true
29-
? (typeof DATA_CATEGORY_INFO)[K]['name']
30+
? (typeof DATA_CATEGORY_INFO)[K]['singular']
3031
: never;
3132
}[keyof typeof DATA_CATEGORY_INFO];
3233

34+
// TODO(data categories): move this and EventType to dataCategory.tsx
35+
export function getCategoryInfoFromEventType(
36+
eventType: EventType
37+
): BilledDataCategoryInfo | null {
38+
const info = Object.values(BILLED_DATA_CATEGORY_INFO).find(
39+
c => c.singular === eventType
40+
);
41+
if (!info) {
42+
return null;
43+
}
44+
return info;
45+
}
46+
3347
type Props = {
3448
api: Client;
3549
organization: Organization;

static/gsApp/components/ai/AiSetupDataConsent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ import {useAutofixSetup} from 'sentry/components/events/autofix/useAutofixSetup'
1212
import {useOrganizationSeerSetup} from 'sentry/components/events/autofix/useOrganizationSeerSetup';
1313
import ExternalLink from 'sentry/components/links/externalLink';
1414
import LoadingIndicator from 'sentry/components/loadingIndicator';
15+
import {DATA_CATEGORY_INFO} from 'sentry/constants';
1516
import {IconRefresh, IconSeer} from 'sentry/icons';
1617
import {t, tct} from 'sentry/locale';
1718
import {space} from 'sentry/styles/space';
18-
import {DataCategory, DataCategoryExact} from 'sentry/types/core';
19+
import {DataCategory} from 'sentry/types/core';
1920
import {useMutation, useQueryClient} from 'sentry/utils/queryClient';
2021
import useApi from 'sentry/utils/useApi';
2122
import {useNavigate} from 'sentry/utils/useNavigate';
2223
import useOrganization from 'sentry/utils/useOrganization';
2324

2425
import {sendAddEventsRequest} from 'getsentry/actionCreators/upsell';
26+
import type {EventType} from 'getsentry/components/addEventsCTA';
2527
import StartTrialButton from 'getsentry/components/startTrialButton';
2628
import useSubscription from 'getsentry/hooks/useSubscription';
2729
import {BillingType, OnDemandBudgetMode} from 'getsentry/types';
@@ -218,7 +220,9 @@ function AiSetupDataConsent({groupId}: AiSetupDataConsentProps) {
218220
await sendAddEventsRequest({
219221
api,
220222
organization,
221-
eventTypes: [DataCategoryExact.SEER_AUTOFIX],
223+
eventTypes: [
224+
DATA_CATEGORY_INFO.seer_autofix.singular as EventType,
225+
],
222226
});
223227
autofixAcknowledgeMutation.mutate();
224228
}}

0 commit comments

Comments
 (0)