Skip to content

Added Optimizely Config in Typescript #390

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 5 commits into from
Jan 28, 2020
Merged
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
65 changes: 63 additions & 2 deletions packages/optimizely-sdk/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018-2019, Optimizely
* Copyright 2018-2020, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -111,10 +111,11 @@ declare module "@optimizely/optimizely-sdk" {
userId: string,
attributes?: UserAttributes
): string | null;
getOptimizelyConfig(): OptimizelyConfig | null;
onReady(options?: {
timeout?: number;
}): Promise<{ success: boolean; reason?: string }>;
close(): void;
close(): void;
}

// An event to be submitted to Optimizely, enabling tracking the reach and impact of
Expand Down Expand Up @@ -214,6 +215,66 @@ declare module "@optimizely/optimizely-sdk" {
};
};
}

/**
* Optimizely Config Entities
*/
export interface OptimizelyVariable {
id: string;
key: string;
type: string;
value: string;
}

export interface OptimizelyVariation {
id: string;
key: string;
featureEnabled?: boolean;
variablesMap: {
[variableKey: string]: {
variable: OptimizelyVariable;
};
};
}

export interface OptimizelyExperiment {
id: string;
key: string;
variationsMap: {
[variationKey: string]: {
variation: OptimizelyVariation;
};
};
}

export interface OptimizelyFeature {
id: string;
key: string;
experimentsMap: {
[experimentKey: string]: {
experiment: OptimizelyExperiment;
};
};
variablesMap: {
[variableKey: string]: {
variable: OptimizelyVariable;
};
};
}

export interface OptimizelyConfig {
experimentsMap: {
[experimentKey: string]: {
experiment: OptimizelyExperiment;
};
};
featuresMap: {
[featureKey: string]: {
feature: OptimizelyFeature;
};
};
revision: string;
}
}

declare module "@optimizely/optimizely-sdk/lib/utils/enums" {
Expand Down