mergeBreadcrumbEntries.tsx 637 B

1234567891011121314151617181920212223
  1. import {Entry, EntryType, Event} from 'sentry/types/event';
  2. /**
  3. * Merge all breadcrumbs from each Event in the `events` array
  4. */
  5. export default function mergeBreadcrumbEntries(events: Event[]): Entry {
  6. const allValues = events.flatMap(event =>
  7. event.entries.flatMap((entry: Entry) =>
  8. entry.type === EntryType.BREADCRUMBS ? entry.data.values : []
  9. )
  10. );
  11. const stringified = allValues.map(value => JSON.stringify(value));
  12. const deduped = Array.from(new Set(stringified));
  13. const values = deduped.map(value => JSON.parse(value));
  14. return {
  15. type: EntryType.BREADCRUMBS,
  16. data: {
  17. values,
  18. },
  19. };
  20. }