From 7968f68976aa8314cdb3f5c2e21a2c5615470f7c Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Sun, 18 Feb 2024 18:49:55 +0100 Subject: [PATCH] 110889: Fixed trackStatistics still sending backend requests to track search event when trackStatistics is false --- src/app/shared/search/search.component.ts | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index 492c0e3d6b1..d2343234cc5 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -485,18 +485,20 @@ export class SearchComponent implements OnDestroy, OnInit { * This method should only be called once and is essentially what SearchTrackingComponent used to do (now removed) * @private */ - private subscribeToRoutingEvents() { - this.subs.push( - this.router.events.pipe( - filter((event) => event instanceof NavigationStart), - map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)), - hasValueOperator(), - ).subscribe((uuid) => { - if (this.resultsRD$.value.hasSucceeded) { - this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects, uuid); - } - }), - ); + private subscribeToRoutingEvents(): void { + if (this.trackStatistics) { + this.subs.push( + this.router.events.pipe( + filter((event) => event instanceof NavigationStart), + map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)), + hasValueOperator(), + ).subscribe((uuid) => { + if (this.resultsRD$.value.hasSucceeded) { + this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects, uuid); + } + }), + ); + } } /**