diff --git a/src/config/entities/__tests__/configuration.ts b/src/config/entities/__tests__/configuration.ts index d605767183..111e79e878 100644 --- a/src/config/entities/__tests__/configuration.ts +++ b/src/config/entities/__tests__/configuration.ts @@ -110,7 +110,7 @@ export default (): ReturnType => ({ zerionBalancesChainIds: ['137'], swapsDecoding: true, twapsDecoding: true, - historyDebugLogs: false, + debugLogs: false, imitationMapping: false, auth: false, confirmationView: false, diff --git a/src/config/entities/configuration.ts b/src/config/entities/configuration.ts index aaccc5e4a6..9e11bc6102 100644 --- a/src/config/entities/configuration.ts +++ b/src/config/entities/configuration.ts @@ -164,8 +164,7 @@ export default () => ({ process.env.FF_ZERION_BALANCES_CHAIN_IDS?.split(',') ?? [], swapsDecoding: process.env.FF_SWAPS_DECODING?.toLowerCase() === 'true', twapsDecoding: process.env.FF_TWAPS_DECODING?.toLowerCase() === 'true', - historyDebugLogs: - process.env.FF_HISTORY_DEBUG_LOGS?.toLowerCase() === 'true', + debugLogs: process.env.FF_DEBUG_LOGS?.toLowerCase() === 'true', imitationMapping: process.env.FF_IMITATION_MAPPING?.toLowerCase() === 'true', auth: process.env.FF_AUTH?.toLowerCase() === 'true', diff --git a/src/datasources/cache/cache.first.data.source.spec.ts b/src/datasources/cache/cache.first.data.source.spec.ts index a3ba79e038..2066ff10b2 100644 --- a/src/datasources/cache/cache.first.data.source.spec.ts +++ b/src/datasources/cache/cache.first.data.source.spec.ts @@ -32,7 +32,7 @@ describe('CacheFirstDataSource', () => { jest.useFakeTimers(); fakeCacheService = new FakeCacheService(); fakeConfigurationService = new FakeConfigurationService(); - fakeConfigurationService.set('features.historyDebugLogs', true); + fakeConfigurationService.set('features.debugLogs', true); cacheFirstDataSource = new CacheFirstDataSource( fakeCacheService, mockNetworkService, diff --git a/src/datasources/cache/cache.first.data.source.ts b/src/datasources/cache/cache.first.data.source.ts index 7068bc0e2a..9cd3d6e318 100644 --- a/src/datasources/cache/cache.first.data.source.ts +++ b/src/datasources/cache/cache.first.data.source.ts @@ -21,6 +21,7 @@ import { } from '@/domain/safe/entities/transaction.entity'; import { IConfigurationService } from '@/config/configuration.service.interface'; import { isArray } from 'lodash'; +import { Safe } from '@/domain/safe/entities/safe.entity'; /** * A data source which tries to retrieve values from cache using @@ -33,7 +34,7 @@ import { isArray } from 'lodash'; */ @Injectable() export class CacheFirstDataSource { - private readonly isHistoryDebugLogsEnabled: boolean; + private readonly areDebugLogsEnabled: boolean; constructor( @Inject(CacheService) private readonly cacheService: ICacheService, @@ -42,10 +43,8 @@ export class CacheFirstDataSource { @Inject(IConfigurationService) private readonly configurationService: IConfigurationService, ) { - this.isHistoryDebugLogsEnabled = - this.configurationService.getOrThrow( - 'features.historyDebugLogs', - ); + this.areDebugLogsEnabled = + this.configurationService.getOrThrow('features.debugLogs'); } /** @@ -132,8 +131,9 @@ export class CacheFirstDataSource { // TODO: transient logging for debugging if ( - this.isHistoryDebugLogsEnabled && - args.url.includes('all-transactions') + this.areDebugLogsEnabled && + (args.url.includes('all-transactions') || + args.url.includes('multisig-transactions')) ) { this.logTransactionsCacheWrite( startTimeMs, @@ -141,6 +141,14 @@ export class CacheFirstDataSource { data as Page, ); } + + if (this.areDebugLogsEnabled && args.cacheDir.key.includes('_safe_')) { + this.logSafeMetadataCacheWrite( + startTimeMs, + args.cacheDir, + data as Safe, + ); + } } return data; } @@ -237,4 +245,24 @@ export class CacheFirstDataSource { }), }); } + + /** + * Logs the Safe metadata retrieved. + * NOTE: this is a debugging-only function. + * TODO: remove this function after debugging. + */ + private logSafeMetadataCacheWrite( + requestStartTime: number, + cacheDir: CacheDir, + safe: Safe, + ): void { + this.loggingService.info({ + type: 'cache_write', + cacheKey: cacheDir.key, + cacheField: cacheDir.field, + cacheWriteTime: new Date(), + requestStartTime: new Date(requestStartTime), + safe, + }); + } }