1
1
/**
2
- * Copyright 2019-2023 , Optimizely
2
+ * Copyright 2019-2024 , Optimizely
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- import {
17
- getLogger ,
18
- setErrorHandler ,
19
- getErrorHandler ,
20
- LogLevel ,
21
- setLogHandler ,
22
- setLogLevel
23
- } from './modules/logging' ;
16
+
17
+ import { getLogger , setErrorHandler , getErrorHandler , LogLevel , setLogHandler , setLogLevel } from './modules/logging' ;
24
18
import * as enums from './utils/enums' ;
25
19
import Optimizely from './optimizely' ;
26
20
import configValidator from './utils/config_validator' ;
@@ -31,8 +25,7 @@ import eventProcessorConfigValidator from './utils/event_processor_config_valida
31
25
import { createNotificationCenter } from './core/notification_center' ;
32
26
import { createEventProcessor } from './plugins/event_processor/index.react_native' ;
33
27
import { OptimizelyDecideOption , Client , Config } from './shared_types' ;
34
- import { createHttpPollingDatafileManager } from
35
- './plugins/datafile_manager/react_native_http_polling_datafile_manager' ;
28
+ import { createHttpPollingDatafileManager } from './plugins/datafile_manager/react_native_http_polling_datafile_manager' ;
36
29
import { BrowserOdpManager } from './plugins/odp_manager/index.browser' ;
37
30
import * as commonExports from './common_exports' ;
38
31
@@ -71,7 +64,7 @@ const createInstance = function(config: Config): Client | null {
71
64
configValidator . validate ( config ) ;
72
65
isValidInstance = true ;
73
66
// eslint-disable-next-line @typescript-eslint/no-explicit-any
74
- } catch ( ex : any ) {
67
+ } catch ( ex ) {
75
68
logger . error ( ex ) ;
76
69
}
77
70
@@ -100,20 +93,27 @@ const createInstance = function(config: Config): Client | null {
100
93
batchSize : eventBatchSize ,
101
94
maxQueueSize : config . eventMaxQueueSize || DEFAULT_EVENT_MAX_QUEUE_SIZE ,
102
95
notificationCenter,
103
- }
96
+ } ;
104
97
105
98
const eventProcessor = createEventProcessor ( eventProcessorConfig ) ;
106
99
100
+ const odpExplicitlyOff = config . odpOptions ?. disabled === true ;
101
+ if ( odpExplicitlyOff ) {
102
+ logger . info ( enums . LOG_MESSAGES . ODP_DISABLED ) ;
103
+ }
104
+
107
105
const optimizelyOptions = {
108
106
clientEngine : enums . REACT_NATIVE_JS_CLIENT_ENGINE ,
109
107
...config ,
110
108
eventProcessor,
111
109
logger,
112
110
errorHandler,
113
- datafileManager : config . sdkKey ? createHttpPollingDatafileManager ( config . sdkKey , logger , config . datafile , config . datafileOptions ) : undefined ,
111
+ datafileManager : config . sdkKey
112
+ ? createHttpPollingDatafileManager ( config . sdkKey , logger , config . datafile , config . datafileOptions )
113
+ : undefined ,
114
114
notificationCenter,
115
- isValidInstance : isValidInstance ,
116
- odpManager : new BrowserOdpManager ( { logger, odpOptions : config . odpOptions } ) ,
115
+ isValidInstance,
116
+ odpManager : odpExplicitlyOff ? undefined : new BrowserOdpManager ( { logger, odpOptions : config . odpOptions } ) ,
117
117
} ;
118
118
119
119
// If client engine is react, convert it to react native.
@@ -123,7 +123,7 @@ const createInstance = function(config: Config): Client | null {
123
123
124
124
return new Optimizely ( optimizelyOptions ) ;
125
125
// eslint-disable-next-line @typescript-eslint/no-explicit-any
126
- } catch ( e : any ) {
126
+ } catch ( e ) {
127
127
logger . error ( e ) ;
128
128
return null ;
129
129
}
@@ -157,4 +157,4 @@ export default {
157
157
OptimizelyDecideOption,
158
158
} ;
159
159
160
- export * from './export_types'
160
+ export * from './export_types' ;
0 commit comments