From 5f5582800b3d3a9df15776a58a69c5bc9125ed99 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Thu, 2 May 2019 10:20:29 -0700 Subject: [PATCH 1/4] Update TypeScript definitions for datafile management --- packages/optimizely-sdk/lib/index.d.ts | 34 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/packages/optimizely-sdk/lib/index.d.ts b/packages/optimizely-sdk/lib/index.d.ts index 41fd8827d..27679a812 100644 --- a/packages/optimizely-sdk/lib/index.d.ts +++ b/packages/optimizely-sdk/lib/index.d.ts @@ -15,13 +15,35 @@ */ declare module '@optimizely/optimizely-sdk' { - import enums = require('@optimizely/optimizely-sdk/lib/utils/enums'); + export namespace enums { + enum LOG_LEVEL { + NOTSET = 0, + DEBUG = 1, + INFO = 2, + WARNING = 3, + ERROR = 4, + } + + enum NOTIFICATION_TYPES { + ACTIVATE = 'ACTIVATE:experiment, user_id,attributes, variation, event', + DECISION = 'DECISION:type, userId, attributes, decisionInfo', + OPTIMIZELY_CONFIG_UPDATE = 'OPTIMIZELY_CONFIG_UPDATE', + TRACK = 'TRACK:event_key, user_id, attributes, event_tags, event', + } + } export function createInstance(config: Config): Client; + interface DatafileOptions { + autoUpdate?: boolean; + updateInterval?: number; + urlTemplate?: string; + } + // The options object given to Optimizely.createInstance. export interface Config { - datafile: object; + datafile?: object | string; + datafileOptions?: DatafileOptions, errorHandler?: object; eventDispatcher?: object; logger?: object; @@ -31,6 +53,7 @@ declare module '@optimizely/optimizely-sdk' { userProfileService?: UserProfileService | null; eventBatchSize?: number eventFlushInterval?: number + sdkKey?: string; } export interface Client { @@ -46,6 +69,8 @@ declare module '@optimizely/optimizely-sdk' { getFeatureVariableDouble(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): number | null; getFeatureVariableInteger(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): number | null; getFeatureVariableString(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): string | null; + onReady(options?: { timeout?: number }): Promise + close(): void } // An event to be submitted to Optimizely, enabling tracking the reach and impact of @@ -145,13 +170,14 @@ declare module '@optimizely/optimizely-sdk' { } declare module '@optimizely/optimizely-sdk/lib/utils/enums'{ - export enum LOG_LEVEL{ + export enum LOG_LEVEL { NOTSET = 0, DEBUG = 1, INFO = 2, WARNING = 3, ERROR = 4, } + export enum NOTIFICATION_TYPES { ACTIVATE = 'ACTIVATE:experiment, user_id, attributes, variation, events', TRACK = 'TRACK:event_key, user_id, attributes, event_tags, event', @@ -180,4 +206,4 @@ declare module '@optimizely/optimizely-sdk' { } export function createLogger(config: Config): Optimizely.Logger; export function createNoOpLogger(): Optimizely.Logger; - } \ No newline at end of file + } From faab8255c73a51365cc0ae2ca2708603dd37224d Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Thu, 2 May 2019 16:01:38 -0700 Subject: [PATCH 2/4] Update CHANGELOG --- packages/optimizely-sdk/CHANGELOG.MD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/optimizely-sdk/CHANGELOG.MD b/packages/optimizely-sdk/CHANGELOG.MD index 36d8e418b..911fa4304 100644 --- a/packages/optimizely-sdk/CHANGELOG.MD +++ b/packages/optimizely-sdk/CHANGELOG.MD @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] Changes that have landed but are not yet released. +- Update TypeScript definitions to account for new methods (`onReady`, `close`) and new properties on object accepted by createInstance (`datafileOptions`, `sdkKey`) + ## [3.2.0-alpha] - April 26nd, 2019 ### New Features From 83edabe589f009fb523caff2650f0d839d3c73d9 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Thu, 2 May 2019 16:02:48 -0700 Subject: [PATCH 3/4] Update NOTIFICATION_TYPES enum in the other module --- packages/optimizely-sdk/lib/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/optimizely-sdk/lib/index.d.ts b/packages/optimizely-sdk/lib/index.d.ts index 27679a812..fa3cd704a 100644 --- a/packages/optimizely-sdk/lib/index.d.ts +++ b/packages/optimizely-sdk/lib/index.d.ts @@ -178,8 +178,10 @@ declare module '@optimizely/optimizely-sdk' { ERROR = 4, } - export enum NOTIFICATION_TYPES { - ACTIVATE = 'ACTIVATE:experiment, user_id, attributes, variation, events', + enum NOTIFICATION_TYPES { + ACTIVATE = 'ACTIVATE:experiment, user_id,attributes, variation, event', + DECISION = 'DECISION:type, userId, attributes, decisionInfo', + OPTIMIZELY_CONFIG_UPDATE = 'OPTIMIZELY_CONFIG_UPDATE', TRACK = 'TRACK:event_key, user_id, attributes, event_tags, event', } } From 8c67b6903f99bc94686198b752759481662432e9 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Thu, 2 May 2019 16:20:04 -0700 Subject: [PATCH 4/4] Export enum in other module --- packages/optimizely-sdk/lib/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/optimizely-sdk/lib/index.d.ts b/packages/optimizely-sdk/lib/index.d.ts index fa3cd704a..62b65f104 100644 --- a/packages/optimizely-sdk/lib/index.d.ts +++ b/packages/optimizely-sdk/lib/index.d.ts @@ -178,7 +178,7 @@ declare module '@optimizely/optimizely-sdk' { ERROR = 4, } - enum NOTIFICATION_TYPES { + export enum NOTIFICATION_TYPES { ACTIVATE = 'ACTIVATE:experiment, user_id,attributes, variation, event', DECISION = 'DECISION:type, userId, attributes, decisionInfo', OPTIMIZELY_CONFIG_UPDATE = 'OPTIMIZELY_CONFIG_UPDATE',