Skip to content

createEntitlementsHook

function createEntitlementsHook<C>(engine, options?): Hook;

Defined in: src/flags.ts:171

An OpenFeature hook that enriches every evaluation context with the customer’s entitlement attributes (attributes already in the context win).

Type Parameter
C extends AnyCatalog
Parameter Type
engine Entitlements<C>
options? EntitlementsHookOptions

Hook

import { OpenFeature } from "@openfeature/server-sdk";
import { createEntitlementsHook } from "@xtandard/entitlements/flags";
OpenFeature.addHooks(createEntitlementsHook(ent, { customerKey: "orgId" }));
// a flags rule can now target `entitlement.export_pdf == true` or `plan in ["pro"]`