110889: Fixed trackStatistics still sending backend requests to track search event when trackStatistics is false

This commit is contained in:
Alexandre Vryghem
2024-02-18 18:49:55 +01:00
parent 37c534b809
commit 7968f68976

View File

@@ -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) * This method should only be called once and is essentially what SearchTrackingComponent used to do (now removed)
* @private * @private
*/ */
private subscribeToRoutingEvents() { private subscribeToRoutingEvents(): void {
this.subs.push( if (this.trackStatistics) {
this.router.events.pipe( this.subs.push(
filter((event) => event instanceof NavigationStart), this.router.events.pipe(
map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)), filter((event) => event instanceof NavigationStart),
hasValueOperator(), map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)),
).subscribe((uuid) => { hasValueOperator(),
if (this.resultsRD$.value.hasSucceeded) { ).subscribe((uuid) => {
this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects<DSpaceObject>, uuid); if (this.resultsRD$.value.hasSucceeded) {
} this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects<DSpaceObject>, uuid);
}), }
); }),
);
}
} }
/** /**