Skip to content

Instantly share code, notes, and snippets.

@RBonaventure
Last active November 10, 2017 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RBonaventure/9ef0867bb5ee89a5bb2f6d14f3551206 to your computer and use it in GitHub Desktop.
Save RBonaventure/9ef0867bb5ee89a5bb2f6d14f3551206 to your computer and use it in GitHub Desktop.
/*
* Les deux traces et les URLs associées :
* A : ReactJS
* B : Plain HTML
*/
private enum RenderingType {
REACT_JS(Traces.REACT_JS_TIME, "https://pot-pourri-android.firebaseapp.com/reactjs"),
PLAIN_HTML(Traces.PLAIN_HTML_TIME, "https://pot-pourri-android.firebaseapp.com/html");
private String mTraceName;
private String mBackendUrl;
RenderingType(String traceName, String backendUrl) {
mTraceName = traceName;
mBackendUrl = backendUrl;
}
String getTraceName() {
return mTraceName;
}
String getBackendUrl() {
return mBackendUrl;
}
}
// Récupération de la variante assignée au device par l'algorithme d'A/B Testing
mRenderingType = mFirebaseRemoteConfig.getBoolean(
RemoteConfig.REACTJS_ENABLED_KEY) ? RenderingType.REACT_JS : RenderingType.PLAIN_HTML;
// Utilisation la Trace adéquate
mRenderingTrace = FirebasePerformance.getInstance().newTrace(mRenderingType.getTraceName());
// Affichage du contenu A ou B
mWebView.loadUrl(mRenderingType.getBackendUrl());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment