From e09eaa6316e1bf084989a030914ffc63b8c0e64f Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 28 Oct 2025 17:28:33 -0400 Subject: [PATCH] feat(dirt): add newApplications$ observable to orchestrator Add reactive observable that filters applicationData for unreviewed apps (reviewedDate === null). Observable automatically updates when report state changes through the pipeline. - Add newApplications$ observable with distinctUntilChanged - Filters rawReportData$.data.applicationData - Uses shareReplay for multi-subscriber efficiency Related to PM-27284 --- .../domain/risk-insights-orchestrator.service.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-orchestrator.service.ts b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-orchestrator.service.ts index f52ab68985b..b6d6e10fbbc 100644 --- a/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-orchestrator.service.ts +++ b/bitwarden_license/bit-common/src/dirt/reports/risk-insights/services/domain/risk-insights-orchestrator.service.ts @@ -91,6 +91,22 @@ export class RiskInsightsOrchestratorService { private _enrichedReportDataSubject = new BehaviorSubject(null); enrichedReportData$ = this._enrichedReportDataSubject.asObservable(); + // New applications that haven't been reviewed (reviewedDate === null) + newApplications$: Observable = this.rawReportData$.pipe( + map((reportState) => { + if (!reportState.data?.applicationData) { + return []; + } + return reportState.data.applicationData + .filter((app) => app.reviewedDate === null) + .map((app) => app.applicationName); + }), + distinctUntilChanged( + (prev, curr) => prev.length === curr.length && prev.every((app, i) => app === curr[i]), + ), + shareReplay({ bufferSize: 1, refCount: true }), + ); + // Generate report trigger and state private _generateReportTriggerSubject = new BehaviorSubject(false); generatingReport$ = this._generateReportTriggerSubject.asObservable();