@datadog/openfeature-node-server

中文文档
2.7.0发布于 2026/10/30Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2351.6万

Node.js server bindings for OpenFeature (wraps @datadog/flagging-core)

原始使用文档
文档目录3 节
  1. Standalone Configuration Helpers
  2. Fetch Options and Errors
  3. End-user license agreement

Datadog OpenFeature Node.js Server Client

This package provides OpenFeature integration for Node.js server environments and is designed exclusively for internal Datadog use. Support is not provided for external organizations or third-party usage.

Standalone Configuration Helpers

Requires Node.js 18 or newer. Fetch and parse rules without initializing a tracer or provider. The customer-facing dd-trace/openfeature entrypoint is a separate follow-up; these examples use the internal package.

import { fetchRulesConfiguration, configurationToString } from '@datadog/openfeature-node-server/rules-based'

// The server distribution channel is the default. Rules do not depend on an evaluation context.
const configuration = await fetchRulesConfiguration({ apiKey, env: 'production' })

// For browser bootstrap data, explicitly fetch client-distributed rules.
const clientConfiguration = await fetchRulesConfiguration({
  distributionChannel: 'client',
  clientToken,
  env: 'production',
})
const wire = configurationToString(clientConfiguration)
// Pass wire through the framework's safe SSR data serializer, not raw inline HTML.

Only forward client-distributed configuration to the browser. Serialization does not remove server-only flags. The client endpoint's access controls and opt-in requirements still apply.

Initialize the browser provider from the serialized configuration:

import { configurationFromString, DatadogCoreProvider } from '@datadog/openfeature-browser/rules-based'
import { OpenFeature } from '@openfeature/web-sdk'

const provider = new DatadogCoreProvider()
provider.setConfiguration(configurationFromString(wire))
await OpenFeature.setProviderAndWait(provider, context)

The returned FlagsConfiguration is not the legacy UFC JSON accepted by DatadogNodeServerProvider.setConfiguration(). The existing Node provider is unchanged, and importing it from the root entrypoint does not load the protobuf decoder.

Fetch Options and Errors

  • distributionChannel selects the configuration channel to fetch, not where the helper runs. It defaults to server; use client when preparing configuration for browser or mobile SDKs.
  • site defaults to datadoghq.com.
  • fetch overrides global Fetch. Custom transports must honor signal and redirect: 'manual'; redirects are rejected to protect credentials.
  • timeoutMs defaults to 5000 and covers the request and response-body read. signal supports caller cancellation and earlier deadlines.
  • Failures throw ConfigurationFetchError with a code and, for HTTP errors, status. Timeouts use timeout; other caller cancellations use cancelled.

Applications own retries, polling, storage, tracking, and fallback.

End-user license agreement

https://www.datadoghq.com/legal/eula

版本与发布记录

@datadog/openfeature-node-server 共发布 33 个版本,首次发布于 2025/09/23;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.7.0latest2026/10/3012 天前
2.6.02026/10/2814 天前
2.5.02026/10/1527 天前
2.4.02026/09/241 个月前
2.3.02026/09/151 个月前
2.2.02026/08/222 个月前

其他发布通道:preview → 0.1.0-preview.14。

关于 @datadog/openfeature-node-server 的常见问题

@datadog/openfeature-node-server 是什么?

Node.js server bindings for OpenFeature (wraps @datadog/flagging-core)

如何安装 @datadog/openfeature-node-server?

在项目目录运行 npm install @datadog/openfeature-node-server,或使用 pnpm add / yarn add / bun add。

@datadog/openfeature-node-server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@datadog/openfeature-node-server 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@datadog/openfeature-node-server 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@datadog/openfeature-node-server 可以商用吗?

@datadog/openfeature-node-server 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@datadog/openfeature-node-server 的下载量有多少?

根据 npm 官方下载统计,@datadog/openfeature-node-server 在 2026/10/12 – 2026/11/10 这 30 天内被下载 23,515,670 次,日均约 783,856 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@datadog/openfeature-node-server 还在维护吗?

最新版本 2.7.0 发布于 2026/10/30(12 天前);至今共发布 33 个版本,其中过去 12 个月发布了 21 个;首次发布于 2025/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。