The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI Reference
Dev guideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

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:

  1. 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.
  2. 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.
  3. 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

The 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:

  1. Initializes the request configuration based on headers, query parameters, and the JSON body for POST requests in Agent Mode.
  2. Defines the set of supported query parameters for configuration.
  3. Initializes metadata configuration for logging and debugging purposes.
  4. Initializes configuration settings from HTTP headers.
  5. Initializes configuration settings from URL query parameters.
  6. 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.

SettingDescriptionHeadersQuery ParametersJSON Body
sdkKeyThe datafile SDK key for the Optimizely project.YesYesYes
overrideCacheIndicates whether to override the cache.YesYesYes
overrideVisitorIdIndicates whether to override the visitor ID. A new visitor ID is generated for every request. Used for development and testing.YesYesYes
attributesCustom attributes and audience conditions for the visitor.YesNoYes
eventTagsEvent tags for tracking and reporting.YesNoYes
datafileAccessTokenAccess token for retrieving the datafile.YesNoNo
enableOptimizelyHeaderIndicates whether to enable Optimizely Experimentation.YesNoNo
decideOptionsOptions for the decide function.YesNoNo
visitorIdThe visitor ID for the request.YesYesYes
trimmedDecisionsIndicates whether to trim the decisions.YesYesYes
enableFlagsFromKVIndicates whether to enable feature flags from the key-value store.YesNoYes
eventKeyThe event key for tracking and reporting.YesYesYes
datafileFromKVIndicates whether to retrieve the datafile from the key-value store.YesNoYes
enableRespMetadataHeaderIndicates whether to enable response metadata.YesNoNo
setResponseCookiesIndicates whether to set response cookies with bucketing decisions.YesYesYes
setResponseHeadersIndicates whether to set response headers with bucketing decisions.YesYesYes
setRequestHeadersIndicates whether to set request headers with bucketing decisions.YesYesYes
setRequestCookiesIndicates whether to set request cookies with bucketing decisions.YesYesYes
serverModeThe server mode for the agent (Edge or Agent).NoYesNo
flagKeysThe specific flag keys to evaluate.NoYes (multi-valued)Yes
enableResponseMetadataIndicates whether to enable response metadata.YesYesYes
decideAllIndicates whether to evaluate all flag keys.NoYesYes
disableDecisionEventIndicates whether to disable the decision event.NoYesYes
enabledFlagsOnlyIndicates whether to return only enabled flag keys.NoYesYes
includeReasonsIndicates whether to include reasons for flag decisions.NoYesYes
ignoreUserProfileServiceIndicates whether to ignore the user profile service.NoYesYes
excludeVariablesIndicates whether to exclude variables from the response.YesYesYes
forcedDecisionsForced decisions for specific flag keys.NoNoYes

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.