Skip to main content

@uniformdev/context-edge-akamai

Uniform enables you to create an Akamai EdgeWorker that implements edge-side personalization. This is a worker that runs under your Akamai account and leverages the Akamai (and other) capabilities that you need.

The basic logic for an EdgeWorker that supports edge-side personalization is:

  1. Get the Uniform Context manifest
  2. Create the edge context
  3. Create an instance of the edge handler
  4. Run the edge handler
  5. Create a response
  6. Return the response
tip

Uniform provides the code for a basic EdgeWorker, but you should consider this a starting point. You can modify and enhance it as you need. For example, you could add your own logic to enrich the context, or to modify the response after the edge handler runs.

Functions

createAkamaiEdgeContext

Creates the primary state object used during and after the classification (e.g. tracking) and contextualization (e.g. personalization) processes.
- Parameters
manifestManifestV2
Uniform Context manifest.
requestEW.ResponseProviderRequest
The request that Akamai routed to the EdgeWorker.
optionsContextOptions (optional)
+ show child attributes
- Return
ContextThe context for the edge handler.
Example
import { createAkamaiEdgeContext } from '@uniformdev/context-edge-akamai';

export async function responseProvider(request) {
const manifest = ...
const context = createAkamaiEdgeContext({ request, manifest });
...
}

createAkamaiProxyEdgeHandler

Creates a new edge handler that can make a sub-request to the CDN, execute personalization instructions included in the CDN response, and create a new response that is personalized.
- Parameters
None
- Return
AkamaiProxyEdgeHandlerThe proxy edge handler for Akamai.
Example
import { createAkamaiProxyEdgeHandler } from '@uniformdev/context-edge-akamai';

export async function responseProvider(request) {
...
const handler = createAkamaiProxyEdgeHandler();
...
}

createOriginFetcher

The proxy edge handler makes requests to the origin using an origin fetcher. This function lets you create a customized origin fetcher.
- Parameters
None
- Return
OriginFetcherThe origin fetcher.
Example
import { createOriginFetcher } from '@uniformdev/context-edge-akamai';

export async function responseProvider(request) {
...
const fetcher = createOriginFetcher();
...
}

Types

AkamaiProxyEdgeHandler

The function that implements the edge handler.
- Parameters
contextContext
Primary state object used during and after the classification (e.g. tracking) and contextualization (e.g. personalization) processes.
requestEW.ResponseProviderRequest
The request that Akamai routed to the EdgeWorker.
fetchOriginOriginFetcher (optional)
quirksAkamaiQuirksConfig (optional)
The values from Akamai that you want to be available as quirks.
- Return
Promise<HandlerResponse>The personalized response created by the edge handler.

AkamaiQuirksConfig

This type is used when calling the edge handler. It is used to specify which values from Akamai should be exposed as quirks.

- Properties
cpCodeboolean (optional)
If true, the CP code ID for the request is exposed as a quirk aka-cpCode.
devicestring[] (optional)
This property allows you to specify which Device Characterization values to expose as quirks.
+ show valid values
missingQuirkValuestring (optional)
By default, any quirk that is specified in the configuration that Akamai is unable to provide a value for is set to unknown. This property allows you to change this default value.
userLocationstring[] (optional)
This property allows you to specify which EdgeScape values to expose as quirks.
+ show valid values
Example
{
  "userLocation": [
    "city",
    "country"
  ],
  "device": [
    "isMobile"
  ]
}

HandlerResponse

An object that represents the result of the edge handler running. The personalized response is included in this object, but this object includes more than just the personalized response.
- Properties
processedboolean
If true, the edge handler processed the response from the CDN. If false, the edge handler did no additional processing and simply returned the response from the sub-request.
responseobject
The response from the sub-request.
+ show child attributes

OriginFetcher

info

Coming soon.