Skip to content

Commit 3ccb52f

Browse files
committed
Incorporate comments
1 parent 510bb95 commit 3ccb52f

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

packages/optimizely-sdk/lib/core/project_config/project_config_manager.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ interface ProjectConfigManagerConfig {
2929
* ProjectConfigManager provides project config objects via its methods
3030
* getConfig and onUpdate. It uses a DatafileManager to fetch datafiles. It is
3131
* responsible for parsing and validating datafiles, and converting datafile
32-
* JSON objects into project config objects.
32+
* string into project config objects.
3333
* @param {ProjectConfig} config
34-
* @param {Object|string} config.datafile
34+
* @param {string} config.datafile
3535
* @param {Object} config.datafileOptions
3636
* @param {Object} config.jsonSchemaValidator
3737
* @param {string} config.sdkKey

packages/optimizely-sdk/lib/core/project_config/project_config_manager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function getErrorMessage(maybeError, defaultMessage) {
4444
* ProjectConfigManager provides project config objects via its methods
4545
* getConfig and onUpdate. It uses a DatafileManager to fetch datafiles. It is
4646
* responsible for parsing and validating datafiles, and converting datafile
47-
* JSON objects into project config objects.
47+
* string into project config objects.
4848
* @param {Object} config
49-
* @param {Object|string=} config.datafile
49+
* @param {string} config.datafile
5050
* @param {Object=} config.datafileOptions
5151
* @param {Object=} config.jsonSchemaValidator
5252
* @param {string=} config.sdkKey

packages/optimizely-sdk/lib/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ declare module '@optimizely/optimizely-sdk' {
158158
* After the event has at least been queued for dispatch, call this function to return
159159
* control back to the Client.
160160
*/
161-
dispatchEvent: (event: Event, callback: () => void) => void;
161+
dispatchEvent: (event: Event, callback: (response: { statusCode: number; }) => void) => void;
162162
}
163163

164164
export type EventTags = {

packages/optimizely-sdk/lib/optimizely/index.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
***************************************************************************/
1616
import { sprintf, objectValues } from '@optimizely/js-sdk-utils';
1717
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
18-
// import {EventDispatcher} from '@optimizely/js-sdk-event-processor';
1918
import { FeatureFlag, FeatureVariable } from '../core/project_config/entities';
2019
import {
2120
UserAttributes,
2221
EventTags,
2322
OptimizelyConfig,
2423
UserProfileService,
2524
DatafileOptions,
26-
EventDispatcher
25+
EventDispatcher,
26+
OnReadyResult
2727
} from '../shared_types';
2828
import { Variation } from '../core/project_config/entities';
2929
import { createProjectConfigManager, ProjectConfigManager } from '../core/project_config/project_config_manager';
@@ -540,8 +540,7 @@ export default class Optimizely {
540540
*/
541541
private validateInputs(
542542
// TODO: Make feature_key, user_id, variable_key, experiment_key camelCase
543-
// stringInputs: Record<'feature_key' | 'user_id' | 'variable_key' | 'experiment_key', unknown>,
544-
stringInputs: unknown,
543+
stringInputs: Partial<Record<'feature_key' | 'user_id' | 'variable_key' | 'experiment_key' | 'event_key', unknown>>,
545544
userAttributes?: unknown,
546545
eventTags?: unknown
547546
): boolean {
@@ -1341,9 +1340,9 @@ export default class Optimizely {
13411340
timeoutValue = DEFAULT_ONREADY_TIMEOUT;
13421341
}
13431342

1344-
let resolveTimeoutPromise: (value?: { success: boolean; reason?: string | undefined; }) => void;
1345-
const timeoutPromise = new Promise(
1346-
function(resolve: (value?: { success: boolean; reason?: string | undefined; }) => void) {
1343+
let resolveTimeoutPromise: (value: OnReadyResult) => void;
1344+
const timeoutPromise = new Promise<OnReadyResult>(
1345+
(resolve) => {
13471346
resolveTimeoutPromise = resolve;
13481347
}
13491348
);
@@ -1357,7 +1356,7 @@ export default class Optimizely {
13571356
success: false,
13581357
reason: sprintf('onReady timeout expired after %s ms', timeoutValue),
13591358
});
1360-
}).bind(this);
1359+
});
13611360
const readyTimeout = setTimeout(onReadyTimeout, timeoutValue);
13621361
const onClose = function() {
13631362
resolveTimeoutPromise({

packages/optimizely-sdk/lib/shared_types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ export interface EventDispatcher {
4949
* After the event has at least been queued for dispatch, call this function to return
5050
* control back to the Client.
5151
*/
52-
dispatchEvent: (event: Event, callback: () => void) => void;
52+
dispatchEvent: (event: Event, callback: (response: { statusCode: number; }) => void) => void;
53+
}
54+
55+
export interface OnReadyResult {
56+
success: boolean;
57+
reason?: string;
5358
}
5459

5560
/**

0 commit comments

Comments
 (0)