Skip to content

Java Event Reporting Interface ​

Based on the reported event type data, it will be reflected in the system's statistical data.

Request Parameter List ​

Parameter NameTypeDescription
requestAppReportRequestSet specific interface request parameters, please refer to Event Reporting

Return Value List ​

Return Value NameTypeDescription
resultAppReportResponseInterface return value, valid when err is nil, specific interface return parameters, please refer to Event Reporting

Unit Test Code Location ​

Example Code ​

You can use the following code to get the latest upgrade strategy.

java
package com.toolsetlink.upgradelink.api;  // Package name must be the same as the tested class

import com.toolsetlink.upgradelink.api.models.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class ClientTest {  // Class name = Tested class name + Test

    private final String accessKey = "mui2W50H1j-OC4xD6PgQag";
    private final String accessSecret = "PEbdHFGC0uO_Pch7XWBQTMsFRxKPQAM2565eP8LJ3gc";
    private Client client;

    @BeforeEach
    void setUp() throws Exception {
        Config config = new Config();
        config.setAccessKey(accessKey);
        config.setAccessSecret(accessSecret);
        client = new Client(config);
    }

    // Test getting event reporting interface
    // /* app_start Application - Startup event */
    @Test
    public void testPostAppReport() throws Exception {

        /*  app_start Application - Startup event */
        AppReportRequest request = new AppReportRequest();
        request.setEventType(Enums.EVENT_TYPE_APP_START);
        request.setAppKey("LOYlLXNy7wV3ySuh0XgtSg");
        request.setTimestamp(Tools.timeRFC3339());
        request.setEventData(new AppReportRequest.AppReportRequestEventData()
                .setLaunchTime(Tools.timeRFC3339())
                .setVersionCode(1)
                .setTarget("darwin")
                .setArch("x86_64")
                .setDevModelKey("")
                .setDevKey("")
        );

        try {
            AppReportResponse info = client.AppReport(request);
            System.out.println(info.code);
            System.out.println(info.msg);
        } catch (Exception e) {
            System.out.println("Exception e1:" + e);
        }

        System.out.println("testPostAppReport end");
    }

    // Test getting event reporting interface
    // /* app_upgrade_download Application Upgrade - Download event */
    @Test
    public void testPostAppReport1() throws Exception {

        /*  app_upgrade_download Application Upgrade - Download event */
        AppReportRequest request = new AppReportRequest();
        request.setEventType(Enums.EVENT_TYPE_APP_UPGRADE_DOWNLOAD);
        request.setAppKey("LOYlLXNy7wV3ySuh0XgtSg");
        request.setTimestamp(Tools.timeRFC3339());
        request.setEventData(new AppReportRequest.AppReportRequestEventData()
                .setDownloadVersionCode(2)
                .setCode(0)
                .setVersionCode(1)
                .setTarget("darwin")
                .setArch("x86_64")
                .setDevModelKey("")
                .setDevKey("")
        );

        try {
            AppReportResponse info = client.AppReport(request);
            System.out.println(info.code);
            System.out.println(info.msg);
        } catch (Exception e) {
            System.out.println("Exception e1:" + e);
        }

        System.out.println("testPostAppReport end");
    }

    // Test getting event reporting interface
    // /* app_upgrade_upgrade Application Upgrade - Upgrade event */
    @Test
    public void testPostAppReport2() throws Exception {

        /*  app_upgrade_upgrade Application Upgrade - Upgrade event */
        AppReportRequest request = new AppReportRequest();
        request.setEventType(Enums.EVENT_TYPE_APP_UPGRADE_UPGRADE);
        request.setAppKey("LOYlLXNy7wV3ySuh0XgtSg");
        request.setTimestamp(Tools.timeRFC3339());
        request.setEventData(new AppReportRequest.AppReportRequestEventData()
                .setUpgradeVersionCode(2)
                .setCode(0)
                .setVersionCode(1)
                .setTarget("darwin")
                .setArch("x86_64")
                .setDevModelKey("")
                .setDevKey("")
        );

        try {
            AppReportResponse info = client.AppReport(request);
            System.out.println(info.code);
            System.out.println(info.msg);
        } catch (Exception e) {
            System.out.println("Exception e1:" + e);
        }

        System.out.println("testPostAppReport end");
    }
}

toolsetlink@163.com