Skip to content

Commit e1976ef

Browse files
author
Matt Carroll
committed
Merge branch 'master' into mcarroll/optimizely-sdk-typescript
2 parents 1923e00 + 8b4211e commit e1976ef

File tree

11 files changed

+102
-73
lines changed

11 files changed

+102
-73
lines changed

.travis.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ jobs:
4242
notifications:
4343
email: false
4444

45-
- stage: 'Lint markdown files'
46-
os: linux
47-
language: generic
48-
before_install: skip
49-
install:
50-
- npm i -g markdown-spellcheck
51-
before_script:
52-
- wget --quiet https://raw.githubusercontent.com/optimizely/mdspell-config/master/.spelling
53-
script:
54-
- mdspell -a -n -r --en-us '**/*.md'
55-
after_success: skip
56-
5745
- stage: 'Lint'
5846
node_js: '12'
5947
script: npm run lint
@@ -72,10 +60,6 @@ jobs:
7260
- CLIENT=node $HOME/travisci-tools/trigger-script-with-status-update.sh
7361
- CLIENT=browser $HOME/travisci-tools/trigger-script-with-status-update.sh
7462
after_success: travis_terminate 0
75-
- <<: *integrationtest
76-
script:
77-
- CLIENT=react-native-android REPO_SLUG=optimizely/react-native-testapp $HOME/travisci-tools/trigger-script-with-status-update.sh
78-
- CLIENT=react-native-ios REPO_SLUG=optimizely/react-native-testapp $HOME/travisci-tools/trigger-script-with-status-update.sh
7963
- stage: Cross-browser and umd unit tests
8064
node_js: '8'
8165
script: npm run test-ci

