Skip to content

Commit

Permalink
starter project telemetry event tracking source added to registry ser…
Browse files Browse the repository at this point in the history
…ver.

Signed-off-by: Michael Valdron <mvaldron@redhat.com>
  • Loading branch information
michael-valdron committed Jan 18, 2023
1 parent 7a809c0 commit e935ffc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
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 indirect calls from clients.
if enableTelemetry && !util.IsWebClient(c) && !util.IsIndirectCall(c) {

user := util.GetUser(c)
client := util.GetClient(c)

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

0 comments on commit e935ffc

Please sign in to comment.