Skip to content

Commit 6d0f2bc

Browse files
committed
predicate
1 parent dc91cad commit 6d0f2bc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/replay/src/coreHandlers/handleScope.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ let _LAST_BREADCRUMB: null | Breadcrumb = null;
1212

1313
type BreadcrumbWithCategory = Required<Pick<Breadcrumb, 'category'>>;
1414

15+
function isBreadcrumbWithCategory(breadcrumb: Breadcrumb): breadcrumb is BreadcrumbWithCategory {
16+
return !!breadcrumb.category;
17+
}
18+
1519
export const handleScopeListener: (replay: ReplayContainer) => (scope: Scope) => void =
1620
(replay: ReplayContainer) =>
1721
(scope: Scope): void => {
@@ -47,18 +51,18 @@ export function handleScope(scope: Scope): Breadcrumb | null {
4751
_LAST_BREADCRUMB = newBreadcrumb;
4852

4953
if (
50-
typeof newBreadcrumb.category !== 'string' ||
54+
!isBreadcrumbWithCategory(newBreadcrumb) ||
5155
['fetch', 'xhr', 'sentry.event', 'sentry.transaction'].includes(newBreadcrumb.category) ||
5256
newBreadcrumb.category.startsWith('ui.')
5357
) {
5458
return null;
5559
}
5660

5761
if (newBreadcrumb.category === 'console') {
58-
return normalizeConsoleBreadcrumb(newBreadcrumb as BreadcrumbWithCategory);
62+
return normalizeConsoleBreadcrumb(newBreadcrumb);
5963
}
6064

61-
return createBreadcrumb(newBreadcrumb as BreadcrumbWithCategory);
65+
return createBreadcrumb(newBreadcrumb);
6266
}
6367

6468
/** exported for tests only */

0 commit comments

Comments
 (0)