Skip to content

Commit 7968f68

Browse files
110889: Fixed trackStatistics still sending backend requests to track search event when trackStatistics is false
1 parent 37c534b commit 7968f68

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

src/app/shared/search/search.component.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,20 @@ export class SearchComponent implements OnDestroy, OnInit {
485485
* This method should only be called once and is essentially what SearchTrackingComponent used to do (now removed)
486486
* @private
487487
*/
488-
private subscribeToRoutingEvents() {
489-
this.subs.push(
490-
this.router.events.pipe(
491-
filter((event) => event instanceof NavigationStart),
492-
map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)),
493-
hasValueOperator(),
494-
).subscribe((uuid) => {
495-
if (this.resultsRD$.value.hasSucceeded) {
496-
this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects<DSpaceObject>, uuid);
497-
}
498-
}),
499-
);
488+
private subscribeToRoutingEvents(): void {
489+
if (this.trackStatistics) {
490+
this.subs.push(
491+
this.router.events.pipe(
492+
filter((event) => event instanceof NavigationStart),
493+
map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)),
494+
hasValueOperator(),
495+
).subscribe((uuid) => {
496+
if (this.resultsRD$.value.hasSucceeded) {
497+
this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects<DSpaceObject>, uuid);
498+
}
499+
}),
500+
);
501+
}
500502
}
501503

502504
/**

0 commit comments

Comments
 (0)