MCPcopy Create free account
hub / github.com/dailydotdev/apps / getServerFeatureValue

Function getServerFeatureValue

packages/shared/src/lib/serverFeatureValue.ts:18–45  ·  view source on GitHub ↗
({
  attributes,
  clientKey,
  feature,
  trackingCallback,
}: GetServerFeatureValueOptions<T>)

Source from the content-addressed store, hash-verified

16};
17
18export const getServerFeatureValue = async <T extends JSONValue>({
19 attributes,
20 clientKey,
21 feature,
22 trackingCallback,
23}: GetServerFeatureValueOptions<T>): Promise<T> => {
24 const { defaultValue, id } = feature;
25
26 if (!clientKey) {
27 return defaultValue;
28 }
29
30 const growthbook = new GrowthBook({
31 apiHost: process.env.GROWTHBOOK_API_HOST ?? DEFAULT_API_HOST,
32 attributes,
33 clientKey,
34 trackingCallback,
35 });
36
37 try {
38 await growthbook.loadFeatures({ timeout: DEFAULT_TIMEOUT });
39 return growthbook.getFeatureValue(id, defaultValue) as T;
40 } catch {
41 return defaultValue;
42 } finally {
43 growthbook.destroy();
44 }
45};

Callers 1

evaluateAgentSignupWallFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected