1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-27 14:53:44 +00:00

change from debug to info logs so we can see everything on olena's end

This commit is contained in:
Alex
2026-01-21 12:14:56 -05:00
parent 1578886a5f
commit df4c2d248e
2 changed files with 27 additions and 10 deletions

View File

@@ -64,6 +64,9 @@ export const PHISHING_DOMAINS_BLOB_KEY = new KeyDefinition<string>(
/** Coordinates fetching, caching, and patching of known phishing web addresses */
export class PhishingDataService {
// Track instance count to detect if multiple services are created (potential memory leak)
private static _instanceCount = 0;
private _testWebAddresses = this.getTestWebAddresses().concat("phishing.testcategory.com"); // Included for QA to test in prod
private _phishingMetaState = this.globalStateProvider.get(PHISHING_DOMAINS_META_KEY);
private _phishingBlobState = this.globalStateProvider.get(PHISHING_DOMAINS_BLOB_KEY);
@@ -101,7 +104,10 @@ export class PhishingDataService {
private platformUtilsService: PlatformUtilsService,
private resourceType: PhishingResourceType = PhishingResourceType.Links,
) {
this.logService.debug("[PhishingDataService] Initializing service...");
PhishingDataService._instanceCount++;
this.logService.info(
`[PhishingDataService] Initializing service instance #${PhishingDataService._instanceCount}`,
);
this.taskSchedulerService.registerTaskHandler(ScheduledTaskNames.phishingDomainUpdate, () => {
this._triggerUpdate$.next();
});
@@ -120,7 +126,7 @@ export class PhishingDataService {
*/
async isPhishingWebAddress(url: URL): Promise<boolean> {
if (!this._webAddressesSet) {
this.logService.debug("[PhishingDataService] Set not loaded; skipping check");
this.logService.info("[PhishingDataService] Set not loaded; skipping check");
return false;
}
@@ -235,7 +241,7 @@ export class PhishingDataService {
const webAddresses = devFlagValue("testPhishingUrls") as unknown[];
if (webAddresses && webAddresses instanceof Array) {
this.logService.debug(
this.logService.info(
"[PhishingDetectionService] Dev flag enabled for testing phishing detection. Adding test phishing web addresses:",
webAddresses,
);
@@ -339,7 +345,7 @@ export class PhishingDataService {
// Try to load compressed newline blob into an in-memory Set for fast lookups
private async _loadBlobToMemory(): Promise<void> {
this.logService.debug("[PhishingDataService] Loading data blob into memory...");
this.logService.info("[PhishingDataService] Loading data blob into memory...");
try {
const blobBase64 = await firstValueFrom(this._phishingBlobState.state$);
if (!blobBase64) {

View File

@@ -43,6 +43,7 @@ export class PhishingDetectionService {
private static _tabUpdated$ = new Subject<PhishingDetectionNavigationEvent>();
private static _ignoredHostnames = new Set<string>();
private static _didInit = false;
private static _logService: LogService | null = null;
static initialize(
logService: LogService,
@@ -51,17 +52,18 @@ export class PhishingDetectionService {
messageListener: MessageListener,
) {
if (this._didInit) {
logService.debug("[PhishingDetectionService] Initialize already called. Aborting.");
logService.info("[PhishingDetectionService] Initialize already called. Aborting.");
return;
}
logService.debug("[PhishingDetectionService] Initialize called. Checking prerequisites...");
logService.info("[PhishingDetectionService] Initialize called. Checking prerequisites...");
this._logService = logService;
BrowserApi.addListener(chrome.tabs.onUpdated, this._handleTabUpdated.bind(this));
const onContinueCommand$ = messageListener.messages$(PHISHING_DETECTION_CONTINUE_COMMAND).pipe(
tap((message) =>
logService.debug(`[PhishingDetectionService] user selected continue for ${message.url}`),
logService.info(`[PhishingDetectionService] user selected continue for ${message.url}`),
),
concatMap(async (message) => {
const url = new URL(message.url);
@@ -87,7 +89,7 @@ export class PhishingDetectionService {
prev.tabId === curr.tabId &&
prev.ignored === curr.ignored,
),
tap((event) => logService.debug(`[PhishingDetectionService] processing event:`, event)),
tap((event) => logService.info(`[PhishingDetectionService] processing event:`, event)),
concatMap(async ({ tabId, url, ignored }) => {
if (ignored) {
// The next time this host is visited, block again
@@ -118,12 +120,12 @@ export class PhishingDetectionService {
distinctUntilChanged(),
switchMap((activeUserHasAccess) => {
if (!activeUserHasAccess) {
logService.debug(
logService.info(
"[PhishingDetectionService] User does not have access to phishing detection service.",
);
return EMPTY;
} else {
logService.debug("[PhishingDetectionService] Enabling phishing detection service");
logService.info("[PhishingDetectionService] Enabling phishing detection service");
return merge(
phishingDataService.update$,
onContinueCommand$,
@@ -137,6 +139,9 @@ export class PhishingDetectionService {
this._didInit = true;
return () => {
logService.info(
`[PhishingDetectionService] Cleanup called. Observers: ${this._tabUpdated$.observers.length}, Ignored hostnames: ${this._ignoredHostnames.size}`,
);
initSub.unsubscribe();
this._didInit = false;
@@ -155,6 +160,12 @@ export class PhishingDetectionService {
changeInfo: chrome.tabs.OnUpdatedInfo,
tab: chrome.tabs.Tab,
): boolean {
// Log observer count to detect listener leaks (should always be 1)
if (this._tabUpdated$.observers.length > 1) {
this._logService?.warning(
`[PhishingDetectionService] Multiple observers detected: ${this._tabUpdated$.observers.length}`,
);
}
this._tabUpdated$.next({ tabId, changeInfo, tab });
// Return value for supporting BrowserApi event listener signature