Skip to content

fix: DataCategoryExact should match Relay #94663

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions static/app/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.ERROR,
apiName: 'error',
plural: DataCategory.ERRORS,
singular: 'error',
displayName: 'error',
titleName: t('Errors'),
productName: t('Error Monitoring'),
Expand All @@ -284,6 +285,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.TRANSACTION,
apiName: 'transaction',
plural: DataCategory.TRANSACTIONS,
singular: 'transaction',
displayName: 'transaction',
titleName: t('Transactions'),
productName: t('Performance Monitoring'),
Expand All @@ -299,6 +301,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.ATTACHMENT,
apiName: 'attachment',
plural: DataCategory.ATTACHMENTS,
singular: 'attachment',
displayName: 'attachment',
titleName: t('Attachments'),
productName: t('Attachments'),
Expand All @@ -315,6 +318,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.PROFILE,
apiName: 'profile',
plural: DataCategory.PROFILES,
singular: 'profile',
displayName: 'profile',
titleName: t('Profiles'),
productName: t('Continuous Profiling'),
Expand All @@ -330,6 +334,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.PROFILE_INDEXED,
apiName: 'profileIndexed',
plural: DataCategory.PROFILES_INDEXED,
singular: 'profileIndexed',
displayName: 'indexed profile',
titleName: t('Indexed Profiles'),
productName: t('Continuous Profiling'),
Expand All @@ -341,6 +346,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.REPLAY,
apiName: 'replay',
plural: DataCategory.REPLAYS,
singular: 'replay',
displayName: 'replay',
titleName: t('Session Replays'),
productName: t('Session Replay'),
Expand All @@ -356,6 +362,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.USER_REPORT_V2,
apiName: 'feedback',
plural: DataCategory.USER_REPORT_V2,
singular: 'feedback',
displayName: 'user feedback',
titleName: t('User Feedback'),
productName: t('User Feedback'),
Expand All @@ -371,6 +378,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.TRANSACTION_PROCESSED,
apiName: 'transactions',
plural: DataCategory.TRANSACTIONS_PROCESSED,
singular: 'transactionProcessed',
displayName: 'transaction',
titleName: t('Transactions'),
productName: t('Performance Monitoring'),
Expand All @@ -385,6 +393,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.TRANSACTION_INDEXED,
apiName: 'transactionIndexed',
plural: DataCategory.TRANSACTIONS_INDEXED,
singular: 'transactionIndexed',
displayName: 'indexed transaction',
titleName: t('Indexed Transactions'),
productName: t('Performance Monitoring'),
Expand All @@ -396,6 +405,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.MONITOR,
apiName: 'monitor',
plural: DataCategory.MONITOR,
singular: 'monitor',
displayName: 'monitor check-in',
titleName: t('Monitor Check-Ins'),
productName: t('Cron Monitoring'),
Expand All @@ -410,6 +420,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.SPAN,
apiName: 'span',
plural: DataCategory.SPANS,
singular: 'span',
displayName: 'span',
titleName: t('Spans'), // TODO(DS Spans): Update name
productName: t('Tracing'),
Expand All @@ -425,6 +436,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.MONITOR_SEAT,
apiName: 'monitorSeat',
plural: DataCategory.MONITOR_SEATS,
singular: 'monitorSeat',
displayName: 'cron monitor',
titleName: t('Cron Monitors'),
productName: t('Cron Monitoring'),
Expand All @@ -440,6 +452,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.SPAN_INDEXED,
apiName: 'span_indexed',
plural: DataCategory.SPANS_INDEXED,
singular: 'spanIndexed',
displayName: 'stored span',
titleName: t('Stored Spans'),
productName: t('Tracing'),
Expand All @@ -452,6 +465,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.PROFILE_DURATION,
apiName: 'profile_duration',
plural: DataCategory.PROFILE_DURATION,
singular: 'profileDuration',
displayName: 'continuous profile hour',
titleName: t('Continuous Profile Hours'),
productName: t('Continuous Profiling'),
Expand All @@ -468,6 +482,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.PROFILE_CHUNK,
apiName: 'profile_chunk',
plural: DataCategory.PROFILE_CHUNKS,
singular: 'profileChunk',
displayName: 'profile chunk',
titleName: t('Profile Chunks'),
productName: t('Continuous Profiling'),
Expand All @@ -479,6 +494,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.PROFILE_DURATION_UI,
apiName: 'profile_duration_ui',
plural: DataCategory.PROFILE_DURATION_UI,
singular: 'profileDurationUI',
displayName: 'UI profile hour',
titleName: t('UI Profile Hours'),
productName: t('UI Profiling'),
Expand All @@ -495,6 +511,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.PROFILE_CHUNK_UI,
apiName: 'profile_chunk_ui',
plural: DataCategory.PROFILE_CHUNKS_UI,
singular: 'profileChunkUI',
displayName: 'UI profile chunk',
titleName: t('UI Profile Chunks'),
productName: t('UI Profiling'),
Expand All @@ -507,6 +524,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.UPTIME,
apiName: 'uptime',
plural: DataCategory.UPTIME,
singular: 'uptime',
displayName: 'uptime monitor',
titleName: t('Uptime Monitors'),
productName: t('Uptime Monitoring'),
Expand All @@ -522,6 +540,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.LOG_ITEM,
apiName: 'log_item',
plural: DataCategory.LOG_ITEM,
singular: 'logItem',
displayName: 'log',
titleName: t('Log Counts'), // Only currently visible internally, this name should change if we expose this to users.
productName: t('Logging'),
Expand All @@ -536,6 +555,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.LOG_BYTE,
apiName: 'log_byte',
plural: DataCategory.LOG_BYTE,
singular: 'logByte',
displayName: 'log byte',
titleName: t('Logs'),
productName: t('Logging'),
Expand All @@ -551,6 +571,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.SEER_AUTOFIX,
apiName: 'seer_autofix',
plural: DataCategory.SEER_AUTOFIX,
singular: 'seerAutofix',
displayName: 'issue fix',
titleName: t('Issue Fixes'),
productName: t('Seer'),
Expand All @@ -565,6 +586,7 @@ export const DATA_CATEGORY_INFO = {
name: DataCategoryExact.SEER_SCANNER,
apiName: 'seer_scanner',
plural: DataCategory.SEER_SCANNER,
singular: 'seerScanner',
displayName: 'issue scan',
titleName: t('Issue Scans'),
productName: t('Seer'),
Expand Down
24 changes: 12 additions & 12 deletions static/app/types/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,23 @@ export enum DataCategoryExact {
TRANSACTION = 'transaction',
ATTACHMENT = 'attachment',
PROFILE = 'profile',
PROFILE_INDEXED = 'profileIndexed',
PROFILE_INDEXED = 'profile_indexed',
REPLAY = 'replay',
// TODO: Update processed and indexed transactions to camel case"
TRANSACTION_PROCESSED = 'transaction_processed',
TRANSACTION_INDEXED = 'transaction_indexed',
MONITOR = 'monitor',
MONITOR_SEAT = 'monitorSeat',
PROFILE_DURATION = 'profileDuration',
PROFILE_DURATION_UI = 'profileDurationUI',
PROFILE_CHUNK = 'profileChunk',
PROFILE_CHUNK_UI = 'profileChunkUI',
MONITOR_SEAT = 'monitor_seat',
PROFILE_DURATION = 'profile_duration',
PROFILE_DURATION_UI = 'profile_duration_ui',
PROFILE_CHUNK = 'profile_chunk',
PROFILE_CHUNK_UI = 'profile_chunk_ui',
SPAN = 'span',
SPAN_INDEXED = 'spanIndexed',
SPAN_INDEXED = 'span_indexed',
UPTIME = 'uptime',
LOG_ITEM = 'logItem',
LOG_BYTE = 'logByte',
SEER_AUTOFIX = 'seerAutofix',
SEER_SCANNER = 'seerScanner',
LOG_ITEM = 'log_item',
LOG_BYTE = 'log_byte',
SEER_AUTOFIX = 'seer_autofix',
SEER_SCANNER = 'seer_scanner',
USER_REPORT_V2 = 'feedback',
}

Expand All @@ -134,6 +133,7 @@ export interface DataCategoryInfo {
name: DataCategoryExact;
plural: DataCategory;
productName: string;
singular: string; // singular form of `plural`
statsInfo: {
showExternalStats: boolean;
showInternalStats: boolean;
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/organizationStats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ export class OrganizationStats extends Component<OrganizationStatsProps> {

renderEstimationDisclaimer() {
if (
this.dataCategory === DATA_CATEGORY_INFO.profileDuration.plural ||
this.dataCategory === DATA_CATEGORY_INFO.profileDurationUI.plural
this.dataCategory === DATA_CATEGORY_INFO.profile_duration.plural ||
this.dataCategory === DATA_CATEGORY_INFO.profile_duration_ui.plural
) {
return (
<EstimationText data-test-id="estimation-text">
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/organizationStats/utils.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ describe('formatUsageWithUnits', function () {
it('should format continuous profiling correctly', function () {
const hourInMs = 1000 * 60 * 60;
[
DATA_CATEGORY_INFO.profileDuration.plural,
DATA_CATEGORY_INFO.profileDurationUI.plural,
DATA_CATEGORY_INFO.profile_duration.plural,
DATA_CATEGORY_INFO.profile_duration_ui.plural,
].forEach(dataCategory => {
expect(formatUsageWithUnits(0, dataCategory)).toBe('0');
expect(formatUsageWithUnits(7.6 * hourInMs, dataCategory)).toBe('7.6');
Expand Down
10 changes: 5 additions & 5 deletions static/app/views/organizationStats/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function formatUsageWithUnits(
): string {
if (
dataCategory === DATA_CATEGORY_INFO.attachment.plural ||
dataCategory === DATA_CATEGORY_INFO.logByte.plural
dataCategory === DATA_CATEGORY_INFO.log_byte.plural
) {
if (options.useUnitScaling) {
return formatBytesBase10(usageQuantity);
Expand All @@ -47,8 +47,8 @@ export function formatUsageWithUnits(
}

if (
(dataCategory === DATA_CATEGORY_INFO.profileDuration.plural ||
dataCategory === DATA_CATEGORY_INFO.profileDurationUI.plural) &&
(dataCategory === DATA_CATEGORY_INFO.profile_duration.plural ||
dataCategory === DATA_CATEGORY_INFO.profile_duration_ui.plural) &&
Number.isFinite(usageQuantity)
) {
// Profile duration is in milliseconds, convert to hours
Expand All @@ -70,10 +70,10 @@ export function getFormatUsageOptions(dataCategory: DataCategory): FormatOptions
return {
isAbbreviated:
dataCategory !== DATA_CATEGORY_INFO.attachment.plural &&
dataCategory !== DATA_CATEGORY_INFO.logByte.plural,
dataCategory !== DATA_CATEGORY_INFO.log_byte.plural,
useUnitScaling:
dataCategory === DATA_CATEGORY_INFO.attachment.plural ||
dataCategory === DATA_CATEGORY_INFO.logByte.plural,
dataCategory === DATA_CATEGORY_INFO.log_byte.plural,
};
}

Expand Down
18 changes: 16 additions & 2 deletions static/gsApp/components/addEventsCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import withApi from 'sentry/utils/withApi';

import {sendAddEventsRequest, sendUpgradeRequest} from 'getsentry/actionCreators/upsell';
import StartTrialButton from 'getsentry/components/startTrialButton';
import type {Subscription} from 'getsentry/types';
import {BILLED_DATA_CATEGORY_INFO} from 'getsentry/constants';
import type {BilledDataCategoryInfo, Subscription} from 'getsentry/types';
import {
displayBudgetName,
getBestActionToIncreaseEventLimits,
Expand All @@ -26,10 +27,23 @@ import {openOnDemandBudgetEditModal} from 'getsentry/views/onDemandBudgets/editO
*/
export type EventType = {
[K in keyof typeof DATA_CATEGORY_INFO]: (typeof DATA_CATEGORY_INFO)[K]['isBilledCategory'] extends true
? (typeof DATA_CATEGORY_INFO)[K]['name']
? (typeof DATA_CATEGORY_INFO)[K]['singular']
: never;
}[keyof typeof DATA_CATEGORY_INFO];

// TODO(data categories): move this and EventType to dataCategory.tsx
export function getCategoryInfoFromEventType(
eventType: EventType
): BilledDataCategoryInfo | null {
const info = Object.values(BILLED_DATA_CATEGORY_INFO).find(
c => c.singular === eventType
);
if (!info) {
return null;
}
return info;
}

type Props = {
api: Client;
organization: Organization;
Expand Down
8 changes: 6 additions & 2 deletions static/gsApp/components/ai/AiSetupDataConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import {useAutofixSetup} from 'sentry/components/events/autofix/useAutofixSetup'
import {useOrganizationSeerSetup} from 'sentry/components/events/autofix/useOrganizationSeerSetup';
import ExternalLink from 'sentry/components/links/externalLink';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import {DATA_CATEGORY_INFO} from 'sentry/constants';
import {IconRefresh, IconSeer} from 'sentry/icons';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {DataCategory, DataCategoryExact} from 'sentry/types/core';
import {DataCategory} from 'sentry/types/core';
import {useMutation, useQueryClient} from 'sentry/utils/queryClient';
import useApi from 'sentry/utils/useApi';
import {useNavigate} from 'sentry/utils/useNavigate';
import useOrganization from 'sentry/utils/useOrganization';

import {sendAddEventsRequest} from 'getsentry/actionCreators/upsell';
import type {EventType} from 'getsentry/components/addEventsCTA';
import StartTrialButton from 'getsentry/components/startTrialButton';
import useSubscription from 'getsentry/hooks/useSubscription';
import {BillingType, OnDemandBudgetMode} from 'getsentry/types';
Expand Down Expand Up @@ -218,7 +220,9 @@ function AiSetupDataConsent({groupId}: AiSetupDataConsentProps) {
await sendAddEventsRequest({
api,
organization,
eventTypes: [DataCategoryExact.SEER_AUTOFIX],
eventTypes: [
DATA_CATEGORY_INFO.seer_autofix.singular as EventType,
],
});
autofixAcknowledgeMutation.mutate();
}}
Expand Down
Loading
Loading