Skip to content

fix: Update TypeScript definitions for datafile management #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/optimizely-sdk/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 33 additions & 5 deletions packages/optimizely-sdk/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,35 @@
*/

declare module '@optimizely/optimizely-sdk' {
import enums = require('@optimizely/optimizely-sdk/lib/utils/enums');
export namespace enums {
enum LOG_LEVEL {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

datafileOptions?: DatafileOptions,
errorHandler?: object;
eventDispatcher?: object;
logger?: object;
Expand All @@ -31,6 +53,7 @@ declare module '@optimizely/optimizely-sdk' {
userProfileService?: UserProfileService | null;
eventBatchSize?: number
eventFlushInterval?: number
sdkKey?: string;
}

export interface Client {
Expand All @@ -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<void>
close(): void
}

// An event to be submitted to Optimizely, enabling tracking the reach and impact of
Expand Down Expand Up @@ -145,15 +170,18 @@ 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',
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',
}
}
Expand All @@ -180,4 +208,4 @@ declare module '@optimizely/optimizely-sdk' {
}
export function createLogger(config: Config): Optimizely.Logger;
export function createNoOpLogger(): Optimizely.Logger;
}
}