Skip to main content
Version: 2.6.0

Manually setting feature control points

Aperture JavaScript SDK can be used to manually set feature control points within a JavaScript service.

To do so, first create an instance of ApertureClient. Agent host and port will be read from environment variables FN_AGENT_HOST and FN_AGENT_PORT, defaulting to localhost:8089.

export const apertureClient = new ApertureClient();

The created instance can then be used to start a flow:

// do some business logic to collect labels
var labelsMap = new Map().set("key", "value");

apertureClient
.StartFlow("feature-name", labelsMap)
.then((flow) => {
if (flow.ShouldRun()) {
// Do actual work
} else {
// handle flow rejection by Aperture Agent
flow.SetStatus(FlowStatus.Error);
}
flow.End();
})
.catch((e) => {
console.log(e);
res.send(`Error occurred: ${e}`);
});

For more context on using the Aperture JavaScript SDK to set feature control points, refer to the example app available in the repository.