UNPKG

dd-trace

Version:

Datadog APM tracing client for JavaScript

34 lines (28 loc) 1.03 kB
'use strict' const RemoteConfigCapabilities = require('../remote_config/capabilities') /** * Configures remote config handlers for openfeature feature flagging * * @param {import('../remote_config')} rc - RemoteConfig instance * @param {() => import('./flagging_provider')} getOpenfeatureProxy * @param {boolean} subscribe - Whether Agent Remote Config owns UFC delivery */ function enable (rc, getOpenfeatureProxy, subscribe) { if (!subscribe) return rc.updateCapabilities(RemoteConfigCapabilities.FFE_FLAG_CONFIGURATION_RULES, true) /** * @param {string} action * @param {import('@datadog/openfeature-node-server').UniversalFlagConfigurationV1} conf */ const updateConfiguration = (action, conf) => { if (action === 'apply' || action === 'modify') { getOpenfeatureProxy().setConfiguration(conf) } else if (action === 'unapply') { getOpenfeatureProxy().setConfiguration(undefined) } } rc.setProductHandler('FFE_FLAGS', updateConfiguration) } module.exports = { enable, }