1
- import EventEmitter from 'events' ;
2
- import PollingProcessor from "../processor/pollingProcessor.js" ;
3
- import OfflineProcessor from "../processor/offlineProcessor.js" ;
4
- import EventProcessor from "../events/eventProcessor.js" ;
5
- import OfflineEventProcessor from "../events/offlineEventProcessor.js" ;
6
- import EventsCache from "../storage/eventsCache/InMemory.js" ;
7
- import CountCache from "../storage/countCache/InMemory.js" ;
8
- import { evaluate } from '../engine/evaluator.js' ;
9
- import { isObject } from "../../src/utils/lang/index.js" ;
10
- import UlFeature from "../dtos/UlFeature.js" ;
11
- import Impression from "../dtos/Impression.js" ;
12
- import { READY } from '../utils/store/constants.js' ;
1
+ const EventEmitter = require ( 'events' )
2
+ const PollingProcessor = require ( "../processor/pollingProcessor.js" )
3
+ const OfflineProcessor = require ( "../processor/offlineProcessor.js" )
4
+ const EventProcessor = require ( "../events/eventProcessor.js" )
5
+ const OfflineEventProcessor = require ( "../events/offlineEventProcessor.js" )
6
+ const EventsCache = require ( "../storage/eventsCache/InMemory.js" )
7
+ const CountCache = require ( "../storage/countCache/InMemory.js" )
8
+ const { evaluate } = require ( '../engine/evaluator.js' )
9
+ const { isObject } = require ( "../../src/utils/lang/index.js" )
10
+ const UlFeature = require ( "../dtos/UlFeature.js" )
11
+ const Impression = require ( "../dtos/Impression.js" )
12
+ const { READY } = require ( '../utils/store/constants.js' )
13
13
14
14
/**
15
15
* Unlaunch Client
16
16
**/
17
- export function ulClient ( configs , store ) {
17
+ const ulClient = ( configs , store ) => {
18
18
19
19
const newUnlaunchClient = function ( ) {
20
20
const client = new EventEmitter ( ) ;
@@ -79,7 +79,7 @@ export function ulClient(configs, store) {
79
79
const isReady = store . get ( READY ) ;
80
80
81
81
if ( flagKey == undefined || flagKey . length <= 0 ) {
82
- configs . logger . error ( 'Please provide valid flagKey' ) ;
82
+ configs . logger . error ( 'error: [Unlaunch] Please provide valid flagKey' ) ;
83
83
return new UlFeature (
84
84
"control" ,
85
85
"Feature flag key was empty" ,
@@ -88,7 +88,7 @@ export function ulClient(configs, store) {
88
88
}
89
89
90
90
if ( identity == undefined || identity . length <= 0 ) {
91
- configs . logger . error ( 'Please provide valid identity' )
91
+ configs . logger . error ( 'error: [Unlaunch] Please provide valid identity' )
92
92
return new UlFeature (
93
93
"control" ,
94
94
"Identity was empty" ,
@@ -97,7 +97,7 @@ export function ulClient(configs, store) {
97
97
}
98
98
99
99
if ( attributes && Object . keys ( attributes ) . length > 0 && ! isObject ( attributes ) ) {
100
- configs . logger . error ( 'Please provide valid Unlaunch attributes' )
100
+ configs . logger . error ( 'error: [Unlaunch] Please provide valid Unlaunch attributes' )
101
101
return new UlFeature (
102
102
"control" ,
103
103
"Invalid Unlaunch attribute(s)" ,
@@ -106,7 +106,7 @@ export function ulClient(configs, store) {
106
106
}
107
107
108
108
if ( offlineMode ) {
109
- configs . logger . info ( 'Offline mode selected - control served' )
109
+ configs . logger . info ( 'info: [Unlaunch] Offline mode selected - control served' )
110
110
return new UlFeature (
111
111
"control" ,
112
112
"Offline mode selected - control served" ,
@@ -115,7 +115,7 @@ export function ulClient(configs, store) {
115
115
}
116
116
117
117
if ( ! isReady ) {
118
- configs . logger . warn ( "The SDK is not ready. Returning the SDK default 'control' " +
118
+ configs . logger . warn ( "warn: [Unlaunch] The SDK is not ready. Returning the SDK default 'control' " +
119
119
"as variation which may not give " +
120
120
"the right result" ) ;
121
121
return new UlFeature (
@@ -153,7 +153,7 @@ export function ulClient(configs, store) {
153
153
154
154
return ulFeature ;
155
155
} else {
156
- configs . logger . error ( `Error flag with flagKey ${ flagKey } not found` ) ;
156
+ configs . logger . error ( `error: [Unlaunch] Error flag with flagKey ${ flagKey } not found` ) ;
157
157
return new UlFeature (
158
158
"control" ,
159
159
"Feature flag was not found in memory" ,
@@ -178,4 +178,5 @@ export function ulClient(configs, store) {
178
178
return {
179
179
client : newUnlaunchClient
180
180
}
181
- }
181
+ }
182
+ module . exports = { ulClient}
0 commit comments