Configuration settings
How to configure and customize Optimizely Edge Agent.
Beta
Optimizely Edge Agent is in beta. Apply on the Optimizely beta signup page or contact your Customer Success Manager.
Optimizely Edge Agent is a versatile solution that lets you configure and customize your experimentation and personalization efforts. The agent operates in two modes
- Edge Mode for handling
GET
requests. - Agent Mode for handling
POST
requests.
Optimizely Edge Agent supports various methods for configuring its settings to accommodate different implementation strategies and provide flexibility.
Configuration methods
Optimizely Edge Agent can be configured using three different methods:
- HTTP Headers – Configuration settings can be passed as HTTP headers in the request. This method is supported for Edge Mode (
GET
requests) and Agent Mode (POST
requests). - Query Parameters – Configuration settings can be passed as query parameters in the request URL. This method is supported for Edge Mode and Agent Mode.
- JSON Body (Agent Mode only) – For
POST
requests in Agent Mode, configuration settings can also be passed as a JSON object in the request body.
Priority of configuration settings
When Optimizely Edge Agent processes a request, it reads the configuration settings in a specific order of priority:
- HTTP Headers – The agent first checks for configuration settings in the HTTP headers. If a setting is found in the headers, it takes precedence over the same setting defined in query parameters or the JSON body.
- Query Parameters – If a configuration setting is not found in the HTTP headers, the agent checks the query parameters. If a setting is found in the query parameters and has not been previously defined in the headers, it is used.
- JSON Body (Agent Mode only) – For
POST
requests in Agent Mode, if a configuration setting is not found in the headers or query parameters, the agent will look for it in the JSON body of the request.
By following this order of priority, Optimizely Edge Agent lets you have granular control over the configuration settings, enabling you to override settings at various levels based on their specific requirements.
requestConfig.js
module
requestConfig.js
moduleThe requestConfig.js
module is responsible for reading and setting the necessary configuration settings that Optimizely Edge Agent uses to operate. It handles the extraction and parsing of configuration settings from the request's headers, query parameters, and JSON body (in Agent Mode).
In addition to the standard configuration settings, you can add any custom configuration settings that you want to use in your specific implementation. These custom settings will automatically be available in the requestConfig
object that is accessible in every handler and module throughout Optimizely Edge Agent.
This lets you have flexibility and extensibility, as you can define and utilize their own configuration settings based on their specific requirements. The requestConfig
object acts as a centralized repository for all configuration settings, making it convenient to access and use them in various parts of the codebase.
To add custom configuration settings, you can include them in the request's headers, query parameters, or JSON body (in Agent Mode), following the same format as the standard configuration settings. The requestConfig.js
module will automatically extract and parse these custom settings, making them readily available in the requestConfig
object.
By providing this capability, Optimizely Edge Agent empowers you to tailor the behavior and functionality of your implementation according to your specific needs, promoting customization and adaptability.
The requestConfig.js
module performs the following tasks:
- Initializes the request configuration based on headers, query parameters, and the JSON body for
POST
requests in Agent Mode. - Defines the set of supported query parameters for configuration.
- Initializes metadata configuration for logging and debugging purposes.
- Initializes configuration settings from HTTP headers.
- Initializes configuration settings from URL query parameters.
- If the request method is
POST
and the content type is JSON (Agent Mode), it loads the request body and initializes configuration settings from it.
By centralizing the configuration handling in the requestConfig.js
module, Optimizely Edge Agent ensures consistent and efficient settings management across different modes and request methods.
Configuration settings
The following table provides an overview of the available configuration settings for Optimizely Edge Agent.
Setting | Description | Headers | Query Parameters | JSON Body |
---|---|---|---|---|
sdkKey | The datafile SDK key for the Optimizely project. | Yes | Yes | Yes |
overrideCache | Indicates whether to override the cache. | Yes | Yes | Yes |
overrideVisitorId | Indicates whether to override the visitor ID. A new visitor ID is generated for every request. Used for development and testing. | Yes | Yes | Yes |
attributes | Custom attributes and audience conditions for the visitor. | Yes | No | Yes |
eventTags | Event tags for tracking and reporting. | Yes | No | Yes |
datafileAccessToken | Access token for retrieving the datafile. | Yes | No | No |
enableOptimizelyHeader | Indicates whether to enable Optimizely Experimentation. | Yes | No | No |
decideOptions | Options for the decide function. | Yes | No | No |
visitorId | The visitor ID for the request. | Yes | Yes | Yes |
trimmedDecisions | Indicates whether to trim the decisions. | Yes | Yes | Yes |
enableFlagsFromKV | Indicates whether to enable feature flags from the key-value store. | Yes | No | Yes |
eventKey | The event key for tracking and reporting. | Yes | Yes | Yes |
datafileFromKV | Indicates whether to retrieve the datafile from the key-value store. | Yes | No | Yes |
enableRespMetadataHeader | Indicates whether to enable response metadata. | Yes | No | No |
setResponseCookies | Indicates whether to set response cookies with bucketing decisions. | Yes | Yes | Yes |
setResponseHeaders | Indicates whether to set response headers with bucketing decisions. | Yes | Yes | Yes |
setRequestHeaders | Indicates whether to set request headers with bucketing decisions. | Yes | Yes | Yes |
setRequestCookies | Indicates whether to set request cookies with bucketing decisions. | Yes | Yes | Yes |
serverMode | The server mode for the agent (Edge or Agent). | No | Yes | No |
flagKeys | The specific flag keys to evaluate. | No | Yes (multi-valued) | Yes |
enableResponseMetadata | Indicates whether to enable response metadata. | Yes | Yes | Yes |
decideAll | Indicates whether to evaluate all flag keys. | No | Yes | Yes |
disableDecisionEvent | Indicates whether to disable the decision event. | No | Yes | Yes |
enabledFlagsOnly | Indicates whether to return only enabled flag keys. | No | Yes | Yes |
includeReasons | Indicates whether to include reasons for flag decisions. | No | Yes | Yes |
ignoreUserProfileService | Indicates whether to ignore the user profile service. | No | Yes | Yes |
excludeVariables | Indicates whether to exclude variables from the response. | Yes | Yes | Yes |
forcedDecisions | Forced decisions for specific flag keys. | No | No | Yes |
Conclusion
Optimizely Edge Agent provides a flexible and powerful way to configure experimentation and personalization settings. By supporting different configuration methods (headers, query parameters, and JSON body) and prioritizing them in a specific order, the agent lets you adapt the configuration to your specific needs and implementation strategies.
The requestConfig.js
module plays a crucial role in handling the configuration settings, ensuring that the agent operates with the correct parameters based on the request's mode and method. By understanding the available configuration settings and their supported methods, you can effectively leverage Optimizely Edge Agent to optimize your experimentation and personalization efforts.
Updated 9 days ago