Skip to content

feat: Converted index.react_native.js to TS #583

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

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bc99e5d
added declaration file for notification center
Sep 22, 2020
5819fff
comment addressed: seperate declaration file for event_helper event_h…
Sep 23, 2020
a27a13c
event_helpers module name and declaration file name corrected
Sep 23, 2020
6cc5495
EOL in event_helpers.d.ts
Sep 23, 2020
687d620
Convert Optimizely Module
yavorona Sep 24, 2020
0df41cf
Fix comments
yavorona Sep 28, 2020
a2cefd7
Update formatting and add optional attribute sign
yavorona Sep 28, 2020
a86dc34
Clean up
yavorona Sep 28, 2020
343518e
Address Matt's comments part 1
yavorona Sep 29, 2020
b34d864
Address comment part2
yavorona Sep 29, 2020
04b44cc
Incorporating commenta part 3
yavorona Sep 29, 2020
90cd51c
Incorporate comments part 4
yavorona Sep 29, 2020
e8473a5
Updating names of private methods
yavorona Sep 30, 2020
32faf70
Update private methods
yavorona Sep 30, 2020
289f2ea
Create configObj interface
yavorona Sep 30, 2020
3b0ba96
Clean up
yavorona Sep 30, 2020
096f857
Add back DatafileOptions
yavorona Sep 30, 2020
625da66
Create ProjectConfigManagerConfig interface
yavorona Sep 30, 2020
b76d534
Fix LogTierV1EventProcessor compiler error without re-defining LogTie…
yavorona Sep 30, 2020
145838b
Fix EventTags to not except boolean
yavorona Oct 1, 2020
510bb95
incporporating comments part 1
yavorona Oct 2, 2020
cb7a600
converted intex.react_native.js to ts according to optimizely module
Oct 2, 2020
d62d6e7
added declaration file for notification center
Sep 22, 2020
8607a26
comment addressed: seperate declaration file for event_helper event_h…
Sep 23, 2020
a0d3f15
event_helpers module name and declaration file name corrected
Sep 23, 2020
7ebde62
EOL in event_helpers.d.ts
Sep 23, 2020
e3b9313
Convert Optimizely Module
yavorona Sep 24, 2020
080198d
Fix comments
yavorona Sep 28, 2020
58978f1
Update formatting and add optional attribute sign
yavorona Sep 28, 2020
07dc378
Clean up
yavorona Sep 28, 2020
1faf4ea
Address Matt's comments part 1
yavorona Sep 29, 2020
dd8d1f4
Address comment part2
yavorona Sep 29, 2020
dfc96df
Incorporating commenta part 3
yavorona Sep 29, 2020
9a23b65
Incorporate comments part 4
yavorona Sep 29, 2020
166ca11
Updating names of private methods
yavorona Sep 30, 2020
f75acb7
Update private methods
yavorona Sep 30, 2020
2005324
Create configObj interface
yavorona Sep 30, 2020
0f1dc9a
Clean up
yavorona Sep 30, 2020
b3be1c9
Add back DatafileOptions
yavorona Sep 30, 2020
6e53691
Create ProjectConfigManagerConfig interface
yavorona Sep 30, 2020
8e6ec59
Fix LogTierV1EventProcessor compiler error without re-defining LogTie…
yavorona Sep 30, 2020
440d009
Fix EventTags to not except boolean
yavorona Oct 1, 2020
90b133b
incporporating comments part 1
yavorona Oct 2, 2020
7de389e
Incoprorate comments part 2
yavorona Oct 2, 2020
63b7882
Returned UserAttributes type back go index.d.ts
yavorona Oct 2, 2020
8da7267
Return all types back to index.d.ts
yavorona Oct 2, 2020
979dadb
Merge branch 'pnguen/optimizely-module-to-ts' into uzair/react_native…
Oct 5, 2020
a7f6a86
copied optimizelyconfig from optimizely module to sharedType
Oct 5, 2020
c064839
Update roolup config for ts file
Oct 5, 2020
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
4 changes: 4 additions & 0 deletions packages/optimizely-sdk/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Bug fixes

