Skip to content

Commit 10fcd43

Browse files
committed
comments addressed
1 parent b1a6e11 commit 10fcd43

File tree

10 files changed

+42
-22
lines changed

10 files changed

+42
-22
lines changed

packages/optimizely-sdk/lib/core/project_config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2021, Optimizely
2+
* Copyright 2016-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

packages/optimizely-sdk/lib/core/project_config/project_config_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019-2021, Optimizely
2+
* Copyright 2019-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

packages/optimizely-sdk/lib/export_types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2022, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
export {
217
UserAttributes,
318
OptimizelyConfig,

packages/optimizely-sdk/lib/index.browser.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017, 2019-2020 Optimizely
2+
* Copyright 2016-2017, 2019-2022 Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,6 +54,8 @@ let hasRetriedEvents = false;
5454
const createInstance = function(config: Config): Client | null {
5555
try {
5656
// TODO warn about setting per instance errorHandler / logger / logLevel
57+
let isValidInstance = false
58+
5759
if (config.errorHandler) {
5860
setErrorHandler(config.errorHandler);
5961
}
@@ -68,10 +70,9 @@ const createInstance = function(config: Config): Client | null {
6870

6971
try {
7072
configValidator.validate(config);
71-
config.isValidInstance = true;
73+
isValidInstance = true;
7274
} catch (ex) {
7375
logger.error(ex);
74-
config.isValidInstance = false;
7576
}
7677

7778
let eventDispatcher;
@@ -125,7 +126,7 @@ const createInstance = function(config: Config): Client | null {
125126
errorHandler,
126127
datafileManager: config.sdkKey ? createHttpPollingDatafileManager(config.sdkKey, logger, config.datafile, config.datafileOptions) : undefined,
127128
notificationCenter,
128-
isValidInstance: config.isValidInstance
129+
isValidInstance: isValidInstance
129130
};
130131

131132
const optimizely = new Optimizely(optimizelyOptions);

packages/optimizely-sdk/lib/index.lite.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021, Optimizely
2+
* Copyright 2021-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,6 +46,8 @@ setLogLevel(LogLevel.ERROR);
4646
try {
4747

4848
// TODO warn about setting per instance errorHandler / logger / logLevel
49+
let isValidInstance = false;
50+
4951
if (config.errorHandler) {
5052
setErrorHandler(config.errorHandler);
5153
}
@@ -60,10 +62,9 @@ setLogLevel(LogLevel.ERROR);
6062

6163
try {
6264
configValidator.validate(config);
63-
config.isValidInstance = true;
65+
isValidInstance = true;
6466
} catch (ex) {
6567
logger.error(ex);
66-
config.isValidInstance = false;
6768
}
6869

6970
const errorHandler = getErrorHandler();
@@ -79,7 +80,7 @@ setLogLevel(LogLevel.ERROR);
7980
datafileManager: createNoOpDatafileManager(),
8081
eventProcessor,
8182
notificationCenter,
82-
isValidInstance: config.isValidInstance,
83+
isValidInstance: isValidInstance,
8384
};
8485

8586
const optimizely = new Optimizely(optimizelyOptions);

packages/optimizely-sdk/lib/index.node.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2016-2017, 2019-2021 Optimizely, Inc. and contributors *
2+
* Copyright 2016-2017, 2019-2022 Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -49,6 +49,7 @@ const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
4949
const createInstance = function(config: Config): Client | null {
5050
try {
5151
let hasLogger = false;
52+
let isValidInstance = false;
5253

5354
// TODO warn about setting per instance errorHandler / logger / logLevel
5455
if (config.errorHandler) {
@@ -66,14 +67,13 @@ const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
6667
}
6768
try {
6869
configValidator.validate(config);
69-
config.isValidInstance = true;
70+
isValidInstance = true;
7071
} catch (ex) {
7172
if (hasLogger) {
7273
logger.error(ex);
7374
} else {
7475
console.error(ex.message);
7576
}
76-
config.isValidInstance = false;
7777
}
7878

7979
let eventBatchSize = config.eventBatchSize;
@@ -113,7 +113,7 @@ const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
113113
errorHandler,
114114
datafileManager: config.sdkKey ? createHttpPollingDatafileManager(config.sdkKey, logger, config.datafile, config.datafileOptions) : undefined,
115115
notificationCenter,
116-
isValidInstance: config.isValidInstance,
116+
isValidInstance: isValidInstance,
117117
};
118118

119119
return new Optimizely(optimizelyOptions);

packages/optimizely-sdk/lib/index.react_native.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019-2021 Optimizely
2+
* Copyright 2019-2022 Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,6 +50,8 @@ const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
5050
const createInstance = function(config: Config): Client | null {
5151
try {
5252
// TODO warn about setting per instance errorHandler / logger / logLevel
53+
let isValidInstance = false;
54+
5355
if (config.errorHandler) {
5456
setErrorHandler(config.errorHandler);
5557
}
@@ -64,10 +66,9 @@ const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
6466

6567
try {
6668
configValidator.validate(config);
67-
config.isValidInstance = true;
69+
isValidInstance = true;
6870
} catch (ex) {
6971
logger.error(ex);
70-
config.isValidInstance = false;
7172
}
7273

7374
let eventBatchSize = config.eventBatchSize;
@@ -107,7 +108,7 @@ const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
107108
errorHandler,
108109
datafileManager: config.sdkKey ? createHttpPollingDatafileManager(config.sdkKey, logger, config.datafile, config.datafileOptions) : undefined,
109110
notificationCenter,
110-
isValidInstance: config.isValidInstance,
111+
isValidInstance: isValidInstance,
111112
};
112113

113114
// If client engine is react, convert it to react native.

packages/optimizely-sdk/lib/plugins/datafile_manager/http_polling_datafile_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021, Optimizely
2+
* Copyright 2021-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

packages/optimizely-sdk/lib/plugins/event_dispatcher/index.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2017, 2020-2021, Optimizely
2+
* Copyright 2016-2017, 2020-2022, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

packages/optimizely-sdk/lib/shared_types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,10 @@ export interface TrackListenerPayload extends ListenerPayload {
398398
errorHandler?: ErrorHandler;
399399
// event dispatcher function
400400
eventDispatcher?: EventDispatcher;
401-
// flag to validate if this instance is valid
402-
isValidInstance?: boolean;
401+
// The object to validate against the schema
402+
jsonSchemaValidator?: {
403+
validate(jsonObject: unknown): boolean,
404+
};
403405
// level of logging i.e debug, info, error, warning etc
404406
logLevel?: LogLevel | string;
405407
// LogHandler object for logging

0 commit comments

Comments
 (0)