Closed cafesanu closed 2 years ago
I'm not sure I understand how your application is using the SDK. Specifically, in this part—
Since LaunchDarkly asks for all the flags at the same time, I get FlagA and FlagB variations in Page A
—it is true that "LaunchDarkly asks for all the flags at the same time" in terms of how the network request is done by the SDK; but that does not cause the analytics data to record a request for every flag, as it sounds like you are assuming it does. The evaluation count per flag is updated when you explicitly call allFlags
to get all flag values at once, or call variation
for a specific flag. I'm guessing that maybe you are calling allFlags
? In any case, my point is that whatever you're doing to cause the results you're describing is definitely not the only way to use the SDK. It is designed to allow you to track usage independently per flag— otherwise analytics would not be very useful.
If you want to call allFlags
but do not want it to affect the request count for any flag, you can set the sendEventsOnlyForVariation
option as described here.
That did the trick! I was not aware that requesting one single variation would record a visitor just for that variation. The part that confused me was this in here https://launchdarkly.github.io/js-client-sdk/interfaces/_launchdarkly_js_client_sdk_.ldclient.html#variation
In the client-side JavaScript SDKs, this is always a fast synchronous operation because all of the feature flag values for the current user have already been loaded into memory.
So I thought getting all the flags via allFlags
or getting one single variation was the same at the end of the day since all flags are being loaded anyway.
I ended up using sendEventsOnlyForVariation: true
in the LaunchdarklyProvider, getting all flags at the same time on load (since now the are not being added to analytics and calling client.variation
to "record" the visitor whenever I get to the actual test page.
Thank you very much! You truly helped :)
Is your feature request related to a problem? Please describe. I am unsure if this is a feature request or this already exists, but I couldn't find a solution so here I am... Let me know if this exists in any way 🙂
Describe the solution you'd like Solution 1 (ideal):
client.recordVisitor("flagB")
Solution 2 (not ideal, but would work):
ldClient.variation("flagB", false, true/false)
where the 3rd parameter is telling launchardkly whether to record the visitor in the resultsDescribe alternatives you've considered I have considered passing information via the custom key in the
LDUser
object with the key equal to the path of the current page and the value beingtrue
. So if the user visits pageA and PageB, I can update thecustom
key each time a user arrives to a new page. Somthin likethis way, the custom object would look something like this eventually:
However:
Additional context
Thank you very much!