utils.tsx 617 B

123456789101112131415161718192021
  1. import {BreadcrumbTypeDefault} from 'sentry/types/breadcrumbs';
  2. export const filterBreadcrumbs = (
  3. breadcrumbs: BreadcrumbTypeDefault[],
  4. searchTerm: string,
  5. logLevel: Array<string>
  6. ) => {
  7. if (!searchTerm && logLevel.length === 0) {
  8. return breadcrumbs;
  9. }
  10. return breadcrumbs.filter(breadcrumb => {
  11. const normalizedSearchTerm = searchTerm.toLowerCase();
  12. const doesMatch = JSON.stringify(breadcrumb.data)
  13. .toLowerCase()
  14. .includes(normalizedSearchTerm);
  15. if (logLevel.length > 0) {
  16. return doesMatch && logLevel.includes(breadcrumb.level);
  17. }
  18. return doesMatch;
  19. });
  20. };