packages/optimizely-sdk/CHANGELOG.MD

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
## [4.1.0] - July 7, 2020
11+
12+
### New Features
13+
14+
- Added support for JSON feature variables: new methods `getFeatureVariableJSON` and `getAllFeatureVariables` ([#467](https://github.com/optimizely/javascript-sdk/pull/467), [#470](https://github.com/optimizely/javascript-sdk/pull/470))
15+
- Added support for authenticated datafiles when running in Node.js. Pass `datafileAccessToken` within `datafileOptions` to request an authenticated datafile using the token ([#498](https://github.com/optimizely/javascript-sdk/pull/498), [#502](https://github.com/optimizely/javascript-sdk/pull/502)):
16+
```js
17+
const optimizelySDK = require('@optimizely/optimizely-sdk');
18+
var optimizelyClientInstance = optimizely.createInstance({
19+
sdkKey: '<Your SDK key>',
20+
datafileOptions: {
21+
datafileAccessToken: '<Your datafile access token>',
22+
}
23+
});
24+
```
25+
26+
### Bug fixes
27+
28+
- Fixed audience evaluation log level: changed from `INFO` to `DEBUG` ([#496](https://github.com/optimizely/javascript-sdk/pull/496))
29+
- Temporarily disabled React Native FSC tests ([#514](https://github.com/optimizely/javascript-sdk/pull/514))
30+
- Changed `getFeatureVariableJson` to `getFeatureVariableJSON` ([#516](https://github.com/optimizely/javascript-sdk/pull/516))
31+
1032
## [4.1.0-beta] - June 16, 2020
1133

1234
### New Features
13-
- Added support for JSON feature variables: new methods `getFeatureVariableJson` and `getAllFeatureVariables` ([#467](https://github.com/optimizely/javascript-sdk/pull/467), [#470](https://github.com/optimizely/javascript-sdk/pull/470))
35+
36+
- Added support for JSON feature variables: new methods `getFeatureVariableJSON` and `getAllFeatureVariables` ([#467](https://github.com/optimizely/javascript-sdk/pull/467), [#470](https://github.com/optimizely/javascript-sdk/pull/470))
1437
- Added support for authenticated datafiles when running in Node.js. Pass `datafileAccessToken` within `datafileOptions` to request an authenticated datafile using the token ([#498](https://github.com/optimizely/javascript-sdk/pull/498), [#502](https://github.com/optimizely/javascript-sdk/pull/502)):
1538
```js
1639
const optimizelySDK = require('@optimizely/optimizely-sdk');
@@ -23,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2346
```
2447

2548
### Bug fixes
49+
2650
- Fixed audience evaluation log level: changed from `INFO` to `DEBUG` ([#496](https://github.com/optimizely/javascript-sdk/pull/496))
2751

2852
## [4.0.0] - April 30, 2020
@@ -59,22 +83,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5983
## [4.0.0-rc.2] - April 24, 2020
6084

6185
### Bug fixes
86+
6287
- Allow multiple instances to be created from the same datafile object ([#462](https://github.com/optimizely/javascript-sdk/pull/462))
6388

6489
## [4.0.0-rc.1] - April 17, 2020
6590

6691
### New Features
92+
6793
- ES module entry point for the browser - `"module"` property of `package.json` points to `dist/optimizely.browser.es.min.js` ([#445](https://github.com/optimizely/javascript-sdk/pull/445))
6894

6995
### Breaking Changes:
96+
7097
- Dropped support for Node.js version <8 ([#456](https://github.com/optimizely/javascript-sdk/pull/456))
7198

7299
### Bug fixes
100+
73101
- Node.js datafile manager uses gzip,deflate compression for requests ([#456](https://github.com/optimizely/javascript-sdk/pull/456))
74102

75103
## [4.0.0-alpha.1] - March 4, 2020
76104

77105
### Breaking Changes:
106+
78107
- Removed `Promise` polyfill from browser entry point ([417](https://github.com/optimizely/javascript-sdk/pull/417)).
79108
- Changed functionality of JSON schema validation in all entry points ([442](https://github.com/optimizely/javascript-sdk/pull/442)).
80109
- Previously, `skipJSONValidation` flag was used by the user to specify whether the JSON object should be validated.

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, '4.1.0-beta');
151+
assert.equal(optlyInstance.clientVersion, '4.1.0');
152152
});
153153

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ declare module '@optimizely/optimizely-sdk' {
9595
userId: string,
9696
attributes?: UserAttributes
9797
): string | null;
98-
getFeatureVariableJson(
98+
getFeatureVariableJSON(
9999
featureKey: string,
100100
variableKey: string,
101101
userId: string,

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

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

9292
assert.instanceOf(optlyInstance, Optimizely);
93-
assert.equal(optlyInstance.clientVersion, '4.1.0-beta');
93+
assert.equal(optlyInstance.clientVersion, '4.1.0');
9494
});
9595

9696
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
@@ -89,7 +89,7 @@ describe('javascript-sdk/react-native', function() {
8989
optlyInstance.onReady().catch(function() {});
9090

9191
assert.instanceOf(optlyInstance, Optimizely);
92-
assert.equal(optlyInstance.clientVersion, '4.1.0-beta');
92+
assert.equal(optlyInstance.clientVersion, '4.1.0');
9393
});
9494

9595
it('should set the Javascript client engine and version', function() {

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

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,10 @@ Optimizely.prototype.getEnabledFeatures = function(userId, attributes) {
686686

687687
Optimizely.prototype.getFeatureVariable = function(featureKey, variableKey, userId, attributes) {
688688
try {
689+
if (!this.__isValidInstance()) {
690+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, 'getFeatureVariable'));
691+
return null;
692+
}
689693
return this._getFeatureVariableForType(featureKey, variableKey, null, userId, attributes);
690694
} catch (e) {
691695
this.logger.log(LOG_LEVEL.ERROR, e.message);
@@ -717,14 +721,6 @@ Optimizely.prototype.getFeatureVariable = function(featureKey, variableKey, user
717721
* with the type of the variable
718722
*/
719723
Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableKey, variableType, userId, attributes) {
720-
if (!this.__isValidInstance()) {
721-
var apiName = variableType
722-
? 'getFeatureVariable' + variableType.charAt(0).toUpperCase() + variableType.slice(1)
723-
: 'getFeatureVariable';
724-
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, apiName));
725-
return null;
726-
}
727-
728724
if (!this.__validateInputs({ feature_key: featureKey, variable_key: variableKey, user_id: userId }, attributes)) {
729725
return null;
730726
}
@@ -875,6 +871,10 @@ Optimizely.prototype._getFeatureVariableValueFromVariation = function(featureKey
875871
*/
876872
Optimizely.prototype.getFeatureVariableBoolean = function(featureKey, variableKey, userId, attributes) {
877873
try {
874+
if (!this.__isValidInstance()) {
875+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, 'getFeatureVariableBoolean'));
876+
return null;
877+
}
878878
return this._getFeatureVariableForType(featureKey, variableKey, FEATURE_VARIABLE_TYPES.BOOLEAN, userId, attributes);
879879
} catch (e) {
880880
this.logger.log(LOG_LEVEL.ERROR, e.message);
@@ -899,6 +899,10 @@ Optimizely.prototype.getFeatureVariableBoolean = function(featureKey, variableKe
899899
*/
900900
Optimizely.prototype.getFeatureVariableDouble = function(featureKey, variableKey, userId, attributes) {
901901
try {
902+
if (!this.__isValidInstance()) {
903+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, 'getFeatureVariableDouble'));
904+
return null;
905+
}
902906
return this._getFeatureVariableForType(featureKey, variableKey, FEATURE_VARIABLE_TYPES.DOUBLE, userId, attributes);
903907
} catch (e) {
904908
this.logger.log(LOG_LEVEL.ERROR, e.message);
@@ -923,6 +927,10 @@ Optimizely.prototype.getFeatureVariableDouble = function(featureKey, variableKey
923927
*/
924928
Optimizely.prototype.getFeatureVariableInteger = function(featureKey, variableKey, userId, attributes) {
925929
try {
930+
if (!this.__isValidInstance()) {
931+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, 'getFeatureVariableInteger'));
932+
return null;
933+
}
926934
return this._getFeatureVariableForType(featureKey, variableKey, FEATURE_VARIABLE_TYPES.INTEGER, userId, attributes);
927935
} catch (e) {
928936
this.logger.log(LOG_LEVEL.ERROR, e.message);
@@ -947,6 +955,10 @@ Optimizely.prototype.getFeatureVariableInteger = function(featureKey, variableKe
947955
*/
948956
Optimizely.prototype.getFeatureVariableString = function(featureKey, variableKey, userId, attributes) {
949957
try {
958+
if (!this.__isValidInstance()) {
959+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, 'getFeatureVariableString'));
960+
return null;
961+
}
950962
return this._getFeatureVariableForType(featureKey, variableKey, FEATURE_VARIABLE_TYPES.STRING, userId, attributes);
951963
} catch (e) {
952964
this.logger.log(LOG_LEVEL.ERROR, e.message);
@@ -969,8 +981,12 @@ Optimizely.prototype.getFeatureVariableString = function(featureKey, variableKey
969981
* invalid, or there is a mismatch with the type
970982
* of the variable
971983
*/
972-
Optimizely.prototype.getFeatureVariableJson = function(featureKey, variableKey, userId, attributes) {
984+
Optimizely.prototype.getFeatureVariableJSON = function(featureKey, variableKey, userId, attributes) {
973985
try {
986+
if (!this.__isValidInstance()) {
987+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.INVALID_OBJECT, MODULE_NAME, 'getFeatureVariableJSON'));
988+
return null;
989+
}
974990
return this._getFeatureVariableForType(featureKey, variableKey, FEATURE_VARIABLE_TYPES.JSON, userId, attributes);
975991
} catch (e) {
976992
this.logger.log(LOG_LEVEL.ERROR, e.message);

0 commit comments

Comments
 (0)