diff --git a/controllers/download.go b/controllers/download.go index 8e046dd..83d910e 100644 --- a/controllers/download.go +++ b/controllers/download.go @@ -1,6 +1,7 @@ package controllers import ( + "fmt" "net/http" "os" "path/filepath" @@ -26,7 +27,8 @@ func HandleFileDownload(c *gin.Context) { } // Send analytics event - utils.SendAnalyticsEvent("pageview", "/api/download/"+fileID+"/"+filename) + properties := fmt.Sprintf(`{"filename": "%s"}`, filename) + _ = utils.SendCustomEvent("file_download", "/api/download/"+fileID+"/"+filename, properties) c.Header("Content-Description", "File Transfer") c.Header("Content-Transfer-Encoding", "binary") diff --git a/controllers/upload.go b/controllers/upload.go index 673c082..80f411e 100644 --- a/controllers/upload.go +++ b/controllers/upload.go @@ -3,6 +3,7 @@ package controllers import ( "crypto/rand" "encoding/hex" + "fmt" "io" "net/http" "os" @@ -102,7 +103,8 @@ func HandleFileUpload(c *gin.Context) { } // Send analytics event - utils.SendAnalyticsEvent("pageview", "/api/upload") + properties := fmt.Sprintf(`{"filename": "%s", "size": %d}`, header.Filename, header.Size) + utils.SendCustomEvent("file_upload", "/api/upload", properties) c.JSON(http.StatusOK, gin.H{ "message": "File uploaded successfully", diff --git a/dist/fitra-darwin-amd64 b/dist/fitra-darwin-amd64 index 0d1369a..6d40f86 100755 Binary files a/dist/fitra-darwin-amd64 and b/dist/fitra-darwin-amd64 differ diff --git a/dist/fitra-darwin-arm64 b/dist/fitra-darwin-arm64 index 39fb621..2c9c96c 100755 Binary files a/dist/fitra-darwin-arm64 and b/dist/fitra-darwin-arm64 differ diff --git a/dist/fitra-linux-amd64 b/dist/fitra-linux-amd64 index 5824591..c946849 100755 Binary files a/dist/fitra-linux-amd64 and b/dist/fitra-linux-amd64 differ diff --git a/dist/fitra-linux-arm64 b/dist/fitra-linux-arm64 index c05f922..275fef8 100755 Binary files a/dist/fitra-linux-arm64 and b/dist/fitra-linux-arm64 differ diff --git a/utils/analytics.go b/utils/analytics.go index 05b5129..b7079a9 100644 --- a/utils/analytics.go +++ b/utils/analytics.go @@ -49,3 +49,12 @@ func SendAnalyticsEvent(eventType, pathname string) error { Pathname: pathname, }) } + +func SendCustomEvent(eventName, pathname, properties string) error { + return trackEvent(TrackingEvent{ + Type: "custom_event", + Pathname: pathname, + EventName: eventName, + Properties: properties, + }) +}