Browse Source

ref(metrics): Rename metrics types (#32316)

Matej Minar 3 years ago
parent
commit
d2fb77dd92

+ 7 - 7
static/app/actionCreators/metrics.tsx

@@ -9,9 +9,9 @@ import MetricsMetaStore from 'sentry/stores/metricsMetaStore';
 import MetricsTagStore from 'sentry/stores/metricsTagStore';
 import {
   DateString,
-  MetricMeta,
   MetricsApiResponse,
-  MetricTag,
+  MetricsMeta,
+  MetricsTag,
   Organization,
 } from 'sentry/types';
 import {defined} from 'sentry/utils';
@@ -83,7 +83,7 @@ export const doMetricsRequest = (
   return api.requestPromise(pathname, {includeAllArgs, query: urlQuery});
 };
 
-function tagFetchSuccess(tags: MetricTag[]) {
+function tagFetchSuccess(tags: MetricsTag[]) {
   MetricsTagActions.loadMetricsTagsSuccess(tags);
 }
 
@@ -92,7 +92,7 @@ export function fetchMetricsTags(
   orgSlug: Organization['slug'],
   projects?: number[],
   fields?: string[]
-): Promise<MetricTag[]> {
+): Promise<MetricsTag[]> {
   MetricsTagStore.reset();
 
   const promise = api.requestPromise(`/organizations/${orgSlug}/metrics/tags/`, {
@@ -111,7 +111,7 @@ export function fetchMetricsTags(
   return promise;
 }
 
-function metaFetchSuccess(metricsMeta: MetricMeta[]) {
+function metaFetchSuccess(metricsMeta: MetricsMeta[]) {
   MetricsMetaActions.loadMetricsMetaSuccess(metricsMeta);
 }
 
@@ -119,10 +119,10 @@ export function fetchMetricsFields(
   api: Client,
   orgSlug: Organization['slug'],
   projects?: number[]
-): Promise<MetricMeta[]> {
+): Promise<MetricsMeta[]> {
   MetricsMetaStore.reset();
 
-  const promise: Promise<MetricMeta[]> = api.requestPromise(
+  const promise: Promise<MetricsMeta[]> = api.requestPromise(
     `/organizations/${orgSlug}/metrics/meta/`,
     {
       query: {

+ 2 - 2
static/app/components/modals/addDashboardWidgetModal.tsx

@@ -26,7 +26,7 @@ import space from 'sentry/styles/space';
 import {
   DateString,
   MetricsMetaCollection,
-  MetricTagCollection,
+  MetricsTagCollection,
   Organization,
   PageFilters,
   SelectValue,
@@ -89,7 +89,7 @@ type Props = ModalRenderProps &
   DashboardWidgetModalOptions & {
     api: Client;
     metricsMeta: MetricsMetaCollection;
-    metricsTags: MetricTagCollection;
+    metricsTags: MetricsTagCollection;
     organization: Organization;
     selection: PageFilters;
     tags: TagCollection;

+ 2 - 2
static/app/stores/metricsMetaStore.tsx

@@ -1,11 +1,11 @@
 import Reflux from 'reflux';
 
 import MetricsMetaActions from 'sentry/actions/metricsMetaActions';
-import {MetricMeta, MetricsMetaCollection} from 'sentry/types';
+import {MetricsMeta, MetricsMetaCollection} from 'sentry/types';
 
 type MetricsMetaStoreInterface = {
   getAllFields(): MetricsMetaCollection;
-  onLoadSuccess(data: MetricMeta[]): void;
+  onLoadSuccess(data: MetricsMeta[]): void;
   reset(): void;
   state: MetricsMetaCollection;
 };

+ 5 - 5
static/app/stores/metricsTagStore.tsx

@@ -1,13 +1,13 @@
 import Reflux from 'reflux';
 
 import MetricsTagActions from 'sentry/actions/metricTagActions';
-import {MetricTag, MetricTagCollection} from 'sentry/types';
+import {MetricsTag, MetricsTagCollection} from 'sentry/types';
 
 type MetricsTagStoreInterface = {
-  getAllTags(): MetricTagCollection;
-  onLoadTagsSuccess(data: MetricTag[]): void;
+  getAllTags(): MetricsTagCollection;
+  onLoadTagsSuccess(data: MetricsTag[]): void;
   reset(): void;
-  state: MetricTagCollection;
+  state: MetricsTagCollection;
 };
 
 const storeConfig: Reflux.StoreDefinition & MetricsTagStoreInterface = {
@@ -28,7 +28,7 @@ const storeConfig: Reflux.StoreDefinition & MetricsTagStoreInterface = {
   },
 
   onLoadTagsSuccess(data) {
-    const newTags = data.reduce<MetricTagCollection>((acc, tag) => {
+    const newTags = data.reduce<MetricsTagCollection>((acc, tag) => {
       acc[tag.key] = {
         ...tag,
       };

+ 5 - 12
static/app/types/metrics.tsx

@@ -23,28 +23,21 @@ export type MetricsApiResponse = {
   start: string;
 };
 
-export type MetricTagCollection = Record<string, MetricTag>;
+export type MetricsTagCollection = Record<string, MetricsTag>;
 
-export type MetricTag = {
+export type MetricsTag = {
   key: string;
 };
 
-export type MetricTagValue = {
+export type MetricsTagValue = {
   key: string;
   value: string;
 };
 
-export type MetricMeta = {
+export type MetricsMeta = {
   name: string;
   operations: MetricsOperation[];
   type: MetricsType;
 };
 
-export type MetricsMetaCollection = Record<string, MetricMeta>;
-
-export type MetricQuery = {
-  aggregation?: string;
-  groupBy?: string[];
-  legend?: string;
-  metricMeta?: MetricMeta;
-};
+export type MetricsMetaCollection = Record<string, MetricsMeta>;

+ 4 - 4
static/app/utils/withMetricsTags.tsx

@@ -1,15 +1,15 @@
 import * as React from 'react';
 
 import MetricsTagStore from 'sentry/stores/metricsTagStore';
-import {MetricTagCollection} from 'sentry/types';
+import {MetricsTagCollection} from 'sentry/types';
 import getDisplayName from 'sentry/utils/getDisplayName';
 
 export type InjectedMetricsTagsProps = {
-  metricsTags: MetricTagCollection;
+  metricsTags: MetricsTagCollection;
 };
 
 type State = {
-  metricsTags: MetricTagCollection;
+  metricsTags: MetricsTagCollection;
 };
 
 function withMetricsTags<P extends InjectedMetricsTagsProps>(
@@ -29,7 +29,7 @@ function withMetricsTags<P extends InjectedMetricsTagsProps>(
       this.unsubscribe();
     }
     unsubscribe = MetricsTagStore.listen(
-      (metricsTags: MetricTagCollection) => this.setState({metricsTags}),
+      (metricsTags: MetricsTagCollection) => this.setState({metricsTags}),
       undefined
     );
 

+ 2 - 2
static/app/views/dashboardsV2/widgetBuilder/metricWidget/fields.tsx

@@ -1,10 +1,10 @@
-import {MetricMeta, MetricsOperation, SelectValue} from 'sentry/types';
+import {MetricsMeta, MetricsOperation, SelectValue} from 'sentry/types';
 import {defined} from 'sentry/utils';
 import {METRICS_OPERATIONS} from 'sentry/utils/metrics/fields';
 import {FieldValue, FieldValueKind} from 'sentry/views/eventsV2/table/types';
 
 export function generateMetricsWidgetFieldOptions(
-  fields: MetricMeta[] = [],
+  fields: MetricsMeta[] = [],
   tagKeys?: string[]
 ) {
   const fieldOptions: Record<string, SelectValue<FieldValue>> = {};

+ 3 - 3
static/app/views/performance/metricsSearchBar.tsx

@@ -6,7 +6,7 @@ import {addErrorMessage} from 'sentry/actionCreators/indicator';
 import SmartSearchBar from 'sentry/components/smartSearchBar';
 import {NEGATION_OPERATOR, SEARCH_WILDCARD} from 'sentry/constants';
 import {t} from 'sentry/locale';
-import {MetricTag, MetricTagValue, Organization, Tag} from 'sentry/types';
+import {MetricsTag, MetricsTagValue, Organization, Tag} from 'sentry/types';
 import useApi from 'sentry/utils/useApi';
 
 const SEARCH_SPECIAL_CHARS_REGEXP = new RegExp(
@@ -34,7 +34,7 @@ function MetricsSearchBar({
   ...props
 }: Props) {
   const api = useApi();
-  const [tags, setTags] = useState<MetricTag[]>([]);
+  const [tags, setTags] = useState<MetricsTag[]>([]);
 
   useEffect(() => {
     fetchTags();
@@ -72,7 +72,7 @@ function MetricsSearchBar({
 
   function getTagValues(tag: Tag, _query: string): Promise<string[]> {
     return fetchTagValues(tag.key).then(
-      tagValues => (tagValues as MetricTagValue[]).map(({value}) => value),
+      tagValues => (tagValues as MetricsTagValue[]).map(({value}) => value),
       () => {
         throw new Error('Unable to fetch tag values');
       }