use of com.kickstarter.libs.models.OptimizelyEnvironment in project android-oss by kickstarter.
the class ApplicationModule method provideOptimizely.
@Provides
@Singleton
@NonNull
ExperimentsClientType provideOptimizely(@ApplicationContext @NonNull final Context context, @NonNull final ApiEndpoint apiEndpoint, @NonNull final Build build) {
final OptimizelyEnvironment optimizelyEnvironment;
if (apiEndpoint == ApiEndpoint.PRODUCTION) {
optimizelyEnvironment = OptimizelyEnvironment.PRODUCTION;
} else if (apiEndpoint == ApiEndpoint.STAGING) {
optimizelyEnvironment = OptimizelyEnvironment.STAGING;
} else {
optimizelyEnvironment = OptimizelyEnvironment.DEVELOPMENT;
}
final OptimizelyManager optimizelyManager = OptimizelyManager.builder().withSDKKey(optimizelyEnvironment.getSdkKey()).withDatafileDownloadInterval(15, TimeUnit.MINUTES).withEventDispatchInterval(2L, TimeUnit.MILLISECONDS).build(context);
optimizelyManager.initialize(context, null, optimizely -> {
if (!optimizely.isValid()) {
FirebaseCrashlytics.getInstance().recordException(new Throwable("Optimizely failed to initialize."));
} else {
if (build.isDebug()) {
Timber.d(ApplicationModule.class.getSimpleName(), "🔮 Optimizely successfully initialized.");
}
context.sendBroadcast(new Intent(ExperimentsClientTypeKt.EXPERIMENTS_CLIENT_READY));
}
});
return new OptimizelyExperimentsClient(optimizelyManager, optimizelyEnvironment);
}
Aggregations