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

@@ -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
}