We have updated our project into Angular 17.
I got this ERROR TypeError: this.router.events.filter is not a function In console.
Here Is the app.components.ts file code
import { AfterViewInit, Component, OnInit, Inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Router, ActivatedRoute, NavigationEnd, RouterModule } from '@angular/router';
import { environment } from "../environments/environment";
import { Title, Meta } from '@angular/platform-browser';
import { WINDOW } from '@ng-toolkit/universal';
import { Idle, DEFAULT_INTERRUPTSOURCES } from '@ng-idle/core';
import { CookieService } from 'ngx-cookie-service';
import { NgIdleKeepaliveModule } from '@ng-idle/keepalive';
import { HttpClientModule } from '@angular/common/http';
import { LoadingComponent } from './shared/components/loading/loading.component';
import { DataService } from './shared/service/data.service';
import { LoaderService } from './shared/service/loader.service';
import { SeoService } from './shared/service/seo.service';

declare const ga: any;
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  standalone: true,
  imports: [RouterModule, NgIdleKeepaliveModule, LoadingComponent, HttpClientModule],
  providers: [{ provide: WINDOW, useValue: {} }]
})

export class AppComponent implements OnInit, AfterViewInit {
  title = 'motor-happy';
  serverName: String;
  idleState = 'Not started.';
  timedOut = false;
  lastPing?: Date = null;
  title1 = 'angular-idle-timeout';
  expiredDate: Date;
  constructor(@Inject(WINDOW) private window: any,
    @Inject(PLATFORM_ID) private platformId: Object,
    public router: Router,
    public activatedRoute: ActivatedRoute,
    public titleService: Title,
    public meta: Meta,
    public cookieService: CookieService,
    public dataService: DataService,
    public loaderSVC: LoaderService,
    public seoService: SeoService,
    public idle: Idle,
  ) { 

    idle.setIdle(600);
    idle.setTimeout(600);
    idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);

    idle.onTimeout.subscribe(() => {
      this.timedOut = true;
      localStorage.removeItem('authorisationToken');
      this.router.navigate(['/']);
    });
    this.reset();
    this.serverName = environment.name;

    this.activatedRoute.queryParams.subscribe(params => {
      let utm_CampaignSource = params['utm_CampaignSource'];
      let getCookie = this.cookieService.get('utm_fetch');

      if (utm_CampaignSource && (!getCookie)) {
        const dateNow = new Date();
        dateNow.setMinutes(dateNow.getMinutes() + 30);
        this.cookieService.set('utm_fetch', "Yes", dateNow, '', '', true);
      }
    });

  }

  reset() {
    this.idle.watch();
    this.timedOut = false;
  }

  ngAfterViewInit(): void {
    this.router.events.subscribe(event => {
      if (event instanceof NavigationEnd && isPlatformBrowser(this.platformId)) {
        if (this.serverName == "production") {
          ga('set', 'page', event.urlAfterRedirects);
          ga('send', 'pageview');
        }
      }
    });
  }

  ngOnInit() {
    this.seoService.createLinkForCanonicalURL();
    this.router.events.subscribe((evt) => {
      this.loaderSVC.startLoading();      
      if (!(evt instanceof NavigationEnd)) {
        return;
      }
      setTimeout(() => {
        this.loaderSVC.stopLoading();        
      });
      if (isPlatformBrowser(this.platformId)) {
        window.scrollTo(0, 0);

        const userAgent = window.navigator.userAgent;
        sessionStorage.setItem('userAgent', userAgent);
        sessionStorage.setItem('ipAddress', '0.0.0.0');
      }
    });

    this.router.events
      .filter((event) => event instanceof NavigationEnd)
      .map(() => this.activatedRoute)
      .map((route) => {
        while (route.firstChild) route = route.firstChild;
        return route;
      })
      .filter((route) => route.outlet === 'primary')
      .mergeMap((route) => route.data)
      .subscribe((event) => {
        this.updateDescription(event['description'], event['keywords'], event['title']);
      });
  }

  updateDescription(desc: string, keywords: string, title: string) {
    if (title) {
      this.titleService.setTitle(title);
    }
    if (desc) {
      this.meta.updateTag({ name: 'description', content: desc })
    }
    /*if(keywords){
      this.meta.updateTag({ name: 'keywords', content: keywords })
    }*/
  }
}

We have tried to update
this.router.events.filter
with
this.router.events.pipe(filter(event => event instanceof NavigationEnd)
But don't know how to map after that