Skip to content

Commit 39eaa53

Browse files
committed
Add comprehensive documentation for new API endpoints and configuration options in the Optimizely Edge Agent v2. Introduced detailed summaries for GET and POST endpoints, including metrics and environment variable configurations. Enhanced the Postman collection with complete API references and examples, ensuring clarity for developers. Updated the README and various guides to reflect recent changes and improvements in the documentation structure.
1 parent 07c760f commit 39eaa53

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src-v2/services/implementations/ApiRouter.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,8 +2632,42 @@ export class ApiRouter {
26322632

26332633
this.logger.debug(`${this.logPrefix} Found ${flagKeys.length} flag keys for SDK key ${this.hashSensitiveValue(sdkKey)}`);
26342634

2635-
// Create user context
2636-
const userContext = { userId: finalUserId, attributes };
2635+
// Extract forced decisions from configuration and prepare user context
2636+
const config = this.configService.getConfig();
2637+
let userContextForcedDecisions: Record<string, { variationKey: string }> = {};
2638+
2639+
if (config.forcedDecisions) {
2640+
// Convert configuration forced decisions to the format expected by DecisionService
2641+
if (Array.isArray(config.forcedDecisions)) {
2642+
// Array format: [{ flagKey: "flag1", variationKey: "var1" }, ...]
2643+
for (const decision of config.forcedDecisions) {
2644+
if (decision.flagKey && decision.variationKey) {
2645+
userContextForcedDecisions[decision.flagKey] = { variationKey: decision.variationKey };
2646+
}
2647+
}
2648+
} else if (typeof config.forcedDecisions === 'object') {
2649+
// Object format: { "flag1": { "variationKey": "var1" }, ... }
2650+
for (const [flagKey, decision] of Object.entries(config.forcedDecisions)) {
2651+
if (decision && typeof decision === 'object' && (decision as any).variationKey) {
2652+
userContextForcedDecisions[flagKey] = { variationKey: (decision as any).variationKey };
2653+
}
2654+
}
2655+
}
2656+
2657+
if (Object.keys(userContextForcedDecisions).length > 0) {
2658+
this.logger.debug(`${this.logPrefix} [REQUEST:${requestId}] Processed forced decisions from config:`, {
2659+
flagCount: Object.keys(userContextForcedDecisions).length,
2660+
flags: Object.keys(userContextForcedDecisions)
2661+
});
2662+
}
2663+
}
2664+
2665+
// Create user context with forced decisions
2666+
const userContext = {
2667+
userId: finalUserId,
2668+
attributes,
2669+
forcedDecisions: userContextForcedDecisions
2670+
};
26372671

26382672
// Collect decide options from all input sources ONCE per request
26392673
const decideOptionsArr = this.collectDecideOptions(requestAdapter, requestBody || {}, urlParams);

0 commit comments

Comments
 (0)