Skip to content

Commit

Permalink
fix(analytics): screen tracking will no longer fail on broken routes (#…
Browse files Browse the repository at this point in the history
…2678)

fixes #2677
  • Loading branch information
jamesdaniels authored Nov 20, 2020
1 parent d5dbe99 commit ae26b35
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/analytics/screen-tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export class ScreenTrackingService implements OnDestroy {
const urlTree = router.parseUrl(router.url.replace(/(?:\().+(?:\))/g, a => a.replace('://', ':///')));
const pagePath = urlTree.root.children[activationEnd.snapshot.outlet]?.toString() || '';
const actualSnapshot = router.routerState.root.children.map(it => it).find(it => it.outlet === activationEnd.snapshot.outlet);

if (!actualSnapshot) {
return of(null);
}

let actualDeep = actualSnapshot;
while (actualDeep.firstChild) {
actualDeep = actualDeep.firstChild;
Expand Down

0 comments on commit ae26b35

Please sign in to comment.