@@ -8,7 +8,7 @@ import { EventsCachePluggable } from './EventsCachePluggable';
88import { wrapperAdapter , METHODS_TO_PROMISE_WRAP } from './wrapperAdapter' ;
99import { isObject } from '../../utils/lang' ;
1010import { getStorageHash , validatePrefix } from '../KeyBuilder' ;
11- import { CONSUMER_PARTIAL_MODE , DEBUG , NONE , STORAGE_PLUGGABLE } from '../../utils/constants' ;
11+ import { CONSUMER_PARTIAL_MODE , STORAGE_PLUGGABLE } from '../../utils/constants' ;
1212import { ImpressionsCacheInMemory } from '../inMemory/ImpressionsCacheInMemory' ;
1313import { EventsCacheInMemory } from '../inMemory/EventsCacheInMemory' ;
1414import { ImpressionCountsCacheInMemory } from '../inMemory/ImpressionCountsCacheInMemory' ;
@@ -63,35 +63,31 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
6363 const prefix = validatePrefix ( options . prefix ) ;
6464
6565 function PluggableStorageFactory ( params : IStorageFactoryParams ) : IStorageAsync {
66- const { onReadyCb, settings, settings : { log, mode, sync : { impressionsMode } , scheduler : { impressionsQueueSize, eventsQueueSize } } } = params ;
66+ const { onReadyCb, settings, settings : { log, mode, scheduler : { impressionsQueueSize, eventsQueueSize } } } = params ;
6767 const metadata = metadataBuilder ( settings ) ;
6868 const keys = new KeyBuilderSS ( prefix , metadata ) ;
6969 const wrapper = wrapperAdapter ( log , options . wrapper ) ;
7070
71- const isSyncronizer = mode === undefined ; // If mode is not defined, the synchronizer is running
71+ const isSynchronizer = mode === undefined ; // If mode is not defined, the synchronizer is running
7272 const isPartialConsumer = mode === CONSUMER_PARTIAL_MODE ;
7373
74- const telemetry = shouldRecordTelemetry ( params ) || isSyncronizer ?
74+ const telemetry = shouldRecordTelemetry ( params ) || isSynchronizer ?
7575 isPartialConsumer ?
7676 new TelemetryCacheInMemory ( ) :
7777 new TelemetryCachePluggable ( log , keys , wrapper ) :
7878 undefined ;
7979
80- const impressionCountsCache = impressionsMode !== DEBUG || isSyncronizer ?
81- isPartialConsumer ?
82- new ImpressionCountsCacheInMemory ( ) :
83- new ImpressionCountsCachePluggable ( log , keys . buildImpressionsCountKey ( ) , wrapper ) :
84- undefined ;
80+ const impressionCountsCache = isPartialConsumer ?
81+ new ImpressionCountsCacheInMemory ( ) :
82+ new ImpressionCountsCachePluggable ( log , keys . buildImpressionsCountKey ( ) , wrapper ) ;
8583
86- const uniqueKeysCache = impressionsMode === NONE || isSyncronizer ?
87- isPartialConsumer ?
88- settings . core . key === undefined ? new UniqueKeysCacheInMemory ( ) : new UniqueKeysCacheInMemoryCS ( ) :
89- new UniqueKeysCachePluggable ( log , keys . buildUniqueKeysKey ( ) , wrapper ) :
90- undefined ;
84+ const uniqueKeysCache = isPartialConsumer ?
85+ settings . core . key === undefined ? new UniqueKeysCacheInMemory ( ) : new UniqueKeysCacheInMemoryCS ( ) :
86+ new UniqueKeysCachePluggable ( log , keys . buildUniqueKeysKey ( ) , wrapper ) ;
9187
9288 // Connects to wrapper and emits SDK_READY event on main client
9389 const connectPromise = wrapper . connect ( ) . then ( ( ) => {
94- if ( isSyncronizer ) {
90+ if ( isSynchronizer ) {
9591 // In standalone or producer mode, clear storage if SDK key or feature flag filter has changed
9692 return wrapper . get ( keys . buildHashKey ( ) ) . then ( ( hash ) => {
9793 const currentHash = getStorageHash ( settings ) ;
@@ -106,8 +102,8 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
106102 } ) ;
107103 } else {
108104 // Start periodic flush of async storages if not running synchronizer (producer mode)
109- if ( impressionCountsCache && ( impressionCountsCache as ImpressionCountsCachePluggable ) . start ) ( impressionCountsCache as ImpressionCountsCachePluggable ) . start ( ) ;
110- if ( uniqueKeysCache && ( uniqueKeysCache as UniqueKeysCachePluggable ) . start ) ( uniqueKeysCache as UniqueKeysCachePluggable ) . start ( ) ;
105+ if ( ( impressionCountsCache as ImpressionCountsCachePluggable ) . start ) ( impressionCountsCache as ImpressionCountsCachePluggable ) . start ( ) ;
106+ if ( ( uniqueKeysCache as UniqueKeysCachePluggable ) . start ) ( uniqueKeysCache as UniqueKeysCachePluggable ) . start ( ) ;
111107 if ( telemetry && ( telemetry as ITelemetryCacheAsync ) . recordConfig ) ( telemetry as ITelemetryCacheAsync ) . recordConfig ( ) ;
112108
113109 onReadyCb ( ) ;
@@ -129,9 +125,9 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
129125
130126 // Stop periodic flush and disconnect the underlying storage
131127 destroy ( ) {
132- return Promise . all ( isSyncronizer ? [ ] : [
133- impressionCountsCache && ( impressionCountsCache as ImpressionCountsCachePluggable ) . stop && ( impressionCountsCache as ImpressionCountsCachePluggable ) . stop ( ) ,
134- uniqueKeysCache && ( uniqueKeysCache as UniqueKeysCachePluggable ) . stop && ( uniqueKeysCache as UniqueKeysCachePluggable ) . stop ( ) ,
128+ return Promise . all ( isSynchronizer ? [ ] : [
129+ ( impressionCountsCache as ImpressionCountsCachePluggable ) . stop && ( impressionCountsCache as ImpressionCountsCachePluggable ) . stop ( ) ,
130+ ( uniqueKeysCache as UniqueKeysCachePluggable ) . stop && ( uniqueKeysCache as UniqueKeysCachePluggable ) . stop ( ) ,
135131 ] ) . then ( ( ) => wrapper . disconnect ( ) ) ;
136132 } ,
137133
0 commit comments