Skip to content

Commit 01b50a2

Browse files
[FSSDK-10198] making isOdpIntegrated public (#930)
* odp not integrated log level change from error to info * odp not integrated log level back to prev state, except identifyUser * making isOdpIntegrated public * Adding JSDoc to newly exposed isODPIntegrated method * registerVuid method ODP integration log change from error to info * Update lib/optimizely/index.ts Co-authored-by: Mike Chu <104384559+mikechu-optimizely@users.noreply.github.com> --------- Co-authored-by: Mike Chu <104384559+mikechu-optimizely@users.noreply.github.com>
1 parent 43fea02 commit 01b50a2

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

lib/core/odp/odp_manager.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export abstract class OdpManager implements IOdpManager {
6565
* Promise that returns when the OdpManager is finished initializing
6666
*/
6767
private initPromise: Promise<unknown>;
68-
6968
private ready = false;
7069

7170
/**
@@ -126,7 +125,7 @@ export abstract class OdpManager implements IOdpManager {
126125

127126
this.onReady().then(() => {
128127
this.ready = true;
129-
if(this.isVuidEnabled() && this.status === Status.Running) {
128+
if (this.isVuidEnabled() && this.status === Status.Running) {
130129
this.registerVuid();
131130
}
132131
});
@@ -146,7 +145,7 @@ export abstract class OdpManager implements IOdpManager {
146145
}
147146

148147
if (!this.odpIntegrationConfig) {
149-
return Promise.reject(new Error('cannot start without ODP config'));
148+
return Promise.reject(new Error('cannot start without ODP config'));
150149
}
151150

152151
if (!this.odpIntegrationConfig.integrated) {
@@ -211,21 +210,21 @@ export abstract class OdpManager implements IOdpManager {
211210
* @returns {Promise<string[] | null>} A promise holding either a list of qualified segments or null.
212211
*/
213212
async fetchQualifiedSegments(userId: string, options: Array<OptimizelySegmentOption> = []): Promise<string[] | null> {
214-
if (!this.odpIntegrationConfig) {
215-
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE);
213+
if (!this.odpIntegrationConfig) {
214+
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE);
216215
return null;
217216
}
218217

219218
if (!this.odpIntegrationConfig.integrated) {
220-
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED);
219+
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED);
221220
return null;
222221
}
223222

224223
if (VuidManager.isVuid(userId)) {
225224
return this.segmentManager.fetchQualifiedSegments(ODP_USER_KEY.VUID, userId, options);
226225
}
227226

228-
return this.segmentManager.fetchQualifiedSegments(ODP_USER_KEY.FS_USER_ID, userId, options);
227+
return this.segmentManager.fetchQualifiedSegments(ODP_USER_KEY.FS_USER_ID, userId, options);
229228
}
230229

231230
/**
@@ -241,7 +240,7 @@ export abstract class OdpManager implements IOdpManager {
241240
}
242241

243242
if (!this.odpIntegrationConfig.integrated) {
244-
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED);
243+
this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED);
245244
return;
246245
}
247246

@@ -306,7 +305,7 @@ export abstract class OdpManager implements IOdpManager {
306305
}
307306

308307
if (!this.odpIntegrationConfig.integrated) {
309-
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_NOT_INTEGRATED);
308+
this.logger.log(LogLevel.INFO, ERROR_MESSAGES.ODP_NOT_INTEGRATED);
310309
return;
311310
}
312311

lib/optimizely/index.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ export default class Optimizely implements Client {
188188
this.nextReadyTimeoutId = 0;
189189
}
190190

191-
192191
/**
193-
* Returns the project configuration retrieved from projectConfigManager
192+
* Returns the project configuration retrieved from projectConfigManager
194193
* @return {projectConfig.ProjectConfig}
195194
*/
196195
getProjectConfig(): projectConfig.ProjectConfig | null {
@@ -1444,10 +1443,7 @@ export default class Optimizely implements Client {
14441443
createUserContext(userId?: string, attributes?: UserAttributes): OptimizelyUserContext | null {
14451444
const userIdentifier = userId ?? this.odpManager?.getVuid();
14461445

1447-
if (
1448-
userIdentifier === undefined ||
1449-
!this.validateInputs({ user_id: userIdentifier }, attributes)
1450-
) {
1446+
if (userIdentifier === undefined || !this.validateInputs({ user_id: userIdentifier }, attributes)) {
14511447
return null;
14521448
}
14531449

@@ -1671,7 +1667,7 @@ export default class Optimizely implements Client {
16711667
}
16721668

16731669
if (this.odpManager) {
1674-
this.odpManager.updateSettings(projectConfig.odpIntegrationConfig)
1670+
this.odpManager.updateSettings(projectConfig.odpIntegrationConfig);
16751671
}
16761672
}
16771673

@@ -1722,8 +1718,11 @@ export default class Optimizely implements Client {
17221718
this.logger.error(ERROR_MESSAGES.ODP_EVENT_FAILED, e);
17231719
}
17241720
}
1725-
1726-
private isOdpIntegrated(): boolean {
1721+
/**
1722+
* Checks if ODP (Optimizely Data Platform) is integrated into the project.
1723+
* @returns { boolean } `true` if ODP settings were found in the datafile otherwise `false`
1724+
*/
1725+
public isOdpIntegrated(): boolean {
17271726
return this.projectConfigManager.getConfig()?.odpIntegrationConfig?.integrated ?? false;
17281727
}
17291728

@@ -1751,7 +1750,7 @@ export default class Optimizely implements Client {
17511750
if (!this.odpManager) {
17521751
return null;
17531752
}
1754-
1753+
17551754
return await this.odpManager.fetchQualifiedSegments(userId, options);
17561755
}
17571756

lib/shared_types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,12 @@ export interface Client {
335335
getForcedVariation(experimentKey: string, userId: string): string | null;
336336
isFeatureEnabled(featureKey: string, userId: string, attributes?: UserAttributes): boolean;
337337
getEnabledFeatures(userId: string, attributes?: UserAttributes): string[];
338-
getFeatureVariable(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): FeatureVariableValue;
338+
getFeatureVariable(
339+
featureKey: string,
340+
variableKey: string,
341+
userId: string,
342+
attributes?: UserAttributes
343+
): FeatureVariableValue;
339344
getFeatureVariableBoolean(
340345
featureKey: string,
341346
variableKey: string,
@@ -371,6 +376,7 @@ export interface Client {
371376
close(): Promise<{ success: boolean; reason?: string }>;
372377
sendOdpEvent(action: string, type?: string, identifiers?: Map<string, string>, data?: Map<string, unknown>): void;
373378
getProjectConfig(): ProjectConfig | null;
379+
isOdpIntegrated(): boolean;
374380
}
375381

376382
export interface ActivateListenerPayload extends ListenerPayload {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy