Search code examples
androidoptimizely

How to use Optimizely.dispatchEvents() method from Optimizely Android SDK


The quickstart guide for the Optimizely Android SDK includes the following example:

private void userClickedImportantButton() {
      Optimizely.trackEvent("ImportantButtonClicked");
      Optimizely.dispatchEvents(); // Manually send the event logs back to the server
  }

This can be found here

However, the example is incorrect and doesn't actually work - it appears that dispatchEvents() is an instance method, not static method, of the Optimizely class.

What is the correct way to use it?


Solution

  • The Optimizely folks answered my question on their community forum post:

    https://community.optimizely.com/t5/Mobile-Apps/Android-how-to-use-Optimizely-dispatchEvents/m-p/10907#M121

    The answer is that dispatchEvents() is deprecated and you should use sendEvents() instead.