- Fixed return type of `getAllFeatureVariables` method and `dispatchEvent ` method signature of `EventDispatcher` interface in TypeScript type definitions ([#576](https://github.com/optimizely/javascript-sdk/pull/576))

## [4.3.0] - October 1, 2020

### New Features
Expand Down
161 changes: 80 additions & 81 deletions packages/optimizely-sdk/lib/core/decision_service/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,95 +13,94 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LogHandler } from '@optimizely/js-sdk-logging';
import { ProjectConfig } from '../project_config';
import { UserAttributes, UserProfileService } from '../../shared_types';
import { FeatureFlag, Experiment, Variation } from '../project_config/entities';

declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
import { LogHandler } from '@optimizely/js-sdk-logging';
import { ProjectConfig } from '@optimizely/optimizely-sdk/lib/core/project_config';
/**
* Creates an instance of the DecisionService.
* @param {Options} options Configuration options
* @return {DecisionService} An instance of the DecisionService
*/
export function createDecisionService(options: Options): DecisionService;

export interface DecisionService {

/**
* Creates an instance of the DecisionService.
* @param {Options} options Configuration options
* @return {DecisionService} An instance of the DecisionService
* Gets variation where visitor will be bucketed.
* @param {ProjectConfig} configObj The parsed project configuration object
* @param {string} experimentKey
* @param {string} userId
* @param {UserAttributes} attributes
* @return {string|null} The variation the user is bucketed into.
*/
export function createDecisionService(options: Options): DecisionService;

interface DecisionService {
getVariation(
configObj: ProjectConfig,
experimentKey: string,
userId: string,
attributes?: UserAttributes
): string | null;

/**
* Gets variation where visitor will be bucketed.
* @param {ProjectConfig} configObj The parsed project configuration object
* @param {string} experimentKey
* @param {string} userId
* @param {UserAttributes} attributes
* @return {string|null} The variation the user is bucketed into.
*/
getVariation(
configObj: ProjectConfig,
experimentKey: string,
userId: string,
attributes?: import('../../shared_types').UserAttributes
): string | null;

/**
* Given a feature, user ID, and attributes, returns an object representing a
* decision. If the user was bucketed into a variation for the given feature
* and attributes, the returned decision object will have variation and
* experiment properties (both objects), as well as a decisionSource property.
* decisionSource indicates whether the decision was due to a rollout or an
* experiment.
* @param {ProjectConfig} configObj The parsed project configuration object
* @param {FeatureFlag} feature A feature flag object from project configuration
* @param {string} userId A string identifying the user, for bucketing
* @param {unknown} attributes Optional user attributes
* @return {Decision} An object with experiment, variation, and decisionSource
* properties. If the user was not bucketed into a variation, the variation
* property is null.
*/
getVariationForFeature(
configObj: ProjectConfig,
feature: import('../project_config/entities').FeatureFlag,
userId: string,
attributes: unknown
): Decision;
/**
* Given a feature, user ID, and attributes, returns an object representing a
* decision. If the user was bucketed into a variation for the given feature
* and attributes, the returned decision object will have variation and
* experiment properties (both objects), as well as a decisionSource property.
* decisionSource indicates whether the decision was due to a rollout or an
* experiment.
* @param {ProjectConfig} configObj The parsed project configuration object
* @param {FeatureFlag} feature A feature flag object from project configuration
* @param {string} userId A string identifying the user, for bucketing
* @param {unknown} attributes Optional user attributes
* @return {Decision} An object with experiment, variation, and decisionSource
* properties. If the user was not bucketed into a variation, the variation
* property is null.
*/
getVariationForFeature(
configObj: ProjectConfig,
feature: FeatureFlag,
userId: string,
attributes: unknown
): Decision;

/**
* Removes forced variation for given userId and experimentKey
* @param {unknown} userId String representing the user id
* @param {string} experimentId Number representing the experiment id
* @param {string} experimentKey Key representing the experiment id
* @throws If the user id is not valid or not in the forced variation map
*/
removeForcedVariation(userId: unknown, experimentId: string, experimentKey: string): void;
/**
* Removes forced variation for given userId and experimentKey
* @param {unknown} userId String representing the user id
* @param {string} experimentId Number representing the experiment id
* @param {string} experimentKey Key representing the experiment id
* @throws If the user id is not valid or not in the forced variation map
*/
removeForcedVariation(userId: unknown, experimentId: string, experimentKey: string): void;

/**
* Gets the forced variation key for the given user and experiment.
* @param {ProjectConfig} configObj Object representing project configuration
* @param {string} experimentKey Key for experiment.
* @param {string} userId The user Id.
* @return {string|null} Variation key that specifies the variation which the given user and experiment should be forced into.
*/
getForcedVariation(configObj: ProjectConfig, experimentKey: string, userId: string): string | null;
/**
* Gets the forced variation key for the given user and experiment.
* @param {ProjectConfig} configObj Object representing project configuration
* @param {string} experimentKey Key for experiment.
* @param {string} userId The user Id.
* @return {string|null} Variation key that specifies the variation which the given user and experiment should be forced into.
*/
getForcedVariation(configObj: ProjectConfig, experimentKey: string, userId: string): string | null;

/**
* Sets the forced variation for a user in a given experiment
* @param {ProjectConfig} configObj Object representing project configuration
* @param {string} experimentKey Key for experiment.
* @param {string} userId The user Id.
* @param {unknown} variationKey Key for variation. If null, then clear the existing experiment-to-variation mapping
* @return {boolean} A boolean value that indicates if the set completed successfully.
*/
setForcedVariation(configObj: ProjectConfig, experimentKey: string, userId: string, variationKey: unknown): boolean;
}
/**
* Sets the forced variation for a user in a given experiment
* @param {ProjectConfig} configObj Object representing project configuration
* @param {string} experimentKey Key for experiment.
* @param {string} userId The user Id.
* @param {unknown} variationKey Key for variation. If null, then clear the existing experiment-to-variation mapping
* @return {boolean} A boolean value that indicates if the set completed successfully.
*/
setForcedVariation(configObj: ProjectConfig, experimentKey: string, userId: string, variationKey: unknown): boolean;
}

interface Options {
userProfileService: import('../../shared_types').UserProfileService | null;
logger: LogHandler;
UNSTABLE_conditionEvaluators: unknown;
}
interface Options {
userProfileService: UserProfileService | null;
logger: LogHandler;
UNSTABLE_conditionEvaluators: unknown;
}

interface Decision {
experiment: import('../../shared_types').Experiment | null;
variation: import('../../shared_types').Variation | null;
decisionSource: string;
}
interface Decision {
experiment: Experiment | null;
variation: Variation | null;
decisionSource: string;
}
122 changes: 89 additions & 33 deletions packages/optimizely-sdk/lib/core/event_builder/event_helpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,97 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ProjectConfig } from '../project_config';
import { EventTags, UserAttributes } from '../../shared_types';

