If I read the first mistake correctly, then getFeatureFlag() has the side-effect to count how often it was called and uses this to calculate the outcome of the experiment? Wow. I don't know what to say....
"posthog.getFeatureFlag('experiment-key')"
doesn't look like it's actually performing a mutation.