Skip to content

Commit 2b495c5

Browse files
committed
Fix imports to avoid anti-pattern
1 parent a0805d7 commit 2b495c5

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
1818
import { LogHandler } from '@optimizely/js-sdk-logging';
19-
import { UserProfile, UserAttributes } from '@optimizely/optimizely-sdk';
20-
import { ProjectConfig } from '@optimizely/optimizely-sdk/lib/core/project_config';
21-
import { Experiment, Variation, FeatureFlag } from '@optimizely/optimizely-sdk/lib/core/project_config';
19+
import { ProjectConfig, Experiment, Variation, FeatureFlag } from '@optimizely/optimizely-sdk/lib/core/project_config';
2220

2321
export function createDecisionService(options: Options): DecisionService;
2422

@@ -27,6 +25,12 @@ declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
2725
save(profile: UserProfile): void;
2826
}
2927

28+
export type UserAttributes = {
29+
// TODO[OASIS-6649]: Don't use any type
30+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31+
[name: string]: any;
32+
}
33+
3034
interface DecisionService {
3135
getVariation(experimentKey: string, userId: string, attributes?: UserAttributes): string | null;
3236
getVariationForFeature(configObj: ProjectConfig, feature: FeatureFlag, userId: string, attributes: unknown): Decision;
@@ -46,4 +50,14 @@ declare module '@optimizely/optimizely-sdk/lib/core/decision_service' {
4650
variation: Variation | null;
4751
decisionSource: string;
4852
}
53+
54+
// Information about past bucketing decisions for a user.
55+
interface UserProfile {
56+
user_id: string;
57+
experiment_bucket_map: {
58+
[experiment_id: string]: {
59+
variation_id: string;
60+
};
61+
};
62+
}
4963
}

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

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
declare module '@optimizely/optimizely-sdk' {
1818
import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging';
1919
import { Experiment, Variation } from '@optimizely/optimizely-sdk/lib/core/project_config';
20+
import { UserProfileService, UserAttributes } from '@optimizely/optimizely-sdk/lib/core/decision_service';
2021
import * as enums from '@optimizely/optimizely-sdk/lib/utils/enums';
2122
import * as logging from '@optimizely/optimizely-sdk/lib/plugins/logger';
2223
export { enums, logging };
@@ -136,11 +137,6 @@ declare module '@optimizely/optimizely-sdk' {
136137
dispatchEvent: (event: Event, callback: () => void) => void;
137138
}
138139

139-
export interface UserProfileService {
140-
lookup: (userId: string) => UserProfile;
141-
save: (profile: UserProfile) => void;
142-
}
143-
144140
// NotificationCenter-related types
145141
export interface NotificationCenter {
146142
addNotificationListener<T extends ListenerPayload>(
@@ -165,12 +161,6 @@ declare module '@optimizely/optimizely-sdk' {
165161
logEvent: Event;
166162
}
167163

168-
export type UserAttributes = {
169-
// TODO[OASIS-6649]: Don't use any type
170-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
171-
[name: string]: any;
172-
};
173-
174164
export type EventTags = {
175165
[key: string]: string | number | boolean;
176166
};
@@ -181,16 +171,6 @@ declare module '@optimizely/optimizely-sdk' {
181171
logEvent: Event;
182172
}
183173

184-
// Information about past bucketing decisions for a user.
185-
export interface UserProfile {
186-
user_id: string;
187-
experiment_bucket_map: {
188-
[experiment_id: string]: {
189-
variation_id: string;
190-
};
191-
};
192-
}
193-
194174
/**
195175
* Optimizely Config Entities
196176
*/

0 commit comments

Comments
 (0)