Skip to content

Commit e935ffc

Browse files
starter project telemetry event tracking source added to registry server.
Signed-off-by: Michael Valdron <[email protected]>
1 parent 7a809c0 commit e935ffc

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

index/server/pkg/server/endpoint.go

+20
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,26 @@ func serveDevfileStarterProjectWithVersion(c *gin.Context) {
305305
return
306306
}
307307

308+
// Track event for telemetry. Ignore indirect calls from clients.
309+
if enableTelemetry && !util.IsWebClient(c) && !util.IsIndirectCall(c) {
310+
311+
user := util.GetUser(c)
312+
client := util.GetClient(c)
313+
314+
err := util.TrackEvent(analytics.Track{
315+
Event: eventTrackMap["spdownload"],
316+
UserId: user,
317+
Context: util.SetContext(c),
318+
Properties: analytics.NewProperties().
319+
Set("devfile", devfileName).
320+
Set("starterProject", starterProjectName).
321+
Set("client", client),
322+
})
323+
if err != nil {
324+
log.Println(err)
325+
}
326+
}
327+
308328
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s.zip\"", starterProjectName))
309329
c.Data(http.StatusAccepted, starterProjectMediaType, downloadBytes)
310330
}

index/server/pkg/server/index.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ import (
4141
)
4242

4343
var eventTrackMap = map[string]string{
44-
"list": "list devfile",
45-
"view": "view devfile",
46-
"download": "download devfile",
44+
"list": "list devfile",
45+
"view": "view devfile",
46+
"download": "download devfile",
47+
"spdownload": "Starter Project Downloaded",
4748
}
4849

4950
var mediaTypeMapping = map[string]string{

0 commit comments

Comments
 (0)