11import { createDispatchMap , select } from '@ngxs/store' ;
22
3- import { map } from 'rxjs' ;
3+ import { filter , map } from 'rxjs' ;
44
55import { DatePipe } from '@angular/common' ;
66import {
@@ -15,7 +15,7 @@ import {
1515 signal ,
1616} from '@angular/core' ;
1717import { takeUntilDestroyed , toObservable , toSignal } from '@angular/core/rxjs-interop' ;
18- import { ActivatedRoute , RouterOutlet } from '@angular/router' ;
18+ import { ActivatedRoute , NavigationEnd , Router , RouterOutlet } from '@angular/router' ;
1919
2020import { ENVIRONMENT } from '@core/provider/environment.provider' ;
2121import { HelpScoutService } from '@core/services/help-scout.service' ;
@@ -27,6 +27,7 @@ import { AnalyticsService } from '@osf/shared/services/analytics.service';
2727import { MetaTagsService } from '@osf/shared/services/meta-tags.service' ;
2828import { ContributorsSelectors , GetBibliographicContributors } from '@osf/shared/stores/contributors' ;
2929import { DataciteService } from '@shared/services/datacite/datacite.service' ;
30+ import { CurrentResourceSelectors } from '@shared/stores/current-resource' ;
3031
3132import { GetRegistryIdentifiers , GetRegistryWithRelatedData , RegistrySelectors } from './store/registry' ;
3233
@@ -59,7 +60,7 @@ export class RegistryComponent implements OnDestroy {
5960 } ) ;
6061
6162 private registryId = toSignal ( this . route . params . pipe ( map ( ( params ) => params [ 'id' ] ) ) ) ;
62-
63+ readonly currentResource = select ( CurrentResourceSelectors . getCurrentResource ) ;
6364 readonly registry = select ( RegistrySelectors . getRegistry ) ;
6465 readonly isRegistryLoading = select ( RegistrySelectors . isRegistryLoading ) ;
6566 readonly identifiersForDatacite$ = toObservable ( select ( RegistrySelectors . getIdentifiers ) ) . pipe (
@@ -79,6 +80,7 @@ export class RegistryComponent implements OnDestroy {
7980 ) ;
8081
8182 private readonly lastMetaTagsRegistryId = signal < string | null > ( null ) ;
83+ readonly router = inject ( Router ) ;
8284
8385 constructor ( ) {
8486 this . prerenderReady . setNotReady ( ) ;
@@ -106,17 +108,22 @@ export class RegistryComponent implements OnDestroy {
106108 }
107109 } ) ;
108110
109- effect ( ( ) => {
110- const currentRegistry = this . registry ( ) ;
111- if ( currentRegistry && currentRegistry . isPublic ) {
112- this . analyticsService . sendCountedUsage ( currentRegistry . id , 'registry.detail' ) . subscribe ( ) ;
113- }
114- } ) ;
115-
116111 this . dataciteService
117112 . logIdentifiableView ( this . identifiersForDatacite$ )
118113 . pipe ( takeUntilDestroyed ( this . destroyRef ) )
119114 . subscribe ( ) ;
115+
116+ this . router . events
117+ . pipe (
118+ filter ( ( event ) => event instanceof NavigationEnd ) ,
119+ takeUntilDestroyed ( this . destroyRef )
120+ )
121+ . subscribe ( ( event : NavigationEnd ) => {
122+ this . analyticsService . sendCountedUsageForRegistrationAndProjects (
123+ event . urlAfterRedirects ,
124+ this . currentResource ( )
125+ ) ;
126+ } ) ;
120127 }
121128
122129 ngOnDestroy ( ) : void {
0 commit comments