Huawei AGC-Remote Configuration Class AB Test Practical Guide

Huawei AppGallery Connect service provides the AB test function, which can be used for Push notification or remote configuration, and create a control test test to check and compare the difference between different solutions, which can help colleagues in products or operations, more data to choose the most best plan.

The following is a practical guide for using the remote configuration AB test from scratch on the Huawei AGC platform. If there is something wrong, please give more guidance.

1. Prerequisites: Integrated Remote Configuration

First of all, using the AB test of remote configuration, the prerequisite is that the SDK for remote configuration has been correctly integrated in the application, and the parameters for remote configuration have been reserved in the application.

The following are the simplest steps to integrate the remote configuration SDK from scratch and reserve parameters

1. Add the Maven repository address to the project-level build.gradle:

buildscript {
    repositories {
        maven { url 'https://developer.huawei.com/repo/'}
    }
    dependencies {
        classpath 'com.huawei.agconnect:agcp:1.5.2.300'
    }
}
allprojects {
    repositories {
        maven { url 'https://developer.huawei.com/repo/'}
    }
}

2. Add AGCP plugin and agc configuration file

Add the following agcp plugin to the application-level build.gradle

apply plugin: 'com.huawei.agconnect'

3. Under My Project - Project Settings in the AGC console, download the agconnect-services.json file and download it to the app path of the project

cke_14222.png

4. Add SDK dependencies in application-level build.gradle

dependencies {
implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.5.2.300'
implementation 'com.huawei.hms:hianalytics:5.3.1.300'
}

5. Code reserved remote configuration parameters

The following is a simple Android code, I just added a button to get remote configuration in a completely new Android project.

Set the corresponding parameter default value in this button, and obtain the remote configuration parameters on the cloud side through fetch

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	HiAnalyticsTools.enableLog();
	HiAnalyticsInstance instance = HiAnalytics.getInstance(this);
	getAAID();
	findViewById(R.id.button).setOnClickListener(view -> {
		getRemoteCongfig();
	});

}
public void getRemoteCongfig() {
	// 获取远程配置实例
	config = AGConnectConfig.getInstance();
	Map<String, Object> defaultValue = new HashMap<>();
	// 添加键值对
	defaultValue.put("welcome_string", "this is a default welcome_slogan");
	config.applyDefault(defaultValue);

	config.fetch(10).addOnSuccessListener(configValues -> {
		config.apply(configValues);
		String newSlogan = config.getValueAsString("welcome_string");
		Log.i(TAG, "RemoteConfig Success: " + newSlogan);
	}).addOnFailureListener(e1 ->
			Log.e(TAG, "getRemoteConfig failed: " + e1.getMessage())
	);
}

2. Prerequisites: Integrate Huawei Analytics

To generate the AB test report, you need to use the Huawei Analytics service. Therefore, you need to integrate the Huawei Analytics SDK in the code. Since the AB test events are automatically collected by Huawei Analytics, the integration steps of Huawei Analytics are very simple:

1. Add SDK dependencies in application-level build.gradle

dependencies {
implementation 'com.huawei.hms:hianalytics:5.3.1.300'
}

2. Initialize Huawei Analytics in OnCreate

HiAnalyticsTools.enableLog();
HiAnalyticsInstance instance = HiAnalytics.getInstance(this);

3. Create a remote configuration on the AGC interface

In the AGC interface, select My Project, select Remote Configuration on the project - select Add Configuration Project;

https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/

cke_14223.png

It should be noted that the name of the configuration item must be the same as the parameter name reserved in the code . After the plugin is saved, go back to the previous level and click Publish to publish the configuration item. 

Fourth, create a remote configuration class AB test.

In the AGC interface, select My Project, select AB Test on the project - select Create Remote Configuration Experiment;

https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/

Create a random test as required. Note that it is best to increase the proportion of target users at this time, and it is recommended not to select the activation event.

Here, in order to facilitate the viewing of the test results, I filter the language conditions to select the language, and select all languages. You can choose as needed when you test by yourself.

cke_14224.png

When configuring the original group and the experimental group, you can drop down and select the corresponding configuration items.

cke_14225.png

The last step is to select the tracking metric, and I will choose the simplest click-through rate here . After all four steps are configured, click Save 

5. Run the experiment and execute fetch in the App

1. In the operation bar, select Start to start the experiment.

4.png
cke_14226.png

2. Run the app and click the button to get the cloud configuration.

The corresponding log is as follows:

cke_14227.png

have to be aware of is:

  • After the created AB test, you can use the operation on the far right to select Debug to debug the experimental effect. The aaid used for commissioning is obtained as follows
public void getAAID() {
	Task<AAIDResult> idResult = HmsInstanceId.getInstance(this).getAAID();
	idResult.addOnSuccessListener(new OnSuccessListener<AAIDResult>() {
		@Override
		public void onSuccess(AAIDResult aaidResult) {
			// 获取AAID方法成功
			String aaid = aaidResult.getId();
			Log.d(TAG, "getAAID successfully, aaid is " + aaid );
		}
	}).addOnFailureListener(new OnFailureListener() {
		@Override
		public void onFailure(Exception myException) {
			// 获取AAID失败
			Log.d(TAG, "getAAID failed, catch exceptio : " + myException);
		}
	});
}
cke_14228.png

6. View the experimental report

For the experiment that has been run, you can click the report in the operation bar on the right to view the corresponding AB test data report. The interface reference is as follows:  

cke_14229.png

Reference documentation link:

  • Huawei AGC AB Test Operation Document

https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-abtest-introduction-0000001058210679

  • Huawei Remote Config SDK Development Guide:

https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-remoteconfig-android-getstarted-0000001056347165

  • Huawei Analytics SDK Development Guide:

https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/android-dev-process-0000001050163813

{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4478396/blog/5512911