Hello, we use the react sdk and there’s many cases...
# ask-questions
c
Hello, we use the react sdk and there’s many cases that we want to check
getFeatureValue
but avoid any analytics calls. Is there a workaround to do that —without patching the sdk ourselves—, would appreciate any pointers. Especially when the value returned hasn’t changed. The main motivation is to reduce high-number of events from a billing/scale perspective.
👁️ 1
f
Hi Leon. Do you have a Single Page App? We already de-dupe tracking calls in the React SDK. So calling
getFeatureValue
a bunch of times for a feature should only be firing the callback once.
c
we’re on React Native, sorry should’ve added that
calls are definitly not deduped for us, both in same session as well as on multiple app opens. let me check which version we’re on:
@growthbook/growthbook-react@0.20.0
maybe the deduping uses some web APIs that don’t work as expected on RN?
f
Ok, the de-duping might not work with React Native. What I'd probably recommend is to do that yourself in your trackingCallback. If you can persist a list of previously fired calls on the device, you can add something like this to your callback:
Copy code
if (previouslyFired.includes(`${experiment.key}::${result.key}`)) return;
previouslyFired.push(`${experiment.key}::${result.key}`);

// Fire your analytics call here
c
can you point me at where this happens on the react SDK code? maybe we can try to submit a PR for RN, or at least keep the logic very similar
f
https://github.com/growthbook/growthbook/blob/main/packages/sdk-js/src/GrowthBook.ts#L1240 We're basically doing the above, but just keeping track in memory in the GrowthBook instance. So if you're creating new GrowthBook instances on every render or something like that, it could also be causing issues
c
cool thanks - we’ll take a look