Skip to content

TypeScript Event Reporting Interface ​

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

Request Parameter List ​

ParameterTypeDescription
requestAppReportRequestSet specific interface request parameters, please refer to Event Reporting

Return Value List ​

Return ValueTypeDescription
resultAppReportResponseInterface return value, specific interface return parameters, please refer to Event Reporting

Unit Test Code Location ​

Example Code ​

You can use the following code to report event type data.

typescript
const {default: Client, Config, AppReportRequest} = require('@toolsetlink/upgradelink-api-typescript');

// Test event reporting information
async function testPostAppReport() {
    try {
        // Initialize client
        const config = new Config({
            accessKey: 'mui2W50H1j-OC4xD6PgQag',
            accessSecret: 'PEbdHFGC0uO_Pch7XWBQTMsFRxKPQAM2565eP8LJ3gc',
        });
        const client = new Client(config);

        // Construct request parameters

        /* app_start Application - Startup event */
        // const request = new AppReportRequest({
        //     eventType: Enums.EVENT_TYPE_APP_START,
        //     appKey: 'LOYlLXNy7wV3ySuh0XgtSg',
        //     devModelKey: '',
        //     devKey: '',
        //     versionCode: 1,
        //     timestamp: Tools.timeRFC3339(),
        //     eventData: {
        //         launchTime: Tools.timeRFC3339(),
        //     }
        // });

        /* app_upgrade_download Application Upgrade - Download event */
        // const request = new AppReportRequest({
        //     eventType: Enums.EVENT_TYPE_APP_UPGRADE_DOWNLOAD,
        //     appKey: 'LOYlLXNy7wV3ySuh0XgtSg',
        //     devModelKey: '',
        //     devKey: '',
        //     versionCode: 1,
        //     timestamp: Tools.timeRFC3339(),
        //     eventData: {
        //         code: Enums.EVENT_TYPE_CODE_SUCCESS,
        //         downloadVersionCode: 10,
        //     }
        // });

        /* app_upgrade_install Application Upgrade - Upgrade event */
        const request = new AppReportRequest({
            eventType: Enums.EVENT_TYPE_APP_UPGRADE_UPGRADE,
            appKey: 'LOYlLXNy7wV3ySuh0XgtSg',
            devModelKey: '',
            devKey: '',
            versionCode: 1,
            timestamp: Tools.timeRFC3339(),
            eventData: {
                code: Enums.EVENT_TYPE_CODE_SUCCESS,
                upgradeVersionCode: 10,
            }
        });

        // Send request
        const response = await client.AppReport(request);

        // Print response result
        console.log('\nEvent Reporting Information Response:');
        console.log(`code: ${response.code}`);
        console.log(`msg: ${response.msg}`);
    } catch (error) {
        console.error('\nEvent Reporting Information Failed:', error);
    }
}

toolsetlink@163.com