Просмотр исходного кода

feat(discover): add device.class as field to front end and feature flag device.class in generateFieldOptions (#45796)

Allows `device.class` to be selectable in column selectors in places
like discover and dashboards. Also adds a description for the smart
search bar and adds a feature flag check.
edwardgou-sentry 2 лет назад
Родитель
Сommit
51015ceb62
2 измененных файлов с 12 добавлено и 0 удалено
  1. 7 0
      static/app/utils/fields/index.ts
  2. 5 0
      static/app/views/discover/utils.tsx

+ 7 - 0
static/app/utils/fields/index.ts

@@ -24,6 +24,7 @@ export enum FieldKey {
   DEVICE_BATTERY_LEVEL = 'device.battery_level',
   DEVICE_BRAND = 'device.brand',
   DEVICE_CHARGING = 'device.charging',
+  DEVICE_CLASS = 'device.class',
   DEVICE_FAMILY = 'device.family',
   DEVICE_LOCALE = 'device.locale',
   DEVICE_MODEL_ID = 'device.model_id',
@@ -500,6 +501,11 @@ const EVENT_FIELD_DEFINITIONS: Record<AllEventFieldKeys, FieldDefinition> = {
     kind: FieldKind.FIELD,
     valueType: FieldValueType.BOOLEAN,
   },
+  [FieldKey.DEVICE_CLASS]: {
+    desc: t('The estimated performance level of the device, graded low, medium, or high'),
+    kind: FieldKind.FIELD,
+    valueType: FieldValueType.STRING,
+  },
   [FieldKey.DEVICE_FAMILY]: {
     desc: t('Model name across generations'),
     kind: FieldKind.FIELD,
@@ -1063,6 +1069,7 @@ export const DISCOVER_FIELDS = [
   FieldKey.DEVICE_SIMULATOR,
   FieldKey.DEVICE_ONLINE,
   FieldKey.DEVICE_CHARGING,
+  FieldKey.DEVICE_CLASS,
   FieldKey.GEO_COUNTRY_CODE,
   FieldKey.GEO_REGION,
   FieldKey.GEO_CITY,

+ 5 - 0
static/app/views/discover/utils.tsx

@@ -490,6 +490,11 @@ export function generateFieldOptions({
     fieldKeys = fieldKeys.filter(item => !PROFILING_FIELDS.includes(item));
   }
 
+  // Strip device.class if the org doesn't have access.
+  if (!organization.features.includes('device-classification')) {
+    fieldKeys = fieldKeys.filter(item => item !== 'device.class');
+  }
+
   const fieldOptions: Record<string, SelectValue<FieldValue>> = {};
 
   // Index items by prefixed keys as custom tags can overlap both fields and