-
Notifications
You must be signed in to change notification settings - Fork 16
Feat(8653): Implement view tracking for registrations and preprints #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
11e5c0b
9ae4195
224879b
98c64c7
f50ac5c
43bb3ef
f57b8c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { Button } from 'primeng/button'; | |
import { DialogService } from 'primeng/dynamicdialog'; | ||
import { Skeleton } from 'primeng/skeleton'; | ||
|
||
import { filter, map, of } from 'rxjs'; | ||
import { filter, map, Observable, of } from 'rxjs'; | ||
|
||
import { DatePipe, Location } from '@angular/common'; | ||
import { | ||
|
@@ -19,7 +19,7 @@ import { | |
OnDestroy, | ||
OnInit, | ||
} from '@angular/core'; | ||
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'; | ||
import { takeUntilDestroyed, toObservable, toSignal } from '@angular/core/rxjs-interop'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
|
||
import { UserSelectors } from '@core/store/user'; | ||
|
@@ -46,7 +46,9 @@ import { | |
import { GetPreprintProviderById, PreprintProvidersSelectors } from '@osf/features/preprints/store/preprint-providers'; | ||
import { CreateNewVersion, PreprintStepperSelectors } from '@osf/features/preprints/store/preprint-stepper'; | ||
import { IS_MEDIUM, pathJoin } from '@osf/shared/helpers'; | ||
import { DataciteTrackerComponent } from '@shared/components/datacite-tracker/datacite-tracker.component'; | ||
import { ReviewPermissions, UserPermissions } from '@shared/enums'; | ||
import { Identifier } from '@shared/models'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is an identifier? I don't see it in the code base. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added this model in the current PR |
||
import { MetaTagsService } from '@shared/services'; | ||
import { ContributorsSelectors } from '@shared/stores'; | ||
|
||
|
@@ -75,7 +77,7 @@ import { environment } from 'src/environments/environment'; | |
providers: [DialogService, DatePipe], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class PreprintDetailsComponent implements OnInit, OnDestroy { | ||
export class PreprintDetailsComponent extends DataciteTrackerComponent implements OnInit, OnDestroy { | ||
@HostBinding('class') classes = 'flex-1 flex flex-column w-full'; | ||
|
||
private readonly router = inject(Router); | ||
|
@@ -105,6 +107,7 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy { | |
preprintProvider = select(PreprintProvidersSelectors.getPreprintProviderDetails(this.providerId())); | ||
isPreprintProviderLoading = select(PreprintProvidersSelectors.isPreprintProviderDetailsLoading); | ||
preprint = select(PreprintSelectors.getPreprint); | ||
preprint$ = toObservable(select(PreprintSelectors.getPreprint)); | ||
isPreprintLoading = select(PreprintSelectors.isPreprintLoading); | ||
contributors = select(ContributorsSelectors.getContributors); | ||
areContributorsLoading = select(ContributorsSelectors.isContributorsLoading); | ||
|
@@ -281,12 +284,17 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy { | |
this.fetchPreprint(this.preprintId()); | ||
}, | ||
}); | ||
this.setupDataciteViewTrackerEffect().subscribe(); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.actions.resetState(); | ||
} | ||
|
||
protected override get trackable(): Observable<{ identifiers?: Identifier[] } | null> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a collection of identifiers if you are only returning a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the confusion, but I am not returning a preprint only. This method returns everything which has identifiers. In our case it it These models have a collection of identifiers because there may be other identifiers other than DOI. |
||
return this.preprint$; | ||
} | ||
|
||
fetchPreprintVersion(preprintVersionId: string) { | ||
const currentUrl = this.router.url; | ||
const newUrl = currentUrl.replace(/[^/]+$/, preprintVersionId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is present because it it impossible to preview preprints locally without it