Proxy Feature Flag SDK Traffic

This product is not supported for your selected Datadog site. ().

Overview

The Datadog Feature Flag SDK makes two types of outbound network requests from your application:

  1. Flag configuration download: The SDK fetches precomputed flag assignments from the Datadog CDN at startup and when the evaluation context changes. This request determines which flag variants are returned to your application.
  2. Event uploads: The SDK sends exposure and evaluation event data to Datadog intake endpoints.

You can route either or both of these request types through a proxy on your own domain. Common reasons to use a proxy include:

  • Network policies that restrict direct access to third-party domains from client devices
  • Data residency or compliance requirements
  • Ad-blocker avoidance for browser applications
The code samples on this page use the US1 site (datadoghq.com) as an example. Replace the Datadog domains with the corresponding values for your Datadog site.

Configure the proxy

Pass custom endpoint URLs to FlagsConfiguration.Builder before calling Flags.enable().

Flag configuration proxy

To route the flag configuration download through your proxy, call useCustomFlagEndpoint with the full URL your proxy exposes. The SDK sends a POST request to this URL with the evaluation context in the body.

Application.kt

import com.datadog.android.flags.FlagsConfiguration

val flagsConfig = FlagsConfiguration.Builder()
    .useCustomFlagEndpoint("https://proxy.example.com/precompute-assignments")
    .build()

Flags.enable(flagsConfig)

Your proxy must forward this request to the Datadog CDN: https://preview.ff-cdn.datadoghq.com/precompute-assignments (replace the subdomain as needed for your Datadog site). Pass through the request body and all headers unchanged.

Event upload proxy

To route exposure and evaluation event uploads through your proxy, call the corresponding builder methods with the full URL of your proxy endpoint.

Application.kt

import com.datadog.android.flags.FlagsConfiguration

val flagsConfig = FlagsConfiguration.Builder()
    .useCustomFlagEndpoint("https://proxy.example.com/precompute-assignments")
    .useCustomExposureEndpoint("https://proxy.example.com/api/v2/exposures")
    .useCustomEvaluationEndpoint("https://proxy.example.com/api/v2/flagevaluation")
    .build()

Flags.enable(flagsConfig)

Your proxy must forward each request to the corresponding Datadog intake endpoint for your Datadog site (the following table uses the US1 site as an example):

Proxy pathForward to
/api/v2/exposureshttps://api.datadoghq.com/api/v2/exposures
/api/v2/flagevaluationhttps://api.datadoghq.com/api/v2/flagevaluation

Set custom endpoint URLs on Flags.Configuration before calling Flags.enable(with:).

Flag configuration proxy

To route the flag configuration download through your proxy, set customFlagsEndpoint to the full URL your proxy exposes. The SDK sends a POST request to this URL with the evaluation context in the body.

AppDelegate.swift

import DatadogFlags

let flagsConfig = Flags.Configuration(
    customFlagsEndpoint: URL(string: "https://proxy.example.com/precompute-assignments")
)

Flags.enable(with: flagsConfig)

Your proxy must forward this request to the Datadog CDN: https://preview.ff-cdn.datadoghq.com/precompute-assignments (replace the subdomain as needed for your Datadog site). Pass through the request body and all headers unchanged.

To attach additional HTTP headers to flag configuration requests (for example, for authentication at your proxy), set customFlagsHeaders.

AppDelegate.swift

let flagsConfig = Flags.Configuration(
    customFlagsEndpoint: URL(string: "https://proxy.example.com/precompute-assignments"),
    customFlagsHeaders: ["X-Proxy-Token": "<YOUR_PROXY_TOKEN>"]
)

Event upload proxy

To route exposure and evaluation event uploads through your proxy, set customExposureEndpoint and customEvaluationEndpoint.

AppDelegate.swift

let flagsConfig = Flags.Configuration(
    customFlagsEndpoint: URL(string: "https://proxy.example.com/precompute-assignments"),
    customExposureEndpoint: URL(string: "https://proxy.example.com/api/v2/exposures"),
    customEvaluationEndpoint: URL(string: "https://proxy.example.com/api/v2/flagevaluation")
)

Flags.enable(with: flagsConfig)

Your proxy must forward each request to the corresponding Datadog intake endpoint for your Datadog site (the following table uses the US1 site as an example):

