Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telemetry for the download-starter-project endpoint to registry server #157

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions index/server/pkg/server/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,26 @@ func serveDevfileStarterProjectWithVersion(c *gin.Context) {
return
}

// Track event for telemetry. Ignore events from the registry-viewer and DevConsole since those are tracked on the client side. Ignore indirect calls from clients.
if enableTelemetry && !util.IsWebClient(c) && !util.IsIndirectCall(c) {

user := util.GetUser(c)
client := util.GetClient(c)
michael-valdron marked this conversation as resolved.
Show resolved Hide resolved

err := util.TrackEvent(analytics.Track{
Event: eventTrackMap["spdownload"],
UserId: user,
Context: util.SetContext(c),
Properties: analytics.NewProperties().
Set("devfile", devfileName).
Set("starterProject", starterProjectName).
Set("client", client),
})
if err != nil {
log.Println(err)
}
}

c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s.zip\"", starterProjectName))
c.Data(http.StatusAccepted, starterProjectMediaType, downloadBytes)
}
Expand Down
7 changes: 4 additions & 3 deletions index/server/pkg/server/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ import (
)

var eventTrackMap = map[string]string{
"list": "list devfile",
"view": "view devfile",
"download": "download devfile",
"list": "list devfile",
"view": "view devfile",
"download": "download devfile",
"spdownload": "Starter Project Downloaded",
}

var mediaTypeMapping = map[string]string{
Expand Down