declare module '@optimizely/optimizely-sdk/lib/core/event_builder' {
import { ProjectConfig } from '@optimizely/optimizely-sdk/lib/core/project_config';

interface ImpressionConfig {
experimentKey: string;
variationKey: string;
userId: string;
userAttributes: import('../../shared_types').UserAttributes;
clientEngine: string;
clientVersion: string;
configObj: ProjectConfig;
}
interface ImpressionConfig {
experimentKey: string;
variationKey: string;
userId: string;
userAttributes?: UserAttributes;
clientEngine: string;
clientVersion: string;
configObj: ProjectConfig;
}
type VisitorAttribute = {
entityId: string;
key: string;
value: string | number | boolean;
}
type EventContext = {
accountId: string;
projectId: string;
revision: string;
clientName: string;
clientVersion: string;
anonymizeIP: boolean;
botFiltering: boolean | undefined;
}

interface ConversionConfig {
eventKey: string;
eventTags: import('../../shared_types').EventTags;
userId: string;
userAttributes: import('../../shared_types').UserAttributes;
clientEngine: string;
clientVersion: string;
configObj: ProjectConfig;
}
interface ImpressionEvent {
type: 'impression';
timestamp: number;
uuid: string;
user: {
id: string;
attributes: VisitorAttribute[];
};
context: EventContext;
layer: {
id: string;
};
experiment: {
id: string;
key: string;
} | null;
variation: {
id: string;
key: string;
} | null;
}

/**
* Creates an ImpressionEvent object from decision data
* @param {ImpressionConfig} config
* @return {ImpressionEvent} an ImpressionEvent object
*/
export function buildImpressionEvent(config: ImpressionConfig): import('@optimizely/js-sdk-event-processor').ImpressionEvent;
interface ConversionConfig {
eventKey: string;
eventTags?: EventTags;
userId: string;
userAttributes?: UserAttributes;
clientEngine: string;
clientVersion: string;
configObj: ProjectConfig;
}

/**
* Creates a ConversionEvent object from track
* @param {ConversionConfig} config
* @return {ConversionEvent} a ConversionEvent object
*/
export function buildConversionEvent(config: ConversionConfig): import('@optimizely/js-sdk-event-processor').ConversionEvent;
interface ConversionEvent {
type: 'conversion';
timestamp: number;
uuid: string;
user: {
id: string;
attributes: VisitorAttribute[];
};
context: EventContext;
experiment: {
id: string;
key: string;
};
event: {
id: string;
key: string;
};
revenue: number | null;
value: number | null;
tags: EventTags;
}

/**
* Creates an ImpressionEvent object from decision data
* @param {ImpressionConfig} config
* @return {ImpressionEvent} an ImpressionEvent object
*/
export function buildImpressionEvent(config: ImpressionConfig): ImpressionEvent;

/**
* Creates a ConversionEvent object from track
* @param {ConversionConfig} config
* @return {ConversionEvent} a ConversionEvent object
*/
export function buildConversionEvent(config: ConversionConfig): ConversionEvent;
Loading