fields.tsx 849 B

1234567891011121314151617181920212223242526
  1. import type {Location} from 'history';
  2. import {decodeList} from 'sentry/utils/queryString';
  3. import {LOGS_FIELDS_KEY} from 'sentry/views/explore/contexts/logs/logsPageParams';
  4. import {type OurLogFieldKey, OurLogKnownFieldKey} from 'sentry/views/explore/logs/types';
  5. /**
  6. * These are the default fields that are shown in the logs table. The query will always add other hidden fields required to render details view etc.
  7. */
  8. export function defaultLogFields(): OurLogKnownFieldKey[] {
  9. return [
  10. OurLogKnownFieldKey.SEVERITY_TEXT,
  11. OurLogKnownFieldKey.BODY,
  12. OurLogKnownFieldKey.TIMESTAMP,
  13. ];
  14. }
  15. export function getLogFieldsFromLocation(location: Location): OurLogFieldKey[] {
  16. const fields = decodeList(location.query[LOGS_FIELDS_KEY]) as OurLogFieldKey[];
  17. if (fields.length) {
  18. return fields;
  19. }
  20. return defaultLogFields();
  21. }