From b5b3fcacbd02fb8be13481ef9a646712fe8c4482 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Wed, 21 Aug 2019 08:32:21 -0700 Subject: [PATCH 1/2] Prepare for 3.3.0-beta --- packages/optimizely-sdk/CHANGELOG.MD | 16 +++++++++++++--- .../optimizely-sdk/lib/index.browser.tests.js | 2 +- packages/optimizely-sdk/lib/index.node.tests.js | 2 +- packages/optimizely-sdk/lib/utils/enums/index.js | 2 +- packages/optimizely-sdk/package-lock.json | 2 +- packages/optimizely-sdk/package.json | 2 +- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/optimizely-sdk/CHANGELOG.MD b/packages/optimizely-sdk/CHANGELOG.MD index 0024e57b2..162f9a3fe 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -7,12 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] Changes that have landed but are not yet released. +## [3.3.0-beta] - August 21th, 2019 + ### New Features + +- Added support for event batching via the event processor. + - Events generated by methods like `activate`, `track`, and `isFeatureEnabled` will be held in a queue until the configured batch size is reached, or the configured flush interval has elapsed. Then, they will be combined into a request and send to the event dispatcher. + - To configure event batching, include the `eventBatchSize` and `eventFlushInterval` number properties in the object you pass to `createInstance`. + - Event batching is enabled by default. `eventBatchSize` defaults to `10`. `eventFlushInterval` defaults to `30000` in Node and `1000` in browsers. +- Added `localStorage` mitigation against lost events in the browser + - When event requests are dispatched, they are written to `localStorage`, and when a response is received, they are removed from `localStorage`. + - When the SDK is initialized for the first time in the browser, if any requests remain in `localStorage`, they will be sent, and removed from `localStorage` when a response is received. - Updated the `close` method to return a `Promise` representing the process of closing the instance. When `close` is called, any events waiting to be sent as part of a batched event request will be immediately batched and sent to the event dispatcher. -- If any such requests were sent to the event dispatcher, `close` returns a `Promise` that fulfills after the event dispatcher calls the response callback for each request. Otherwise, `close` returns an immediately-fulfilled `Promise`. -- The `Promise` returned from `close` is fulfilled with a result object containing `success` (boolean) and `reason` (string, only when success is `false`) properties. In the result object, `success` is `true` if all events in the queue at the time close was called were combined into requests, sent to the event dispatcher, and the event dispatcher called the callbacks for each request. `success` is false if an unexpected error was encountered during the close process. + - If any such requests were sent to the event dispatcher, `close` returns a `Promise` that fulfills after the event dispatcher calls the response callback for each request. Otherwise, `close` returns an immediately-fulfilled `Promise`. + - The `Promise` returned from `close` is fulfilled with a result object containing `success` (boolean) and `reason` (string, only when success is `false`) properties. In the result object, `success` is `true` if all events in the queue at the time close was called were combined into requests, sent to the event dispatcher, and the event dispatcher called the callbacks for each request. `success` is false if an unexpected error was encountered during the close process. - Added non-typed `getFeatureVariable` method ([#298](https://github.com/optimizely/javascript-sdk/pull/298)) as a more idiomatic approach to getting values of feature variables. -- Typed `getFeatureVariable` methods will still be available for use. + - Typed `getFeatureVariable` methods will still be available for use. ## [3.2.2] - August 20th, 2019 diff --git a/packages/optimizely-sdk/lib/index.browser.tests.js b/packages/optimizely-sdk/lib/index.browser.tests.js index 6b069a8ad..8c840d949 100644 --- a/packages/optimizely-sdk/lib/index.browser.tests.js +++ b/packages/optimizely-sdk/lib/index.browser.tests.js @@ -148,7 +148,7 @@ describe('javascript-sdk', function() { optlyInstance.onReady().catch(function() {}); assert.instanceOf(optlyInstance, Optimizely); - assert.equal(optlyInstance.clientVersion, '3.2.2'); + assert.equal(optlyInstance.clientVersion, '3.3.0-beta'); }); it('should set the JavaScript client engine and version', function() { diff --git a/packages/optimizely-sdk/lib/index.node.tests.js b/packages/optimizely-sdk/lib/index.node.tests.js index a55baa804..9eed24e39 100644 --- a/packages/optimizely-sdk/lib/index.node.tests.js +++ b/packages/optimizely-sdk/lib/index.node.tests.js @@ -92,7 +92,7 @@ describe('optimizelyFactory', function() { optlyInstance.onReady().catch(function() {}); assert.instanceOf(optlyInstance, Optimizely); - assert.equal(optlyInstance.clientVersion, '3.2.2'); + assert.equal(optlyInstance.clientVersion, '3.3.0-beta'); }); describe('event processor configuration', function() { diff --git a/packages/optimizely-sdk/lib/utils/enums/index.js b/packages/optimizely-sdk/lib/utils/enums/index.js index 5e31167bf..b22b7e84a 100644 --- a/packages/optimizely-sdk/lib/utils/enums/index.js +++ b/packages/optimizely-sdk/lib/utils/enums/index.js @@ -159,7 +159,7 @@ exports.CONTROL_ATTRIBUTES = { exports.JAVASCRIPT_CLIENT_ENGINE = 'javascript-sdk'; exports.NODE_CLIENT_ENGINE = 'node-sdk'; exports.REACT_CLIENT_ENGINE = 'react-sdk'; -exports.NODE_CLIENT_VERSION = '3.2.2'; +exports.NODE_CLIENT_VERSION = '3.3.0-beta'; exports.VALID_CLIENT_ENGINES = [ exports.NODE_CLIENT_ENGINE, diff --git a/packages/optimizely-sdk/package-lock.json b/packages/optimizely-sdk/package-lock.json index 6b38d1b30..29e602842 100644 --- a/packages/optimizely-sdk/package-lock.json +++ b/packages/optimizely-sdk/package-lock.json @@ -1,6 +1,6 @@ { "name": "@optimizely/optimizely-sdk", - "version": "3.2.2", + "version": "3.3.0-beta", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/optimizely-sdk/package.json b/packages/optimizely-sdk/package.json index d291546f9..1412c53ce 100644 --- a/packages/optimizely-sdk/package.json +++ b/packages/optimizely-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@optimizely/optimizely-sdk", - "version": "3.2.2", + "version": "3.3.0-beta", "description": "JavaScript SDK for Optimizely X Full Stack", "main": "lib/index.node.js", "browser": "lib/index.browser.js", From 9683ee1f32ba0f6a277dbe03deae0c1584d4023a Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Wed, 21 Aug 2019 09:11:33 -0700 Subject: [PATCH 2/2] send to -> sent to --- packages/optimizely-sdk/CHANGELOG.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/optimizely-sdk/CHANGELOG.MD b/packages/optimizely-sdk/CHANGELOG.MD index 162f9a3fe..db593e6fb 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -12,7 +12,7 @@ Changes that have landed but are not yet released. ### New Features - Added support for event batching via the event processor. - - Events generated by methods like `activate`, `track`, and `isFeatureEnabled` will be held in a queue until the configured batch size is reached, or the configured flush interval has elapsed. Then, they will be combined into a request and send to the event dispatcher. + - Events generated by methods like `activate`, `track`, and `isFeatureEnabled` will be held in a queue until the configured batch size is reached, or the configured flush interval has elapsed. Then, they will be combined into a request and sent to the event dispatcher. - To configure event batching, include the `eventBatchSize` and `eventFlushInterval` number properties in the object you pass to `createInstance`. - Event batching is enabled by default. `eventBatchSize` defaults to `10`. `eventFlushInterval` defaults to `30000` in Node and `1000` in browsers. - Added `localStorage` mitigation against lost events in the browser