Skip to content

Commit ae26b35

Browse files
authored
fix(analytics): screen tracking will no longer fail on broken routes (#2678)
fixes #2677
1 parent d5dbe99 commit ae26b35

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/analytics/screen-tracking.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ export class ScreenTrackingService implements OnDestroy {
7878
const urlTree = router.parseUrl(router.url.replace(/(?:\().+(?:\))/g, a => a.replace('://', ':///')));
7979
const pagePath = urlTree.root.children[activationEnd.snapshot.outlet]?.toString() || '';
8080
const actualSnapshot = router.routerState.root.children.map(it => it).find(it => it.outlet === activationEnd.snapshot.outlet);
81+
82+
if (!actualSnapshot) {
83+
return of(null);
84+
}
85+
8186
let actualDeep = actualSnapshot;
8287
while (actualDeep.firstChild) {
8388
actualDeep = actualDeep.firstChild;

0 commit comments

Comments
 (0)