From bc65eb9809d1fcfcf65cb225befeb2e8c566bcab Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sun, 23 Jul 2023 23:59:01 +0800 Subject: [PATCH] feat: report GA4 events for hrp cmd --- docs/CHANGELOG.md | 1 + hrp/boomer.go | 2 +- hrp/build.go | 13 +++++++++++++ hrp/cmd/adb/devices.go | 14 +++++++++++++- hrp/cmd/adb/screencap.go | 14 +++++++++++++- hrp/cmd/boom.go | 12 +++++++++++- hrp/cmd/build.go | 14 +++++++++++++- hrp/cmd/ios/apps.go | 14 +++++++++++++- hrp/cmd/ios/devices.go | 14 +++++++++++++- hrp/cmd/ios/mount.go | 13 ++++++++++++- hrp/cmd/ios/pcap.go | 13 ++++++++++++- hrp/cmd/ios/perf.go | 13 ++++++++++++- hrp/cmd/ios/ps.go | 14 +++++++++++++- hrp/cmd/ios/reboot.go | 15 ++++++++++++++- hrp/cmd/ios/xctest.go | 15 ++++++++++++++- hrp/cmd/pytest.go | 16 ++++++++++++++-- hrp/cmd/wiki.go | 14 +++++++++++++- hrp/internal/pytest/main.go | 3 --- hrp/internal/scaffold/main.go | 11 +++++++++-- hrp/internal/sdk/ga4.go | 2 +- hrp/internal/wiki/main.go | 2 -- hrp/pkg/convert/main.go | 24 ++++++++++++++---------- hrp/runner.go | 4 ++++ hrp/step_mobile_ui.go | 6 ++++++ 24 files changed, 229 insertions(+), 34 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 683b4594..bc3daa39 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,7 @@ **go version** +- feat: report GA4 events for hrp cmd - change: create python venv with httprunner minimum version v4.3.5 - fix #1603: ensure path suffix '/' exists diff --git a/hrp/boomer.go b/hrp/boomer.go index 2a9ed700..ba24a55e 100644 --- a/hrp/boomer.go +++ b/hrp/boomer.go @@ -96,7 +96,7 @@ func (b *HRPBoomer) Run(testcases ...ITestCase) { startTime := time.Now() defer func() { // report boom event - sdk.SendGA4Event("hrp_boom", map[string]interface{}{ + sdk.SendGA4Event("hrp_boomer_run", map[string]interface{}{ "engagement_time_msec": time.Since(startTime).Milliseconds(), }) diff --git a/hrp/build.go b/hrp/build.go index a15614ef..c11a0073 100644 --- a/hrp/build.go +++ b/hrp/build.go @@ -18,6 +18,7 @@ import ( "github.com/httprunner/httprunner/v4/hrp/internal/code" "github.com/httprunner/httprunner/v4/hrp/internal/env" "github.com/httprunner/httprunner/v4/hrp/internal/myexec" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/internal/version" ) @@ -172,6 +173,12 @@ func (pt *pluginTemplate) generateGo(output string) error { // buildGo builds debugtalk.go to debugtalk.bin func buildGo(path string, output string) error { log.Info().Str("path", path).Str("output", output).Msg("start to build go plugin") + + // report GA event + sdk.SendGA4Event("hrp_build_plugin", map[string]interface{}{ + "pluginType": "go", + }) + content, err := os.ReadFile(path) if err != nil { log.Error().Err(err).Msg("failed to read file") @@ -197,6 +204,12 @@ func buildGo(path string, output string) error { // buildPy completes funppy information in debugtalk.py func buildPy(path string, output string) error { log.Info().Str("path", path).Str("output", output).Msg("start to prepare python plugin") + + // report GA event + sdk.SendGA4Event("hrp_build_plugin", map[string]interface{}{ + "pluginType": "python", + }) + // check the syntax of debugtalk.py err := myexec.ExecPython3Command("py_compile", path) if err != nil { diff --git a/hrp/cmd/adb/devices.go b/hrp/cmd/adb/devices.go index 3a0de351..6640a45e 100644 --- a/hrp/cmd/adb/devices.go +++ b/hrp/cmd/adb/devices.go @@ -4,9 +4,12 @@ import ( "encoding/json" "fmt" "os" + "strings" + "time" "github.com/spf13/cobra" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/uixt" ) @@ -18,7 +21,16 @@ func format(data map[string]string) string { var listAndroidDevicesCmd = &cobra.Command{ Use: "devices", Short: "List all Android devices", - 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_adb_devices", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + deviceList, err := uixt.GetAndroidDevices(serial) if err != nil { fmt.Println(err) diff --git a/hrp/cmd/adb/screencap.go b/hrp/cmd/adb/screencap.go index 8147e0c4..d25352bf 100644 --- a/hrp/cmd/adb/screencap.go +++ b/hrp/cmd/adb/screencap.go @@ -3,16 +3,28 @@ package adb import ( "fmt" "io/ioutil" + "strings" + "time" "github.com/spf13/cobra" "github.com/httprunner/httprunner/v4/hrp/internal/builtin" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) var screencapAndroidDevicesCmd = &cobra.Command{ Use: "screencap", Short: "Start android screen capture", - 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_adb_screencap", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + device, err := getDevice(serial) if err != nil { return err diff --git a/hrp/cmd/boom.go b/hrp/cmd/boom.go index 08cff659..b2447ebe 100644 --- a/hrp/cmd/boom.go +++ b/hrp/cmd/boom.go @@ -10,6 +10,7 @@ import ( "github.com/httprunner/httprunner/v4/hrp" "github.com/httprunner/httprunner/v4/hrp/internal/builtin" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/boomer" ) @@ -29,7 +30,16 @@ var boomCmd = &cobra.Command{ } setLogLevel(logLevel) }, - 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_boom", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + var paths []hrp.ITestCase for _, arg := range args { path := hrp.TestCasePath(arg) diff --git a/hrp/cmd/build.go b/hrp/cmd/build.go index 3c8848e3..7e022177 100644 --- a/hrp/cmd/build.go +++ b/hrp/cmd/build.go @@ -1,9 +1,13 @@ package cmd import ( + "strings" + "time" + "github.com/spf13/cobra" "github.com/httprunner/httprunner/v4/hrp" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) var buildCmd = &cobra.Command{ @@ -16,7 +20,15 @@ var buildCmd = &cobra.Command{ PreRun: func(cmd *cobra.Command, args []string) { setLogLevel(logLevel) }, - 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_build", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() return hrp.BuildPlugin(args[0], output) }, } diff --git a/hrp/cmd/ios/apps.go b/hrp/cmd/ios/apps.go index f524c38f..2c41009e 100644 --- a/hrp/cmd/ios/apps.go +++ b/hrp/cmd/ios/apps.go @@ -2,10 +2,13 @@ package ios import ( "fmt" + "strings" + "time" "github.com/mitchellh/mapstructure" "github.com/spf13/cobra" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/gidevice" ) @@ -19,7 +22,16 @@ var listAppsCmd = &cobra.Command{ Use: "apps", Short: "List all iOS installed apps", 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_apps", 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 diff --git a/hrp/cmd/ios/devices.go b/hrp/cmd/ios/devices.go index ad8fb55c..c4f4f333 100644 --- a/hrp/cmd/ios/devices.go +++ b/hrp/cmd/ios/devices.go @@ -4,10 +4,13 @@ import ( "encoding/json" "fmt" "os" + "strings" + "time" "github.com/pkg/errors" "github.com/spf13/cobra" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/gidevice" "github.com/httprunner/httprunner/v4/hrp/pkg/uixt" ) @@ -69,7 +72,16 @@ var listDevicesCmd = &cobra.Command{ Use: "devices", Short: "List all iOS devices", 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_devices", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + devices, err := uixt.GetIOSDevices(udid) if err != nil { fmt.Println(err) diff --git a/hrp/cmd/ios/mount.go b/hrp/cmd/ios/mount.go index cb077ae3..af5313c0 100644 --- a/hrp/cmd/ios/mount.go +++ b/hrp/cmd/ios/mount.go @@ -5,18 +5,29 @@ import ( "fmt" "path/filepath" "strings" + "time" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/httprunner/httprunner/v4/hrp/internal/builtin" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) // mountCmd represents the mount command var mountCmd = &cobra.Command{ Use: "mount", Short: "A brief description of your command", - 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_mount", 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 diff --git a/hrp/cmd/ios/pcap.go b/hrp/cmd/ios/pcap.go index 4535483e..911a911c 100644 --- a/hrp/cmd/ios/pcap.go +++ b/hrp/cmd/ios/pcap.go @@ -3,6 +3,7 @@ package ios import ( "os" "os/signal" + "strings" "syscall" "time" @@ -11,13 +12,23 @@ import ( "github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/httprunner/httprunner/v4/hrp/internal/env" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/uixt" ) var pcapCmd = &cobra.Command{ Use: "pcap", Short: "capture ios network packets", - 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_pcap", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + pcapOptions := []uixt.IOSPcapOption{} if pid > 0 { pcapOptions = append(pcapOptions, uixt.WithIOSPcapPID(pid)) diff --git a/hrp/cmd/ios/perf.go b/hrp/cmd/ios/perf.go index 3824552b..65e833e8 100644 --- a/hrp/cmd/ios/perf.go +++ b/hrp/cmd/ios/perf.go @@ -3,6 +3,7 @@ package ios import ( "os" "os/signal" + "strings" "syscall" "time" @@ -11,13 +12,23 @@ import ( "github.com/httprunner/httprunner/v4/hrp/internal/builtin" "github.com/httprunner/httprunner/v4/hrp/internal/env" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/uixt" ) var perfCmd = &cobra.Command{ Use: "perf", Short: "capture ios performance data (cpu,mem,disk,net,fps,etc.)", - 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_perf", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + perfOptions := []uixt.IOSPerfOption{} for _, p := range indicators { switch p { diff --git a/hrp/cmd/ios/ps.go b/hrp/cmd/ios/ps.go index d40dcc4d..b19b26f1 100644 --- a/hrp/cmd/ios/ps.go +++ b/hrp/cmd/ios/ps.go @@ -2,17 +2,29 @@ package ios import ( "fmt" + "strings" "time" "github.com/pkg/errors" "github.com/spf13/cobra" + + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) var psCmd = &cobra.Command{ Use: "ps", Short: "show running processes", 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_ps", 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 diff --git a/hrp/cmd/ios/reboot.go b/hrp/cmd/ios/reboot.go index d38d9db8..4fc02e6a 100644 --- a/hrp/cmd/ios/reboot.go +++ b/hrp/cmd/ios/reboot.go @@ -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 diff --git a/hrp/cmd/ios/xctest.go b/hrp/cmd/ios/xctest.go index e2b8d343..8060783e 100644 --- a/hrp/cmd/ios/xctest.go +++ b/hrp/cmd/ios/xctest.go @@ -4,17 +4,30 @@ import ( "fmt" "os" "os/signal" + "strings" "syscall" + "time" "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/spf13/cobra" + + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) var xctestCmd = &cobra.Command{ Use: "xctest", Short: "run xctest", - 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_xctest", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + if bundleID == "" { return fmt.Errorf("bundleID is required") } diff --git a/hrp/cmd/pytest.go b/hrp/cmd/pytest.go index 55538e78..5687711e 100644 --- a/hrp/cmd/pytest.go +++ b/hrp/cmd/pytest.go @@ -2,12 +2,15 @@ package cmd import ( "fmt" + "strings" + "time" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/httprunner/httprunner/v4/hrp/internal/myexec" "github.com/httprunner/httprunner/v4/hrp/internal/pytest" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/internal/version" ) @@ -19,11 +22,20 @@ var pytestCmd = &cobra.Command{ setLogLevel(logLevel) }, DisableFlagParsing: true, // allow to pass any args to pytest - 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_pytest", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + packages := []string{ fmt.Sprintf("httprunner==%s", version.HttpRunnerMinimumVersion), } - _, err := myexec.EnsurePython3Venv(venv, packages...) + _, err = myexec.EnsurePython3Venv(venv, packages...) if err != nil { log.Error().Err(err).Msg("python3 venv is not ready") return err diff --git a/hrp/cmd/wiki.go b/hrp/cmd/wiki.go index 7774a740..d7f29be1 100644 --- a/hrp/cmd/wiki.go +++ b/hrp/cmd/wiki.go @@ -1,8 +1,12 @@ package cmd import ( + "strings" + "time" + "github.com/spf13/cobra" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/internal/wiki" ) @@ -13,7 +17,15 @@ var wikiCmd = &cobra.Command{ PreRun: func(cmd *cobra.Command, args []string) { setLogLevel(logLevel) }, - 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_wiki", map[string]interface{}{ + "args": strings.Join(args, "-"), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() return wiki.OpenWiki() }, } diff --git a/hrp/internal/pytest/main.go b/hrp/internal/pytest/main.go index 31acdca9..258a2171 100644 --- a/hrp/internal/pytest/main.go +++ b/hrp/internal/pytest/main.go @@ -2,12 +2,9 @@ package pytest import ( "github.com/httprunner/httprunner/v4/hrp/internal/myexec" - "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) func RunPytest(args []string) error { - sdk.SendGA4Event("hrp_pytest", nil) - args = append([]string{"run"}, args...) return myexec.ExecPython3Command("httprunner", args...) } diff --git a/hrp/internal/scaffold/main.go b/hrp/internal/scaffold/main.go index 3c808224..102b02d8 100644 --- a/hrp/internal/scaffold/main.go +++ b/hrp/internal/scaffold/main.go @@ -54,8 +54,15 @@ func CopyFile(templateFile, targetFile string) error { } func CreateScaffold(projectName string, pluginType PluginType, venv string, force bool) error { - // report event - sdk.SendGA4Event("hrp_startproject", nil) + // report GA event + startTime := time.Now() + defer func() { + sdk.SendGA4Event("hrp_startproject", map[string]interface{}{ + "pluginType": string(pluginType), + "force": force, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() log.Info(). Str("projectName", projectName). diff --git a/hrp/internal/sdk/ga4.go b/hrp/internal/sdk/ga4.go index 395b6a65..1f75c366 100644 --- a/hrp/internal/sdk/ga4.go +++ b/hrp/internal/sdk/ga4.go @@ -41,7 +41,7 @@ func init() { } // init GA4 client - ga4Client = NewGA4Client(ga4MeasurementID, ga4APISecret) + ga4Client = NewGA4Client(ga4MeasurementID, ga4APISecret, false) } type GA4Client struct { diff --git a/hrp/internal/wiki/main.go b/hrp/internal/wiki/main.go index 1d9b3680..c5364826 100644 --- a/hrp/internal/wiki/main.go +++ b/hrp/internal/wiki/main.go @@ -4,11 +4,9 @@ import ( "github.com/rs/zerolog/log" "github.com/httprunner/httprunner/v4/hrp/internal/myexec" - "github.com/httprunner/httprunner/v4/hrp/internal/sdk" ) func OpenWiki() error { - sdk.SendGA4Event("hrp_wiki", nil) log.Info().Msgf("%s https://httprunner.com", openCmd) return myexec.RunCommand(openCmd, "https://httprunner.com") } diff --git a/hrp/pkg/convert/main.go b/hrp/pkg/convert/main.go index 6be392f1..6eacc6c6 100644 --- a/hrp/pkg/convert/main.go +++ b/hrp/pkg/convert/main.go @@ -3,6 +3,7 @@ package convert import ( _ "embed" "path/filepath" + "time" "github.com/rs/zerolog/log" @@ -138,22 +139,25 @@ func (c *TCaseConverter) loadCase(casePath string, fromType FromType) error { return err } -func (c *TCaseConverter) Convert(casePath string, fromType FromType, outputType OutputType) error { - // report event - sdk.SendGA4Event( - "hrp_convert", - map[string]interface{}{ - "from": fromType.String(), - "to": outputType.String(), - }, - ) +func (c *TCaseConverter) Convert(casePath string, fromType FromType, outputType OutputType) (err error) { + // report GA event + startTime := time.Now() + defer func() { + sdk.SendGA4Event("hrp_convert", map[string]interface{}{ + "from": fromType.String(), + "to": outputType.String(), + "success": err == nil, + "engagement_time_msec": time.Since(startTime).Milliseconds(), + }) + }() + log.Info().Str("path", casePath). Str("fromType", fromType.String()). Str("outputType", outputType.String()). Msg("convert testcase") // load source file - err := c.loadCase(casePath, fromType) + err = c.loadCase(casePath, fromType) if err != nil { return err } diff --git a/hrp/runner.go b/hrp/runner.go index 86cfd98d..6cf0031b 100644 --- a/hrp/runner.go +++ b/hrp/runner.go @@ -199,6 +199,7 @@ func (r *HRPRunner) Run(testcases ...ITestCase) (err error) { defer func() { // report run event sdk.SendGA4Event("hrp_run", map[string]interface{}{ + "success": err == nil, "engagement_time_msec": time.Since(startTime).Milliseconds(), }) }() @@ -512,6 +513,9 @@ func (r *SessionRunner) inheritConnection(src *SessionRunner) { // Start runs the test steps in sequential order. // givenVars is used for data driven func (r *SessionRunner) Start(givenVars map[string]interface{}) error { + // report GA event + sdk.SendGA4Event("hrp_session_runner_start", nil) + config := r.caseRunner.testCase.Config log.Info().Str("testcase", config.Name).Msg("run testcase start") diff --git a/hrp/step_mobile_ui.go b/hrp/step_mobile_ui.go index 48672dcc..09cfb258 100644 --- a/hrp/step_mobile_ui.go +++ b/hrp/step_mobile_ui.go @@ -7,6 +7,7 @@ import ( "github.com/rs/zerolog/log" "github.com/httprunner/httprunner/v4/hrp/internal/code" + "github.com/httprunner/httprunner/v4/hrp/internal/sdk" "github.com/httprunner/httprunner/v4/hrp/pkg/uixt" ) @@ -564,6 +565,11 @@ func runStepMobileUI(s *SessionRunner, step *TStep) (stepResult *StepResult, err mobileStep = step.Android } + // report GA event + sdk.SendGA4Event("hrp_run_ui", map[string]interface{}{ + "osType": osType, + }) + stepResult = &StepResult{ Name: step.Name, StepType: StepType(osType),