@@ -68,14 +68,6 @@ const DEFAULT_STREAM: string = 'https://clientstream.launchdarkly.com';
6868
6969export { DEFAULT_POLLING , DEFAULT_STREAM } ;
7070
71- function ensureSafeLogger ( logger ?: LDLogger ) : LDLogger {
72- if ( logger instanceof SafeLogger ) {
73- return logger ;
74- }
75- // Even if logger is not defined this will produce a valid logger.
76- return createSafeLogger ( logger ) ;
77- }
78-
7971interface ConfigurationValues {
8072 logger : LDLogger ;
8173 baseUri : string ;
@@ -113,11 +105,43 @@ interface ConfigurationValues {
113105 [ index : string ] : any ;
114106}
115107
116- function validateTypesAndNames (
117- pristineOptions : LDOptions ,
118- values : ConfigurationValues ,
119- _logger : LDLogger ,
120- ) : string [ ] {
108+ export function createConfiguration (
109+ pristineOptions : LDOptions = { } ,
110+ internalOptions : LDClientInternalOptions = {
111+ getImplementationHooks : ( ) => [ ] ,
112+ credentialType : 'mobileKey' ,
113+ } ,
114+ ) : Configuration {
115+ // Ensures that the logger is a SafeLogger.
116+ // This should account for the case where the logger is not defined.
117+ const logger =
118+ pristineOptions . logger instanceof SafeLogger
119+ ? pristineOptions . logger
120+ : createSafeLogger ( pristineOptions . logger ) ;
121+
122+ const values : ConfigurationValues = {
123+ logger,
124+ baseUri : DEFAULT_POLLING ,
125+ eventsUri : ServiceEndpoints . DEFAULT_EVENTS ,
126+ streamUri : DEFAULT_STREAM ,
127+ maxCachedContexts : 5 ,
128+ capacity : 100 ,
129+ diagnosticRecordingInterval : 900 ,
130+ flushInterval : 30 ,
131+ streamInitialReconnectDelay : 1 ,
132+ allAttributesPrivate : false ,
133+ debug : false ,
134+ diagnosticOptOut : false ,
135+ sendEvents : true ,
136+ sendLDHeaders : true ,
137+ useReport : false ,
138+ withReasons : false ,
139+ privateAttributes : [ ] ,
140+ pollInterval : DEFAULT_POLLING_INTERVAL ,
141+ hooks : [ ] ,
142+ inspectors : [ ] ,
143+ } ;
144+
121145 const errors : string [ ] = [ ] ;
122146
123147 Object . entries ( pristineOptions ) . forEach ( ( [ k , v ] ) => {
@@ -158,42 +182,6 @@ function validateTypesAndNames(
158182 }
159183 } ) ;
160184
161- return errors ;
162- }
163-
164- export function createConfiguration (
165- pristineOptions : LDOptions = { } ,
166- internalOptions : LDClientInternalOptions = {
167- getImplementationHooks : ( ) => [ ] ,
168- credentialType : 'mobileKey' ,
169- } ,
170- ) : Configuration {
171- const logger = ensureSafeLogger ( pristineOptions . logger ) ;
172-
173- const values : ConfigurationValues = {
174- logger,
175- baseUri : DEFAULT_POLLING ,
176- eventsUri : ServiceEndpoints . DEFAULT_EVENTS ,
177- streamUri : DEFAULT_STREAM ,
178- maxCachedContexts : 5 ,
179- capacity : 100 ,
180- diagnosticRecordingInterval : 900 ,
181- flushInterval : 30 ,
182- streamInitialReconnectDelay : 1 ,
183- allAttributesPrivate : false ,
184- debug : false ,
185- diagnosticOptOut : false ,
186- sendEvents : true ,
187- sendLDHeaders : true ,
188- useReport : false ,
189- withReasons : false ,
190- privateAttributes : [ ] ,
191- pollInterval : DEFAULT_POLLING_INTERVAL ,
192- hooks : [ ] ,
193- inspectors : [ ] ,
194- } ;
195-
196- const errors = validateTypesAndNames ( pristineOptions , values , logger ) ;
197185 errors . forEach ( ( e : string ) => logger . warn ( e ) ) ;
198186
199187 const serviceEndpoints = new ServiceEndpoints (
@@ -213,35 +201,13 @@ export function createConfiguration(
213201 const { credentialType, getImplementationHooks } = internalOptions ;
214202
215203 return {
216- logger,
217- maxCachedContexts : values . maxCachedContexts ,
218- capacity : values . capacity ,
219- diagnosticRecordingInterval : values . diagnosticRecordingInterval ,
220- flushInterval : values . flushInterval ,
221- streamInitialReconnectDelay : values . streamInitialReconnectDelay ,
222- allAttributesPrivate : values . allAttributesPrivate ,
223- debug : values . debug ,
224- diagnosticOptOut : values . diagnosticOptOut ,
225- sendEvents : values . sendEvents ,
226- sendLDHeaders : values . sendLDHeaders ,
227- useReport,
228- withReasons : values . withReasons ,
229- privateAttributes : values . privateAttributes ,
230- tags,
231- applicationInfo : values . applicationInfo ,
232- bootstrap : values . bootstrap ,
233- requestHeaderTransform : values . requestHeaderTransform ,
234- stream : values . stream ,
235- hash : values . hash ,
236- wrapperName : values . wrapperName ,
237- wrapperVersion : values . wrapperVersion ,
204+ ...values ,
238205 serviceEndpoints,
239- pollInterval : values . pollInterval ,
206+ tags ,
240207 userAgentHeaderName,
241208 trackEventModifier,
242- hooks : values . hooks ,
243- inspectors : values . inspectors ,
244209 credentialType,
245210 getImplementationHooks,
211+ useReport,
246212 } ;
247213}
0 commit comments