Skip to content

Commit ec5a0ea

Browse files
alibaker-optimizelymjc1283
authored andcommitted
refact: Deprecate launched status check (#385)
- Remove 'Launched' status check from isActive - Change associated tests - Change associated log message
1 parent 728c7c0 commit ec5a0ea

File tree

5 files changed

+6
-19
lines changed

5 files changed

+6
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ DecisionService.prototype.__resolveExperimentBucketMap = function(userId, attrib
121121

122122

123123
/**
124-
* Checks whether the experiment is running or launched
124+
* Checks whether the experiment is running
125125
* @param {Object} configObj The parsed project configuration object
126126
* @param {string} experimentKey Key of experiment being validated
127127
* @param {string} userId ID of user

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var sprintf = require('@optimizely/js-sdk-utils').sprintf;
1919
var configValidator = require('../../utils/config_validator');
2020
var projectConfigSchema = require('./project_config_schema');
2121

22-
var EXPERIMENT_LAUNCHED_STATUS = 'Launched';
2322
var EXPERIMENT_RUNNING_STATUS = 'Running';
2423
var RESERVED_ATTRIBUTE_PREFIX = '$opt_';
2524
var MODULE_NAME = 'PROJECT_CONFIG';
@@ -198,14 +197,13 @@ module.exports = {
198197
},
199198

200199
/**
201-
* Returns whether experiment has a status of 'Running' or 'Launched'
200+
* Returns whether experiment has a status of 'Running'
202201
* @param {Object} projectConfig Object representing project configuration
203202
* @param {string} experimentKey Experiment key for which status is to be compared with 'Running'
204203
* @return {Boolean} true if experiment status is set to 'Running', false otherwise
205204
*/
206205
isActive: function(projectConfig, experimentKey) {
207-
return module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_RUNNING_STATUS ||
208-
module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_LAUNCHED_STATUS;
206+
return module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_RUNNING_STATUS;
209207
},
210208

211209
/**

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,11 @@ describe('lib/core/project_config', function() {
305305
}, sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, 'PROJECT_CONFIG', 'invalidExperimentKey'));
306306
});
307307

308-
it('should return true if experiment status is set to Running or Launch in isActive', function() {
308+
it('should return true if experiment status is set to Running in isActive', function() {
309309
assert.isTrue(projectConfig.isActive(configObj, 'testExperiment'));
310-
311-
assert.isTrue(projectConfig.isActive(configObj, 'testExperimentLaunched'));
312310
});
313311

314-
it('should return true if experiment status is set to Running or Launch in isActive', function() {
312+
it('should return false if experiment status is not set to Running in isActive', function() {
315313
assert.isFalse(projectConfig.isActive(configObj, 'testExperimentNotRunning'));
316314
});
317315

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -786,15 +786,6 @@ describe('lib/optimizely', function() {
786786
});
787787
});
788788

789-
it('returns the variation key but does not dispatch the event if user is in experiment and experiment is set to Launched', function() {
790-
bucketStub.returns('144448');
791-
792-
var bucketedVariation = optlyInstance.activate('testExperimentLaunched', 'testUser');
793-
assert.strictEqual(bucketedVariation, 'controlLaunched');
794-
795-
sinon.assert.notCalled(eventDispatcher.dispatchEvent);
796-
});
797-
798789
it('should not activate when optimizely object is not a valid instance', function() {
799790
var instance = new Optimizely({
800791
datafile: {},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exports.LOG_MESSAGES = {
9292
ROLLOUT_HAS_NO_EXPERIMENTS: '%s: Rollout of feature %s has no experiments',
9393
SAVED_VARIATION: '%s: Saved variation "%s" of experiment "%s" for user "%s".',
9494
SAVED_VARIATION_NOT_FOUND: '%s: User %s was previously bucketed into variation with ID %s for experiment %s, but no matching variation was found.',
95-
SHOULD_NOT_DISPATCH_ACTIVATE: '%s: Experiment %s is in "Launched" state. Not activating user.',
95+
SHOULD_NOT_DISPATCH_ACTIVATE: '%s: Experiment %s is not in "Running" state. Not activating user.',
9696
SKIPPING_JSON_VALIDATION: '%s: Skipping JSON schema validation.',
9797
TRACK_EVENT: '%s: Tracking event %s for user %s.',
9898
USER_ASSIGNED_TO_VARIATION_BUCKET: '%s: Assigned variation bucket %s to user %s.',

0 commit comments

Comments
 (0)