0

I try to follow documentation in Optimizely to get my react native app (@22.2) working but getting such bug.

 MainActivity.java:24: error: cannot find symbol
      Optimizely.startOptimizelyWithApiToken("xxxxxx", getApplication());
                ^
  symbol:   method startOptimizelyWithApiToken(String,Application)
  location: class Optimizely
1 error
:app:compileDebugJavaWithJavac

What is wrong and how can I debug . I try

adb logcat ReactNative:V ReactNativeJS:V

but it's not giving me any information

MarJano
  • 1,257
  • 2
  • 18
  • 39

2 Answers2

4

I an on the engineering team at Optimizely and we've released a brand new product called FullStack that is more geared towards developers. As part of the product we now offer a JavaScript SDK for running experiments in all JavaScript clients, including React Native.

To use you would install our SDK:

npm install optimizely-client-sdk

And then you can split traffic using our activate and track methods.

Here is an example:

var optimizely = require('optimizely-client-sdk');

// Initialize an Optimizely client
var optimizelyClientInstance = optimizely.createInstance({ datafile: datafile });


// ALTERNATIVELY, if you don't use CommonJS or npm, you can install the minified snippet and use the globally exported varible as follows:
var optimizelyClientInstance = window.optimizelyClient.createInstance({ datafile: datafile });


// Activate user in an experiment
var variation = optimizelyClientInstance.activate("my_experiment", userId);

if (variation === 'control') {
  // Execute code for variation A
} else if (variation === 'treatment') {
  // Execute code for variation B
} else {
  // Execute default code
}

// Track conversion event
optimizelyClientInstance.track("my_conversion", userId);

For more information please checkout our developer docs: https://developers.optimizely.com/x/solutions/sdks/introduction/index.html?language=javascript

0

i sorted problem is more about reading docs and using legacy:

compile ('com.optimizely:optimizely-legacy:+@aar') {
      transitive = true
    }

and then:

Optimizely.startOptimizely("xxxx", getApplication());
MarJano
  • 1,257
  • 2
  • 18
  • 39