Skip to content

Commit 96cc209

Browse files
authored
Merge branch 'master' into fayyaz/replace_lodash_isFinite
2 parents 39a5ee4 + 037f466 commit 96cc209

File tree

16 files changed

+88
-50
lines changed

16 files changed

+88
-50
lines changed

packages/optimizely-sdk/CHANGELOG.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [3.5.0] - February 20th, 2020
10+
811
### Bug fixes
912
- Fixed default event dispatcher not used in React Native entry point ([#383](https://github.com/optimizely/javascript-sdk/pull/383))
13+
- Fixed errors in `getOptimizelyConfig` TypeScript type definitions ([#406](https://github.com/optimizely/javascript-sdk/pull/406))
1014

1115
### New Features
1216
- Promise returned from `close` tracks the state of in-flight event dispatcher requests ([#404](https://github.com/optimizely/javascript-sdk/pull/404))

packages/optimizely-sdk/lib/core/decision_service/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ DecisionService.prototype.__checkIfExperimentIsActive = function(configObj, expe
144144
* @return {string|null} Forced variation if it exists for user ID, otherwise null
145145
*/
146146
DecisionService.prototype.__getWhitelistedVariation = function(experiment, userId) {
147-
if (!fns.isEmpty(experiment.forcedVariations) && experiment.forcedVariations.hasOwnProperty(userId)) {
147+
if (experiment.forcedVariations && experiment.forcedVariations.hasOwnProperty(userId)) {
148148
var forcedVariationKey = experiment.forcedVariations[userId];
149149
if (experiment.variationKeyMap.hasOwnProperty(forcedVariationKey)) {
150150
var forcedBucketingSucceededMessageLog = sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, MODULE_NAME, userId, forcedVariationKey);

packages/optimizely-sdk/lib/core/notification_center/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
var enums = require('../../utils/enums');
1818
var fns = require('../../utils/fns');
19-
var sprintf = require('@optimizely/js-sdk-utils').sprintf;
19+
var jsSdkUtils = require('@optimizely/js-sdk-utils');
2020

2121
var LOG_LEVEL = enums.LOG_LEVEL;
2222
var LOG_MESSAGES = enums.LOG_MESSAGES;
@@ -55,7 +55,7 @@ function NotificationCenter(options) {
5555
*/
5656
NotificationCenter.prototype.addNotificationListener = function (notificationType, callback) {
5757
try {
58-
var isNotificationTypeValid = fns.values(enums.NOTIFICATION_TYPES)
58+
var isNotificationTypeValid = jsSdkUtils.objectValues(enums.NOTIFICATION_TYPES)
5959
.indexOf(notificationType) > -1;
6060
if (!isNotificationTypeValid) {
6161
return -1;
@@ -165,7 +165,7 @@ NotificationCenter.prototype.sendNotifications = function (notificationType, not
165165
try {
166166
callback(notificationData);
167167
} catch (ex) {
168-
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.NOTIFICATION_LISTENER_EXCEPTION, MODULE_NAME, notificationType, ex.message));
168+
this.logger.log(LOG_LEVEL.ERROR, jsSdkUtils.sprintf(LOG_MESSAGES.NOTIFICATION_LISTENER_EXCEPTION, MODULE_NAME, notificationType, ex.message));
169169
}
170170
}.bind(this));
171171
} catch (e) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ module.exports = {
122122
*/
123123
getExperimentId: function(projectConfig, experimentKey) {
124124
var experiment = projectConfig.experimentKeyMap[experimentKey];
125-
if (fns.isEmpty(experiment)) {
125+
if (!experiment) {
126126
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
127127
}
128128
return experiment.id;
@@ -137,7 +137,7 @@ module.exports = {
137137
*/
138138
getLayerId: function(projectConfig, experimentId) {
139139
var experiment = projectConfig.experimentIdMap[experimentId];
140-
if (fns.isEmpty(experiment)) {
140+
if (!experiment) {
141141
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_ID, MODULE_NAME, experimentId));
142142
}
143143
return experiment.layerId;
@@ -190,7 +190,7 @@ module.exports = {
190190
*/
191191
getExperimentStatus: function(projectConfig, experimentKey) {
192192
var experiment = projectConfig.experimentKeyMap[experimentKey];
193-
if (fns.isEmpty(experiment)) {
193+
if (!experiment) {
194194
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
195195
}
196196
return experiment.status;
@@ -224,7 +224,7 @@ module.exports = {
224224
*/
225225
getExperimentAudienceConditions: function(projectConfig, experimentKey) {
226226
var experiment = projectConfig.experimentKeyMap[experimentKey];
227-
if (fns.isEmpty(experiment)) {
227+
if (!experiment) {
228228
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
229229
}
230230

@@ -286,7 +286,7 @@ module.exports = {
286286
*/
287287
getTrafficAllocation: function(projectConfig, experimentKey) {
288288
var experiment = projectConfig.experimentKeyMap[experimentKey];
289-
if (fns.isEmpty(experiment)) {
289+
if (!experiment) {
290290
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
291291
}
292292
return experiment.trafficAllocation;

packages/optimizely-sdk/lib/index.browser.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('javascript-sdk', function() {
148148
optlyInstance.onReady().catch(function() {});
149149

150150
assert.instanceOf(optlyInstance, Optimizely);
151-
assert.equal(optlyInstance.clientVersion, '3.4.1');
151+
assert.equal(optlyInstance.clientVersion, '3.5.0');
152152
});
153153

154154
it('should set the JavaScript client engine and version', function() {

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

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ declare module "@optimizely/optimizely-sdk" {
115115
onReady(options?: {
116116
timeout?: number;
117117
}): Promise<{ success: boolean; reason?: string }>;
118-
close(): void;
118+
close(): Promise<{ success: boolean; reason?: string }>;
119119
}
120120

121121
// An event to be submitted to Optimizely, enabling tracking the reach and impact of
@@ -225,53 +225,41 @@ declare module "@optimizely/optimizely-sdk" {
225225
type: string;
226226
value: string;
227227
}
228-
228+
229229
export interface OptimizelyVariation {
230230
id: string;
231231
key: string;
232232
featureEnabled?: boolean;
233233
variablesMap: {
234-
[variableKey: string]: {
235-
variable: OptimizelyVariable;
236-
};
234+
[variableKey: string]: OptimizelyVariable;
237235
};
238236
}
239237

240238
export interface OptimizelyExperiment {
241239
id: string;
242240
key: string;
243241
variationsMap: {
244-
[variationKey: string]: {
245-
variation: OptimizelyVariation;
246-
};
242+
[variationKey: string]: OptimizelyVariation;
247243
};
248244
}
249245

250246
export interface OptimizelyFeature {
251247
id: string;
252248
key: string;
253249
experimentsMap: {
254-
[experimentKey: string]: {
255-
experiment: OptimizelyExperiment;
256-
};
250+
[experimentKey: string]: OptimizelyExperiment;
257251
};
258252
variablesMap: {
259-
[variableKey: string]: {
260-
variable: OptimizelyVariable;
261-
};
253+
[variableKey: string]: OptimizelyVariable;
262254
};
263255
}
264256

265257
export interface OptimizelyConfig {
266258
experimentsMap: {
267-
[experimentKey: string]: {
268-
experiment: OptimizelyExperiment;
269-
};
259+
[experimentKey: string]: OptimizelyExperiment;
270260
};
271261
featuresMap: {
272-
[featureKey: string]: {
273-
feature: OptimizelyFeature;
274-
};
262+
[featureKey: string]: OptimizelyFeature;
275263
};
276264
revision: string;
277265
}

packages/optimizely-sdk/lib/index.node.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('optimizelyFactory', function() {
9292
optlyInstance.onReady().catch(function() {});
9393

9494
assert.instanceOf(optlyInstance, Optimizely);
95-
assert.equal(optlyInstance.clientVersion, '3.4.1');
95+
assert.equal(optlyInstance.clientVersion, '3.5.0');
9696
});
9797

9898
describe('event processor configuration', function() {

packages/optimizely-sdk/lib/index.react_native.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('javascript-sdk/react-native', function() {
9292
optlyInstance.onReady().catch(function() {});
9393

9494
assert.instanceOf(optlyInstance, Optimizely);
95-
assert.equal(optlyInstance.clientVersion, '3.4.1');
95+
assert.equal(optlyInstance.clientVersion, '3.5.0');
9696
});
9797

9898
it('should set the JavaScript client engine and version', function() {

packages/optimizely-sdk/lib/optimizely/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes)
375375
}
376376

377377
var experiment = configObj.experimentKeyMap[experimentKey];
378-
if (fns.isEmpty(experiment)) {
378+
if (!experiment) {
379379
this.logger.log(LOG_LEVEL.DEBUG, sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
380380
return null;
381381
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var fns = require('../../utils/fns');
17-
1816
var POST_METHOD = 'POST';
1917
var GET_METHOD = 'GET';
2018
var READYSTATE_COMPLETE = 4;
@@ -68,7 +66,7 @@ module.exports = {
6866
};
6967

7068
var toQueryString = function(obj) {
71-
return fns.map(obj, function(v, k) {
72-
return encodeURIComponent(k) + '=' + encodeURIComponent(v);
69+
return Object.keys(obj).map(function(k) {
70+
return encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]);
7371
}).join('&');
7472
};

0 commit comments

Comments
 (0)