Skip to content

Commit

Permalink
24-sep-bach-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leomendoza123 committed Sep 24, 2024
1 parent 663ff80 commit bca1392
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class SummarySimplePanelComponent implements OnInit {
constructor(@Inject(WINDOW) private _window: Window) {}

ngOnInit(): void {
this.acitivityCountOverflow = this.simpleActivities.length > 3
this.acitivityCountOverflow = this.simpleActivities.length > 3 || this.count > 3
this.simpleActivities = this.simpleActivities.slice(0, 3)
}
goToUrl(url?: string, event?: KeyboardEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ <h1 class="orc-font-body-large">
'panel-body-3-cols': !mobile
}"
>

<div
class="column"
[ngClass]="{ 'column-border': !mobile && (twoColumns || threeColumns) }"
Expand Down Expand Up @@ -144,13 +145,15 @@ <h1 class="orc-font-body-large">
[activitySection]="'affiliations'"
></app-summary-panel>
</ng-container>
<ng-container *ngIf="emailDomains.length > 1">
<ng-container *ngIf="emailDomains.length >= 1">
<a
tabindex="0"
rel="noopener noreferrer"
(click)="goToActivitySection('emails-panel')"
(keydown)="goToActivitySection('emails-panel', $event)"
[attr.aria-label]="ariaLabelEmailDomains"
(mouseenter)="emailDomainsHover = true"
(mouseleave)="emailDomainsHover = false"
>
<h3
class="orc-font-small-print"
Expand Down Expand Up @@ -223,7 +226,7 @@ <h3 class="orc-font-small-print" i18n="@@summary.keyDates">
<div
class="column"
[ngClass]="{ 'column-border': !mobile && threeColumns }"
*ngIf="peerReviews?.length || works?.length || funds?.length"
*ngIf="peerReviews?.length || works?.length || funds?.length || researchResoruces?.length"
>
<ng-container *ngIf="works?.length">
<a
Expand Down Expand Up @@ -332,7 +335,8 @@ <h3 class="orc-font-small-print" i18n="@@summary.keyDates">
class="column"
*ngIf="
trustedSummary.professionalActivities?.length ||
externalIdentifiers?.length
externalIdentifiers?.length ||
trustedSummary.educationQualifications?.length
"
>
<ng-container *ngIf="trustedSummary.professionalActivities?.length">
Expand Down Expand Up @@ -406,6 +410,8 @@ <h3 class="orc-font-small-print" i18n="@@summary.keyDates">
(click)="goToActivitySection('other-identifiers')"
(keydown)="goToActivitySection('other-identifiers', $event)"
[attr.aria-label]="ariaLabelIdentifiers"
(mouseenter)="externalIdentifiersHover = true"
(mouseleave)="externalIdentifiersHover = false"
>
<h3
class="orc-font-small-print"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Component, Inject, Input, OnDestroy, OnInit } from '@angular/core'
import {
ChangeDetectorRef,
Component,
Inject,
Input,
OnDestroy,
OnInit,
} from '@angular/core'
import { Router } from '@angular/router'
import { TrustedSummaryService } from 'src/app/core/trusted-summary/trusted-summary.service'
import { TrustedSummary } from 'src/app/types/trust-summary'
Expand Down Expand Up @@ -93,7 +100,7 @@ export class TrustedSummaryComponent implements OnInit, OnDestroy {
emailDomains: SimpleActivityModel[]
twoColumns: boolean = false
threeColumns: boolean = false
oneColumn: boolean
oneColumn: boolean = false
createdToday = false
modifiedToday: boolean
creationDateWithOffset: any
Expand All @@ -106,6 +113,8 @@ export class TrustedSummaryComponent implements OnInit, OnDestroy {
private _platform: PlatformInfoService,
private _robotsMetaTags: RobotsMetaTagsService,
private _zendeskService: ZendeskService,
private _changeDetectorRef: ChangeDetectorRef,

// import window
@Inject(WINDOW) private _window: Window
) {}
Expand Down Expand Up @@ -253,30 +262,30 @@ export class TrustedSummaryComponent implements OnInit, OnDestroy {
stringA: domain.value,
}
})

