Skip to content

Go Event Reporting Interface

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

Method Definition

go
func (client *Client) AppReport(request *AppReportRequest) (_result *AppReportResponse, _err error)

Request Parameter List

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

Return Value List

Return Value NameTypeDescription
result*AppReportResponseInterface return value, valid when err is nil, specific interface return parameters, please refer to Event Reporting
errerrorRequest status, when the request fails, err is not nil

Example Code Location

Example Code

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

go
package test

import (
	"fmt"
	"testing"

	"github.com/toolsetlink/upgradelink-api-go/client"
)


// Report event
func TestPostAppReport(t *testing.T) {

	accessKey := "mui2W50H1j-OC4xD6PgQag"
	accessSecret := "PEbdHFGC0uO_Pch7XWBQTMsFRxKPQAM2565eP8LJ3gc"
	var config = client.Config{
		AccessKey:    &accessKey,
		AccessSecret: &accessSecret,
	}

	Client, err := client.NewClient(&config)
	if err != nil {
		return
	}

	/* app_start Application - Startup event */
	//eventType := client.EventTypeAppStart
	//appKey := "LOYlLXNy7wV3ySuh0XgtSg"
	//devModelKey := ""
	//devKey := ""
	//versionCode := 1
	//timestamp := client.TimeRFC3339()
	//launchTime := client.TimeRFC3339()
	//eventData := &client.AppReportRequestEventData{
	//	LaunchTime: launchTime,
	//}

	/* app_upgrade_download Application Upgrade - Download event */
	//eventType := client.EventTypeAppUpgradeDownload
	//appKey := "LOYlLXNy7wV3ySuh0XgtSg"
	//devModelKey := ""
	//devKey := ""
	//versionCode := 1
	//timestamp := client.TimeRFC3339()
	//downloadVersionCode := 10
	//code := client.EventTypeCodeError
	//eventData := &client.AppReportRequestEventData{
	//	Code:                &code,
	//	DownloadVersionCode: &downloadVersionCode,
	//}

	/* app_upgrade_upgrade Application Upgrade - Upgrade event */
eventType := client.EventTypeAppUpgradeUpgrade
appKey := "LOYlLXNy7wV3ySuh0XgtSg"
devModelKey := ""
devKey := ""
versionCode := 1
timestamp := client.TimeRFC3339()
upgradeVersionCode := 10
code := client.EventTypeCodeSuccess
eventData := &client.AppReportRequestEventData{
	Code:               &code,
	UpgradeVersionCode: &upgradeVersionCode,
}

	// Interface call
	request := &client.AppReportRequest{
		EventType:   &eventType,
		AppKey:      &appKey,
		DevModelKey: &devModelKey,
		DevKey:      &devKey,
		VersionCode: &versionCode,
		Timestamp:   timestamp,
		EventData:   eventData,
	}

	Info, err := Client.AppReport(request)
	if err != nil {
		fmt.Println("err: ", err)
	} else {
		fmt.Println("info: ", Info)
	}

}

toolsetlink@163.com