Skip to content

Commit 39fa1eb

Browse files
author
Matt Carroll
committed
Merge branch 'master' into mcarroll/utils-object-entries
2 parents 69ec720 + db57438 commit 39fa1eb

File tree

11 files changed

+380
-190
lines changed

11 files changed

+380
-190
lines changed

packages/optimizely-sdk/CHANGELOG.MD

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,71 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## [Unreleased]
88
Changes that have landed but are not yet released.
99

10+
## [3.2.0] - May 30th, 2019
11+
12+
### New Features
13+
14+
- Added support for automatic datafile management ([#261](https://github.com/optimizely/javascript-sdk/pull/261)), ([#266](https://github.com/optimizely/javascript-sdk/pull/266)), ([#267](https://github.com/optimizely/javascript-sdk/pull/267)), ([#268](https://github.com/optimizely/javascript-sdk/pull/268)), ([#270](https://github.com/optimizely/javascript-sdk/pull/270)), ([#272](https://github.com/optimizely/javascript-sdk/pull/272))
15+
- To use automatic datafile management, include `sdkKey` as a string property in the options object you pass to `createInstance`.
16+
- When sdkKey is provided, the SDK instance will download the datafile associated with that sdkKey immediately upon construction. When the download completes, the SDK instance will update itself to use the downloaded datafile.
17+
- Use the `onReady` method to wait until the download is complete and the SDK is ready to use.
18+
- Customize datafile management behavior by passing a `datafileOptions` object within the options you pass to `createInstance`.
19+
- Enable automatic updates by passing `autoUpdate: true`. Periodically (on the provided update interval), the SDK instance will download the datafile and update itself. Use this to ensure that the SDK instance is using a fresh datafile reflecting changes recently made to your experiment or feature configuration.
20+
- Add a notification listener for the `OPTIMIZELY_CONFIG_UPDATE` notification type to be notified when an instance updates its Optimizely config after obtaining a new datafile.
21+
- Stop active downloads and cancel recurring downloads by calling the `close` method
22+
23+
#### Create an instance with datafile management enabled
24+
```js
25+
const optimizely = require('@optimizely/optimizely-sdk');
26+
const optimizelyClientInstance = optimizely.createInstance({
27+
sdkKey: '12345', // Provide the sdkKey of your desired environment here
28+
});
29+
```
30+
31+
#### Use `onReady` to wait until optimizelyClientInstance has a datafile
32+
```js
33+
const optimizely = require('@optimizely/optimizely-sdk');
34+
const optimizelyClientInstance = optimizely.createInstance({
35+
sdkKey: '12345',
36+
});
37+
optimizelyClientInstance.onReady().then(() => {
38+
// optimizelyClientInstance is ready to use, with datafile downloaded from the Optimizely CDN
39+
});
40+
```
41+
42+
#### Enable automatic updates, add notification listener for OPTIMIZELY_CONFIG_UPDATE notification type, and stop automatic updates
43+
```js
44+
const optimizely = require('@optimizely/optimizely-sdk');
45+
const optimizelyClientInstance = optimizely.createInstance({
46+
sdkKey: '12345',
47+
datafileOptions: {
48+
autoUpdate: true,
49+
updateInterval: 600000 // 10 minutes in milliseconds
50+
},
51+
});
52+
optimizelyClientInstance.notificationCenter.addNotificationListener(
53+
optimizely.enums.NOTIFICATION_TYPES.OPTIMIZELY_CONFIG_UPDATE,
54+
() => {
55+
// optimizelyClientInstance has updated its Optimizely config
56+
},
57+
);
58+
// Stop automatic updates - optimizelyClientInstance will use whatever datafile it currently has from now on
59+
optimizelyClientInstance.close();
60+
```
61+
62+
### Changed
63+
- Forced variation logic has been moved from the project config module to the decision service. Prefixes for forced-variation-related log messages will reflect this change ([#261](https://github.com/optimizely/javascript-sdk/pull/261)).
64+
- Update TypeScript definitions to account for new methods (`onReady`, `close`) and new properties on object accepted by createInstance (`datafileOptions`, `sdkKey`), ([#263](https://github.com/optimizely/javascript-sdk/pull/263)), ([#278](https://github.com/optimizely/javascript-sdk/pull/278))
65+
- Allow react-sdk to be passed in as `clientEngine` ([#279](https://github.com/optimizely/javascript-sdk/pull/279))
66+
67+
### Bug Fixes:
68+
- Add logging message for `optimizely.track()` ([#281](https://github.com/optimizely/javascript-sdk/pull/281))
69+
70+
## [3.2.0-beta] - May 16th, 2019
71+
72+
### Bug Fixes:
73+
- Clear timeout created in onReady call for timeout promise as soon as project config manager's ready promise fulfills
74+
1075
### New Features
1176
- Added 60 second timeout for all datafile requests
1277

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ module.exports = {
9393
hasRetriedEvents = true;
9494
}
9595

96-
config = fns.assignIn({}, config, {
97-
eventDispatcher: wrappedEventDispatcher,
96+
config = fns.assignIn({
9897
clientEngine: enums.JAVASCRIPT_CLIENT_ENGINE,
98+
}, config, {
99+
eventDispatcher: wrappedEventDispatcher,
99100
// always get the OptimizelyLogger facade from logging
100101
logger: logger,
101102
errorHandler: logging.getErrorHandler(),

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe('javascript-sdk', function() {
119119
optlyInstance.onReady().catch(function() {});
120120

121121
assert.instanceOf(optlyInstance, Optimizely);
122-
assert.equal(optlyInstance.clientVersion, '3.2.0-alpha');
122+
assert.equal(optlyInstance.clientVersion, '3.2.0');
123123
});
124124

125125
it('should set the JavaScript client engine and version', function() {
@@ -135,6 +135,32 @@ describe('javascript-sdk', function() {
135135
assert.equal(packageJSON.version, optlyInstance.clientVersion);
136136
});
137137

138+
it('should allow passing of "react-sdk" as the clientEngine', function() {
139+
var optlyInstance = optimizelyFactory.createInstance({
140+
clientEngine: 'react-sdk',
141+
datafile: {},
142+
errorHandler: fakeErrorHandler,
143+
eventDispatcher: fakeEventDispatcher,
144+
logger: silentLogger,
145+
});
146+
// Invalid datafile causes onReady Promise rejection - catch this error
147+
optlyInstance.onReady().catch(function() {});
148+
assert.equal('react-sdk', optlyInstance.clientEngine);
149+
});
150+
151+
it('should allow passing of "react-sdk" as the clientEngine', function() {
152+
var optlyInstance = optimizelyFactory.createInstance({
153+
clientEngine: 'react-sdk',
154+
datafile: {},
155+
errorHandler: fakeErrorHandler,
156+
eventDispatcher: fakeEventDispatcher,
157+
logger: silentLogger,
158+
});
159+
// Invalid datafile causes onReady Promise rejection - catch this error
160+
optlyInstance.onReady().catch(function() {});
161+
assert.equal('react-sdk', optlyInstance.clientEngine);
162+
});
163+
138164
it('should activate with provided event dispatcher', function() {
139165
var optlyInstance = optimizelyFactory.createInstance({
140166
datafile: testData.getTestProjectConfig(),

0 commit comments

Comments
 (0)