if (
(this.works.length > 0 ||
this.funds.length > 0 ||
this.peerReviews.length > 0) &&
this.peerReviews.length > 0 ||
this.researchResoruces.length) &&
(this.externalIdentifiers?.length > 0 ||
this.trustedSummary.professionalActivitiesCount > 0 ||
this.trustedSummary.externalIdentifiers.length > 0 ||
this.trustedSummary.externalIdentifiers.length > 0 ||
this.researchResoruces.length > 0)
this.trustedSummary.educationQualifications?.length > 0)
) {
this.threeColumns = true
} else if (
this.works.length > 0 ||
this.funds.length > 0 ||
this.peerReviews.length > 0 ||
this.researchResoruces.length > 0 ||
this.externalIdentifiers?.length > 0 ||
this.trustedSummary.professionalActivitiesCount > 0 ||
this.researchResoruces.length > 0
this.trustedSummary.educationQualifications?.length > 0
) {
this.twoColumns = true
} else {
this.oneColumn = true
}
this._changeDetectorRef.markForCheck()
this.ariaLabelAffiliations = this.getAriaLabelSection(
this.labelViewAffiliations
)
Expand Down
106 changes: 106 additions & 0 deletions src/app/core/observability-events/observability-events.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { Inject, Injectable } from '@angular/core'
import { WINDOW } from 'src/app/cdk/window'
import { environment } from 'src/environments/environment'

export type journeyType = 'orcid_registration' | 'orcid_update_emails'
@Injectable({
providedIn: 'root',
})
export class CustomEventService {
// Store the start times of each journey
private journeys: { [key: string]: { startTime: number; attributes: any } } =
{}

constructor(@Inject(WINDOW) private window: Window) {}

/**
* Starts a new user journey.
* @param journeyType The type of the journey (e.g., 'orcid_registration', 'orcid_update_emails').
* @param attributes Additional attributes to store with the journey
*/
startJourney(journeyType: journeyType, attributes: any = {}): void {


// Record the start time and initial attributes
this.journeys[journeyType] = {
startTime: Date.now(),
attributes,
}

if (environment.debugger) {
console.debug(
`-> Journey "${journeyType}" started at ${this.journeys[journeyType].startTime}`
)
}
}

/**
* Records an event within the journey.
* @param journeyType The type of the journey (e.g., 'orcid_registration').
* @param eventName The name of the event to track (e.g., 'page_loaded', 'form_submitted').
* @param additionalAttributes Any additional attributes related to the event.
*/
recordEvent(
journeyType: string,
eventName: string,
additionalAttributes: any = {}
): void {
if (!this.journeys[journeyType]) {
console.error(`Journey "${journeyType}" not started.`)
return
}

// Calculate time since the start of the journey
const elapsedTime = Date.now() - this.journeys[journeyType].startTime

// Combine the journey attributes with additional attributes
const eventAttributes = {
...this.journeys[journeyType].attributes,
...additionalAttributes,
eventName,
elapsedTime,
}
;(this.window as any).newrelic.addPageAction(journeyType, eventAttributes)

// Send the custom event to New Relic

if (environment.debugger) {
console.debug(
`-> Event "${eventName}" recorded for journey "${journeyType}" with elapsed time ${elapsedTime}ms`
)
}
}

/**
* Finishes the user journey.
* @param journeyType The type of the journey (e.g., 'orcid_registration').
* @param additionalAttributes Any final attributes or metadata to log at the end of the journey.
*/
finishJourney(journeyType: string, additionalAttributes: any = {}): void {
if (!this.journeys[journeyType]) {
console.error(`Journey "${journeyType}" not started.`)
return
}

// Calculate time since the start of the journey
const elapsedTime = Date.now() - this.journeys[journeyType].startTime

// Final event attributes
const finalAttributes = {
...this.journeys[journeyType].attributes,
...additionalAttributes,
eventName: 'journey_finished',
elapsedTime,
}

// Send the final custom event to New Relic
;(this.window as any).addPageAction(journeyType, finalAttributes)

// Clean up the journey data
delete this.journeys[journeyType]

console.log(
`Journey "${journeyType}" finished with elapsed time ${elapsedTime}ms`
)
}
}
3 changes: 3 additions & 0 deletions src/app/record/pages/my-orcid/my-orcid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ export class MyOrcidComponent implements OnInit, OnDestroy {
'peer-reviews',
'funding',
'professional-activities',
'research-resources',
'emails-panel',
'education-and-qualification'
].find((x) => x === this.fragment)
) {
setTimeout(() => {
Expand Down

0 comments on commit bca1392

Please sign in to comment.