Skip to content

Commit cc2c76a

Browse files
authored
PD-5240 (#2792)
* PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * PD-5240 * COMMS-1503 * PD-5240 * PD-5240 * PD-5240 * PD-5240
1 parent 2f5f019 commit cc2c76a

47 files changed

Lines changed: 427 additions & 177 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ The app sends events to **New Relic** (and optionally logs them in the console)
3434

3535
### Event names: use the enum
3636

37-
- **All event name strings** live in **`AppEventName`** in `src/app/register/app-event-names.ts`. Do not hardcode event names elsewhere.
37+
- **All event name strings** live in **`AppEventName`** in `src/app/rum/app-event-names.ts`. Do not hardcode event names elsewhere.
3838
- For **dynamic** names (e.g. `step-${step}-loaded`), add a small helper in the same file (e.g. `stepLoadedEvent(step)`) and use it when calling `recordEvent`.
39+
- **Terminal outcomes** (user leaves the flow, error screen, success that navigates away): add the event to **`src/app/rum/terminating-rum-events.ts`** so `RumJourneyEventService` triggers an immediate NR harvest after recording.

angular.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@
143143
},
144144
"configurations": {
145145
"local": {
146+
"scripts": [
147+
"/scripts/environment.runtime.js",
148+
"/scripts/onetrust.runtime.js",
149+
"/scripts/new-relic.runtime.js"
150+
],
146151
"budgets": [
147152
{
148153
"type": "anyComponentStyle",
@@ -164,6 +169,11 @@
164169
"outputPath": "dist"
165170
},
166171
"local-with-proxy": {
172+
"scripts": [
173+
"/scripts/environment.runtime.js",
174+
"/scripts/onetrust.runtime.js",
175+
"/scripts/new-relic.runtime.js"
176+
],
167177
"optimization": false,
168178
"outputHashing": "none",
169179
"sourceMap": true,
@@ -180,6 +190,11 @@
180190
]
181191
},
182192
"local-with-proxy-localize-en": {
193+
"scripts": [
194+
"/scripts/environment.runtime.js",
195+
"/scripts/onetrust.runtime.js",
196+
"/scripts/new-relic.runtime.js"
197+
],
183198
"localize": ["en"],
184199
"optimization": false,
185200
"outputHashing": "none",
@@ -197,12 +212,27 @@
197212
]
198213
},
199214
"local-with-proxy-localize-fr": {
215+
"scripts": [
216+
"/scripts/environment.runtime.js",
217+
"/scripts/onetrust.runtime.js",
218+
"/scripts/new-relic.runtime.js"
219+
],
200220
"localize": ["fr"]
201221
},
202222
"local-with-proxy-localize-ar": {
223+
"scripts": [
224+
"/scripts/environment.runtime.js",
225+
"/scripts/onetrust.runtime.js",
226+
"/scripts/new-relic.runtime.js"
227+
],
203228
"localize": ["ar"]
204229
},
205230
"local-with-proxy-localize-xx": {
231+
"scripts": [
232+
"/scripts/environment.runtime.js",
233+
"/scripts/onetrust.runtime.js",
234+
"/scripts/new-relic.runtime.js"
235+
],
206236
"localize": ["xx"]
207237
},
208238
"production": {

scripts/new-relic.runtime.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
window.NREUM || (NREUM = {})
22
NREUM.init = {
3-
performance: { capture_measures: true },
3+
performance: { capture_measures: false },
44
browser_consent_mode: { enabled: false },
55
privacy: { cookies_enabled: true },
6-
session_replay: { enabled: false },
7-
session_trace: { enabled: false },
8-
ajax: { capture_payloads: 'none', autoStart: false },
9-
page_view_event: { autoStart: false },
10-
page_view_timing: { autoStart: false },
11-
jserrors: { autoStart: false },
12-
metrics: { autoStart: false },
13-
generic_events: { autoStart: false },
14-
soft_navigations: { autoStart: false },
6+
// --- Temporarily disabled (noise / volume); re-enable in NREUM.init when ready ---
7+
session_replay: { enabled: false }, // Session replay
8+
session_trace: { enabled: false }, // Session traces / long tasks
9+
// XHR/fetch instrumentation (custom timings, Ajax events)
10+
ajax: { enabled: false, capture_payloads: 'none', autoStart: false },
11+
page_view_event: { enabled: false, autoStart: false }, // Initial page view beacon payload
12+
page_view_timing: { enabled: false, autoStart: false }, // Web vitals / timing harvest
13+
jserrors: { enabled: false, autoStart: false }, // Uncaught JS error reports
14+
// Custom metrics aggregate (separate from PageView timing)
15+
metrics: { enabled: false, autoStart: false },
16+
// UserAction / interaction events (click, blur, keydown, etc.)
17+
generic_events: { enabled: true, autoStart: false },
18+
page_action: { enabled: true }, // addPageAction API default collection
19+
user_actions: { enabled: false },
20+
// SPA soft-navigation / route-change instrumentation
21+
soft_navigations: { enabled: false, autoStart: false },
1522
}
1623

1724
NREUM.loader_config = {

src/app/authorize/components/form-authorize/form-authorize.component.spec.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ describe('FormAuthorizeComponent', () => {
119119
PlatformInfoService
120120
) as jasmine.SpyObj<PlatformInfoService>
121121
mockWindow = TestBed.inject(WINDOW) as jasmine.SpyObj<Window>
122+
;(mockWindow as any).outOfRouterNavigation = (value: string) => {
123+
mockWindow.location.href = value
124+
}
122125

123126
// Setup default mocks
124127
togglzService.getStateOf.and.returnValue(of(false))
@@ -330,7 +333,7 @@ describe('FormAuthorizeComponent', () => {
330333
expect(mockWindow.location.href).toContain('redirect_uri=')
331334
})
332335

333-
it('should redirect to signin even when noRedirectLogout fails', (done) => {
336+
it('should redirect to signin even when noRedirectLogout fails', () => {
334337
const queryParams = {
335338
email: 'test@example.com',
336339
scope: 'read write',
@@ -342,29 +345,21 @@ describe('FormAuthorizeComponent', () => {
342345

343346
component.logout()
344347

345-
// Wait for the async operation to complete
346-
setTimeout(() => {
347-
expect(userService.noRedirectLogout).toHaveBeenCalled()
348-
expect(mockWindow.location.href).toBe(
349-
'/signin?email=test%40example.com&scope=read+write'
350-
)
351-
done()
352-
}, 100)
348+
expect(userService.noRedirectLogout).toHaveBeenCalled()
349+
expect(mockWindow.location.href).toBe(
350+
'/signin?email=test%40example.com&scope=read+write'
351+
)
353352
})
354353

355-
it('should redirect to signin with empty query parameters when noRedirectLogout fails', (done) => {
354+
it('should redirect to signin with empty query parameters when noRedirectLogout fails', () => {
356355
component.platformInfo.queryParameters = {}
357356
userService.noRedirectLogout.and.returnValue(
358357
throwError(() => new Error('Logout failed'))
359358
)
360359

361360
component.logout()
362361

363-
// Wait for the async operation to complete
364-
setTimeout(() => {
365-
expect(mockWindow.location.href).toBe('/signin')
366-
done()
367-
}, 100)
362+
expect(mockWindow.location.href).toBe('/signin')
368363
})
369364

370365
it('should redirect to signout when OAUTH_AUTHORIZATION is false', () => {

src/app/authorize/components/form-authorize/form-authorize.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { TogglzService } from 'src/app/core/togglz/togglz.service'
4040
import { OauthURLSessionManagerService } from 'src/app/core/oauth-urlsession-manager/oauth-urlsession-manager.service'
4141
import { TogglzFlag } from 'src/app/types/config.endpoint'
4242
import { RumJourneyEventService } from 'src/app/rum/service/customEvent.service'
43-
import { AppEventName } from 'src/app/register/app-event-names'
43+
import { AppEventName } from 'src/app/rum/app-event-names'
4444
import { OauthAuthorizationContext } from 'src/app/rum/journeys/oauthAuthorization'
4545
import { oauthAuthorizeHttpFailureEventAttrs } from 'src/app/rum/oauth-authorize-http-failure-event-attrs'
4646
import { serializeQueryParamsForRum } from 'src/app/rum/serialize-oauth-query-for-rum'
@@ -178,7 +178,7 @@ export class FormAuthorizeComponent implements OnInit, OnDestroy {
178178
this.performRedirect()
179179
})
180180
} else {
181-
this.window.location.href = '/signout'
181+
;(this.window as any).outOfRouterNavigation('/signout')
182182
}
183183
}
184184

@@ -188,7 +188,7 @@ export class FormAuthorizeComponent implements OnInit, OnDestroy {
188188
? new URLSearchParams(this.platformInfo.queryParameters).toString()
189189
: ''
190190
const signinUrl = queryParams ? `/signin?${queryParams}` : '/signin'
191-
this.window.location.href = signinUrl
191+
;(this.window as any).outOfRouterNavigation(signinUrl)
192192
}
193193

194194
authorize(value = true) {

src/app/authorize/components/oauth-error/oauth-error.component.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { LegacyOauthRequestInfoForm as RequestInfoForm } from 'src/app/types/req
1010
import { UserSession } from 'src/app/types/session.local'
1111
import { RumJourneyEventService } from 'src/app/rum/service/customEvent.service'
1212
import { TogglzFlag } from 'src/app/types/config.endpoint'
13-
import { AppEventName } from 'src/app/register/app-event-names'
13+
import { AppEventName } from 'src/app/rum/app-event-names'
1414
import { getOauthAuthorizationErrorCategory } from 'src/app/rum/oauth-authorization-error-category'
1515
import { OauthAuthorizationContext } from 'src/app/rum/journeys/oauthAuthorization'
1616
import { serializeQueryParamsForRum } from 'src/app/rum/serialize-oauth-query-for-rum'
@@ -76,11 +76,6 @@ export class OauthErrorComponent implements OnInit, OnDestroy {
7676
error: this.error,
7777
errorCode: this.errorCode,
7878
errorDescription: this.errorDescription,
79-
}
80-
)
81-
this._observability.recordSimpleEvent(
82-
AppEventName.OauthAuthorizationValidationFailed,
83-
{
8479
surface: 'oauth_error_page',
8580
error_category: getOauthAuthorizationErrorCategory(
8681
this.error,
@@ -91,13 +86,6 @@ export class OauthErrorComponent implements OnInit, OnDestroy {
9186
oauth_error_description: String(
9287
this.errorDescription ?? ''
9388
).slice(0, 500),
94-
client_id: this.queryParams?.client_id,
95-
redirect_uri: this.queryParams?.redirect_uri,
96-
response_type: this.queryParams?.response_type,
97-
scope: this.queryParams?.scope,
98-
oauth_query_string: serializeQueryParamsForRum(
99-
platform.queryParameters
100-
),
10189
}
10290
)
10391
this.oauthJourneyStarted = true

src/app/authorize/pages/authorize/authorize.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { OauthURLSessionManagerService } from 'src/app/core/oauth-urlsession-man
2424
import { FeatureLoggerService } from 'src/app/core/logging/feature-logger.service'
2525
import { TogglzFlag } from 'src/app/types/config.endpoint'
2626
import { RumJourneyEventService } from 'src/app/rum/service/customEvent.service'
27-
import { AppEventName } from 'src/app/register/app-event-names'
27+
import { AppEventName } from 'src/app/rum/app-event-names'
2828

2929
@Component({
3030
templateUrl: './authorize.component.html',

src/app/cdk/panel/panel/panel.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { TogglzService } from '../../../core/togglz/togglz.service'
3434
import { getAriaLabel } from '../../../constants'
3535
import { RecordBiographyService } from 'src/app/core/record-biography/record-biography.service'
3636
import { RumJourneyEventService } from 'src/app/rum/service/customEvent.service'
37-
import { AppEventName } from 'src/app/register/app-event-names'
37+
import { AppEventName } from 'src/app/rum/app-event-names'
3838
import { ExpandedWorkFeaturedModalComponent } from 'src/app/record/components/work-featured/modals/expanded-work-featured-modal/expanded-work-featured-modal.component'
3939

4040
@Component({

src/app/cdk/two-factor-authentication-form/two-factor/two-factor-authentication-form.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,6 @@ export class TwoFactorAuthenticationFormComponent implements AfterViewInit {
150150
}
151151

152152
navigateTo(val) {
153-
this.window.location.href = val
153+
;(this.window as any).outOfRouterNavigation(val)
154154
}
155155
}

src/app/cdk/window/window.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ export class BrowserWindowRef extends WindowRef {
2323
constructor() {
2424
if (!(window as any).outOfRouterNavigation) {
2525
;(window as any).outOfRouterNavigation = (value) => {
26-
window.location.href = value
26+
const HARVEST_TIMEOUT_MS = 300
27+
try {
28+
if (typeof (window as any).orcidForceRumHarvest === 'function') {
29+
;(window as any).orcidForceRumHarvest()
30+
}
31+
} catch {
32+
// Keep navigation resilient even if RUM flush fails.
33+
}
34+
window.setTimeout(() => {
35+
window.location.href = value
36+
}, HARVEST_TIMEOUT_MS)
2737
}
2838
}
2939
super()

0 commit comments

Comments
 (0)