Proxy pathForward to
/api/v2/exposureshttps://api.datadoghq.com/api/v2/exposures
/api/v2/flagevaluationhttps://api.datadoghq.com/api/v2/flagevaluation

Pass a FlagsConfiguration object to DdFlags.enable().

Flag configuration proxy

To route the flag configuration download through your proxy, set customFlagsEndpoint to the base URL of your proxy. The SDK appends /precompute-assignments to this value automatically and sends a POST request with the evaluation context in the body.

App.tsx

import { DdFlags } from '@datadog/mobile-react-native';

await DdFlags.enable({
    customFlagsEndpoint: 'https://proxy.example.com',
    // SDK sends POST to: https://proxy.example.com/precompute-assignments
});

Your proxy must forward this request to the Datadog CDN: https://preview.ff-cdn.datadoghq.com/precompute-assignments (replace the subdomain as needed for your Datadog site). Pass through the request body and all headers unchanged.

Event upload proxy

To route exposure event uploads through your proxy, set customExposureEndpoint to the base URL of your proxy. The SDK appends /api/v2/exposures to this value automatically.

App.tsx

await DdFlags.enable({
    customFlagsEndpoint: 'https://proxy.example.com',
    customExposureEndpoint: 'https://proxy.example.com',
    // SDK sends POST to: https://proxy.example.com/api/v2/exposures
});

Your proxy must forward exposure requests to the corresponding Datadog intake endpoint for your Datadog site; for example, for the US1 site use https://api.datadoghq.com/api/v2/exposures.

The React Native SDK does not expose a customEvaluationEndpoint option. Evaluation events are sent through the underlying native Android or iOS SDK and cannot be routed through a custom proxy endpoint.

Pass configuration options to DatadogBrowserFlagging.init().

Flag configuration proxy

To route the flag configuration download through your proxy, set flaggingProxy to the URL of your proxy endpoint. The SDK sends a POST request with the evaluation context in the body directly to this URL, replacing the default Datadog CDN endpoint.

index.js

import { DatadogBrowserFlagging } from '@datadog/browser-flagging';

DatadogBrowserFlagging.init({
    clientToken: '<CLIENT_TOKEN>',
    site: 'datadoghq.com',
    flaggingProxy: 'https://proxy.example.com/precompute-assignments',
});

Your proxy must forward this request to the Datadog CDN: https://preview.ff-cdn.datadoghq.com/precompute-assignments (replace the subdomain as needed for your Datadog site). Pass through the request body and headers unchanged. The SDK includes dd-client-token and dd-application-id headers automatically.

To add custom headers to the flag configuration request (for example, for authentication at your proxy), use customHeaders:

index.js

DatadogBrowserFlagging.init({
    clientToken: '<CLIENT_TOKEN>',
    site: 'datadoghq.com',
    flaggingProxy: 'https://proxy.example.com/precompute-assignments',
    customHeaders: { 'X-Proxy-Token': '<YOUR_PROXY_TOKEN>' },
});

Event upload proxy

Browser flag event data (exposures and evaluations) is sent through the standard Browser SDK intake pipeline. To route this traffic through a proxy, set the proxy option to a URL on your domain.

index.js

DatadogBrowserFlagging.init({
    clientToken: '<CLIENT_TOKEN>',
    site: 'datadoghq.com',
    flaggingProxy: 'https://proxy.example.com/precompute-assignments',
    proxy: 'https://proxy.example.com/intake',
});

The SDK appends a ddforward query parameter to each request sent to your proxy. This parameter contains the URL-encoded path and query string that your proxy must forward to. For example:

POST https://proxy.example.com/intake?ddforward=%2Fapi%2Fv2%2Fexposures%3Fddsource%3Dbrowser...

Your proxy decodes the ddforward value and constructs the Datadog intake URL:

https://browser-intake-datadoghq.com/api/v2/exposures?ddsource=browser...

The intake origin varies by Datadog site. For example, for datadoghq.eu it is https://browser-intake-datadoghq.eu. Forward the POST body unchanged and add an X-Forwarded-For header with the client IP for accurate geolocation. Remove any sensitive headers such as cookie before forwarding.

The proxy option also accepts a function that receives the decoded path and parameters and returns the full proxy URL. See Proxy Browser RUM Data for the full function signature.

Further reading