feat: report GA4 events for hrp cmd

This commit is contained in:
lilong.129
2023-07-23 23:59:01 +08:00
parent 0a88e3a57f
commit bc65eb9809
24 changed files with 229 additions and 34 deletions

View File

@@ -2,15 +2,28 @@ package ios
import (
"fmt"
"strings"
"time"
"github.com/spf13/cobra"
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
)
var rebootCmd = &cobra.Command{
Use: "reboot",
Short: "reboot or shutdown ios device",
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) (err error) {
startTime := time.Now()
defer func() {
sdk.SendGA4Event("hrp_ios_reboot", map[string]interface{}{
"args": strings.Join(args, "-"),
"success": err == nil,
"engagement_time_msec": time.Since(startTime).Milliseconds(),
})
}()
device, err := getDevice(udid)
if err != nil {
return err