From b0ebe853f825ec6e8347ad489bf9db0eed8e6b9d Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Mon, 5 Oct 2020 09:16:42 -0700 Subject: [PATCH 1/4] Add missing OptimizelyConfig and UserAttributes to TS definitions --- packages/optimizely-sdk/CHANGELOG.MD | 6 +- packages/optimizely-sdk/lib/index.d.ts | 83 +++++++++++++++++++++----- 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/packages/optimizely-sdk/CHANGELOG.MD b/packages/optimizely-sdk/CHANGELOG.MD index cbcae5156..aac513ccf 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -7,13 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] -## [4.3.0] - October 1, 2020 +## [4.3.0] - October 5, 2020 ### New Features - Added support for version audience evaluation ([#517](https://github.com/optimizely/javascript-sdk/pull/571)) - Add datafile accessor ([#564](https://github.com/optimizely/javascript-sdk/pull/564)) +### Bug fixes + +- Added `OptimizelyConfig` interface and `UserAttributes ` type in TypeScript type definitions ([--](https://github.com/optimizely/javascript-sdk/pull/--)) + ## [4.2.1] - August 10, 2020 ### Bug fixes diff --git a/packages/optimizely-sdk/lib/index.d.ts b/packages/optimizely-sdk/lib/index.d.ts index 3bc79687c..62ea9b3c5 100644 --- a/packages/optimizely-sdk/lib/index.d.ts +++ b/packages/optimizely-sdk/lib/index.d.ts @@ -66,72 +66,72 @@ declare module '@optimizely/optimizely-sdk' { activate( experimentKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): string | null; track( eventKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes, + attributes?: UserAttributes, eventTags?: EventTags ): void; getVariation( experimentKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): string | null; setForcedVariation(experimentKey: string, userId: string, variationKey: string | null): boolean; getForcedVariation(experimentKey: string, userId: string): string | null; isFeatureEnabled( featureKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): boolean; getEnabledFeatures( userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): string[]; getFeatureVariable( featureKey: string, variableKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): unknown; getFeatureVariableBoolean( featureKey: string, variableKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): boolean | null; getFeatureVariableDouble( featureKey: string, variableKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): number | null; getFeatureVariableInteger( featureKey: string, variableKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): number | null; getFeatureVariableString( featureKey: string, variableKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): string | null; getFeatureVariableJSON( featureKey: string, variableKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): unknown; getAllFeatureVariables( featureKey: string, userId: string, - attributes?: import('./shared_types').UserAttributes + attributes?: UserAttributes ): { [variableKey: string]: unknown }; - getOptimizelyConfig(): import('./shared_types').OptimizelyConfig | null; + getOptimizelyConfig(): OptimizelyConfig | null; onReady(options?: { timeout?: number }): Promise<{ success: boolean; reason?: string }>; close(): Promise<{ success: boolean; reason?: string }>; } @@ -160,6 +160,61 @@ declare module '@optimizely/optimizely-sdk' { dispatchEvent: (event: Event, callback: () => void) => void; } + export type UserAttributes = { + // TODO[OASIS-6649]: Don't use any type + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [name: string]: any; + } + + /** + * Optimizely Config Entities + */ + export interface OptimizelyVariable { + id: string; + key: string; + type: string; + value: string; + } + + export interface OptimizelyExperiment { + id: string; + key: string; + variationsMap: { + [variationKey: string]: OptimizelyVariation; + }; + } + + export interface OptimizelyFeature { + id: string; + key: string; + experimentsMap: { + [experimentKey: string]: OptimizelyExperiment; + }; + variablesMap: { + [variableKey: string]: OptimizelyVariable; + }; + } + + export interface OptimizelyVariation { + id: string; + key: string; + featureEnabled?: boolean; + variablesMap: { + [variableKey: string]: OptimizelyVariable; + }; + } + + export interface OptimizelyConfig { + experimentsMap: { + [experimentKey: string]: OptimizelyExperiment; + }; + featuresMap: { + [featureKey: string]: OptimizelyFeature; + }; + revision: string; + getDatafile(): string; + } + // NotificationCenter-related types export interface NotificationCenter { addNotificationListener( @@ -175,7 +230,7 @@ declare module '@optimizely/optimizely-sdk' { export interface ListenerPayload { userId: string; - attributes: import('./shared_types').UserAttributes; + attributes: UserAttributes; } export interface ActivateListenerPayload extends ListenerPayload { From f5eb1bec33ba3a7d28bee05e0c47e675d695cb61 Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Mon, 5 Oct 2020 09:24:06 -0700 Subject: [PATCH 2/4] Include pull request number to changelog --- 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 aac513ccf..8a57d0e69 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Bug fixes -- Added `OptimizelyConfig` interface and `UserAttributes ` type in TypeScript type definitions ([--](https://github.com/optimizely/javascript-sdk/pull/--)) +- Added `OptimizelyConfig` interface and `UserAttributes` type in TypeScript type definitions ([#587](https://github.com/optimizely/javascript-sdk/pull/587)) ## [4.2.1] - August 10, 2020 From d45bd0e277e924e62ec010c9e347e88d4383fa2d Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Mon, 5 Oct 2020 10:30:08 -0700 Subject: [PATCH 3/4] Prepare for 4.3.1 release --- packages/optimizely-sdk/CHANGELOG.MD | 10 ++-- .../optimizely-sdk/lib/index.browser.tests.js | 2 +- packages/optimizely-sdk/lib/index.d.ts | 59 ++----------------- .../optimizely-sdk/lib/index.node.tests.js | 2 +- .../lib/index.react_native.tests.js | 2 +- .../optimizely-sdk/lib/utils/enums/index.ts | 2 +- packages/optimizely-sdk/package-lock.json | 2 +- packages/optimizely-sdk/package.json | 2 +- 8 files changed, 16 insertions(+), 65 deletions(-) diff --git a/packages/optimizely-sdk/CHANGELOG.MD b/packages/optimizely-sdk/CHANGELOG.MD index 8a57d0e69..692910b7b 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [4.3.1] - October 5, 2020 + +### Bug fixes + +- Exported `OptimizelyConfig` and `UserAttributes` type in TypeScript type definitions ([#587](https://github.com/optimizely/javascript-sdk/pull/587)) + ## [4.3.0] - October 5, 2020 ### New Features @@ -14,10 +20,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added support for version audience evaluation ([#517](https://github.com/optimizely/javascript-sdk/pull/571)) - Add datafile accessor ([#564](https://github.com/optimizely/javascript-sdk/pull/564)) -### Bug fixes - -- Added `OptimizelyConfig` interface and `UserAttributes` type in TypeScript type definitions ([#587](https://github.com/optimizely/javascript-sdk/pull/587)) - ## [4.2.1] - August 10, 2020 ### Bug fixes diff --git a/packages/optimizely-sdk/lib/index.browser.tests.js b/packages/optimizely-sdk/lib/index.browser.tests.js index 2c49a6a59..5d7cec571 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, '4.3.0'); + assert.equal(optlyInstance.clientVersion, '4.3.1'); }); it('should set the JavaScript client engine and version', function() { diff --git a/packages/optimizely-sdk/lib/index.d.ts b/packages/optimizely-sdk/lib/index.d.ts index 62ea9b3c5..7222ea530 100644 --- a/packages/optimizely-sdk/lib/index.d.ts +++ b/packages/optimizely-sdk/lib/index.d.ts @@ -30,6 +30,10 @@ declare module '@optimizely/optimizely-sdk' { export const eventDispatcher: EventDispatcher; + export type UserAttributes = import('./shared_types').UserAttributes; + + export type OptimizelyConfig = import('./shared_types').OptimizelyConfig; + interface DatafileOptions { autoUpdate?: boolean; updateInterval?: number; @@ -160,61 +164,6 @@ declare module '@optimizely/optimizely-sdk' { dispatchEvent: (event: Event, callback: () => void) => void; } - export type UserAttributes = { - // TODO[OASIS-6649]: Don't use any type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [name: string]: any; - } - - /** - * Optimizely Config Entities - */ - export interface OptimizelyVariable { - id: string; - key: string; - type: string; - value: string; - } - - export interface OptimizelyExperiment { - id: string; - key: string; - variationsMap: { - [variationKey: string]: OptimizelyVariation; - }; - } - - export interface OptimizelyFeature { - id: string; - key: string; - experimentsMap: { - [experimentKey: string]: OptimizelyExperiment; - }; - variablesMap: { - [variableKey: string]: OptimizelyVariable; - }; - } - - export interface OptimizelyVariation { - id: string; - key: string; - featureEnabled?: boolean; - variablesMap: { - [variableKey: string]: OptimizelyVariable; - }; - } - - export interface OptimizelyConfig { - experimentsMap: { - [experimentKey: string]: OptimizelyExperiment; - }; - featuresMap: { - [featureKey: string]: OptimizelyFeature; - }; - revision: string; - getDatafile(): string; - } - // NotificationCenter-related types export interface NotificationCenter { addNotificationListener( diff --git a/packages/optimizely-sdk/lib/index.node.tests.js b/packages/optimizely-sdk/lib/index.node.tests.js index bf04ee20c..273239eeb 100644 --- a/packages/optimizely-sdk/lib/index.node.tests.js +++ b/packages/optimizely-sdk/lib/index.node.tests.js @@ -90,7 +90,7 @@ describe('optimizelyFactory', function() { optlyInstance.onReady().catch(function() {}); assert.instanceOf(optlyInstance, Optimizely); - assert.equal(optlyInstance.clientVersion, '4.3.0'); + assert.equal(optlyInstance.clientVersion, '4.3.1'); }); describe('event processor configuration', function() { diff --git a/packages/optimizely-sdk/lib/index.react_native.tests.js b/packages/optimizely-sdk/lib/index.react_native.tests.js index a1ab74270..556451847 100644 --- a/packages/optimizely-sdk/lib/index.react_native.tests.js +++ b/packages/optimizely-sdk/lib/index.react_native.tests.js @@ -89,7 +89,7 @@ describe('javascript-sdk/react-native', function() { optlyInstance.onReady().catch(function() {}); assert.instanceOf(optlyInstance, Optimizely); - assert.equal(optlyInstance.clientVersion, '4.3.0'); + assert.equal(optlyInstance.clientVersion, '4.3.1'); }); it('should set the Javascript client engine and version', function() { diff --git a/packages/optimizely-sdk/lib/utils/enums/index.ts b/packages/optimizely-sdk/lib/utils/enums/index.ts index e4dde2d48..af8e18af2 100644 --- a/packages/optimizely-sdk/lib/utils/enums/index.ts +++ b/packages/optimizely-sdk/lib/utils/enums/index.ts @@ -173,7 +173,7 @@ export const CONTROL_ATTRIBUTES = { export const JAVASCRIPT_CLIENT_ENGINE = 'javascript-sdk'; export const NODE_CLIENT_ENGINE = 'node-sdk'; export const REACT_CLIENT_ENGINE = 'react-sdk'; -export const NODE_CLIENT_VERSION = '4.3.0'; +export const NODE_CLIENT_VERSION = '4.3.1'; export const VALID_CLIENT_ENGINES = [ NODE_CLIENT_ENGINE, diff --git a/packages/optimizely-sdk/package-lock.json b/packages/optimizely-sdk/package-lock.json index b066ba741..3abaf9915 100644 --- a/packages/optimizely-sdk/package-lock.json +++ b/packages/optimizely-sdk/package-lock.json @@ -1,6 +1,6 @@ { "name": "@optimizely/optimizely-sdk", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/optimizely-sdk/package.json b/packages/optimizely-sdk/package.json index 05294ee12..6dae0c7ea 100644 --- a/packages/optimizely-sdk/package.json +++ b/packages/optimizely-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@optimizely/optimizely-sdk", - "version": "4.3.0", + "version": "4.3.1", "description": "JavaScript SDK for Optimizely X Full Stack", "module": "dist/optimizely.browser.es.min.js", "main": "dist/optimizely.node.min.js", From 62296da936f2129e3d0523ef482f2de719157fd6 Mon Sep 17 00:00:00 2001 From: Polina Nguen Date: Mon, 5 Oct 2020 10:36:22 -0700 Subject: [PATCH 4/4] Fix date in Changelog --- 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 692910b7b..da022239f 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Exported `OptimizelyConfig` and `UserAttributes` type in TypeScript type definitions ([#587](https://github.com/optimizely/javascript-sdk/pull/587)) -## [4.3.0] - October 5, 2020 +## [4.3.0] - October 1, 2020 ### New Features