OpenFeature
了解如何将 Sentry 与 OpenFeature 配合使用。
当前处于测试阶段
功能标志变更跟踪和功能标志评估跟踪当前处于公开测试阶段。
此集成仅在浏览器环境中工作。它仅从基于包的安装(例如 npm
或 yarn
)可用。
OpenFeature 集成会跟踪由 OpenFeature SDK 生成的功能标志评估。这些评估保存在内存中,并在发生错误时发送到 Sentry 进行审查和分析。目前,我们仅支持布尔标志评估。 此集成在 Sentry SDK 版本 8.43.0 或更高版本 中可用。
Import name: Sentry.openFeatureIntegration
and Sentry.OpenFeatureIntegrationHook
Before using this integration, you need to install and instrument the OpenFeature SDK in your app. Learn more by reading OpenFeature's SDK docs and provider docs.
Copied
import * as Sentry from "@sentry/browser";
import { OpenFeature } from "@openfeature/web-sdk";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [Sentry.openFeatureIntegration()],
});
OpenFeature.setProvider(new MyProviderOfChoice());
OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook());
const client = OpenFeature.getClient();
const result = client.getBooleanValue("test-flag", false); // evaluate with a default value
Sentry.captureException(new Error("Something went wrong!"));
访问 Sentry 网站并确认您的错误事件已记录功能标志 "test-flag" 及其值 "false"。