https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
c

curved-accountant-6477

03/18/2024, 1:38 PM
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

future-teacher-7046

03/18/2024, 1:43 PM
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

curved-accountant-6477

03/18/2024, 1:44 PM
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

future-teacher-7046

03/18/2024, 1:47 PM
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

curved-accountant-6477

03/18/2024, 1:48 PM
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

future-teacher-7046

03/18/2024, 1:51 PM
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

curved-accountant-6477

03/18/2024, 6:15 PM
cool thanks - we’ll take a look
5 Views