Skip to content

Commit 1226c7d

Browse files
authored
Exclude internal projects & tests from analytics (#686)
* Exclude internal projects & tests from analytics * Update analytics.go * Update analytics.go * Use identifiers instead of raw values
1 parent 0ff27a3 commit 1226c7d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

iterative/utils/analytics.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"reflect"
1717
"regexp"
1818
"runtime/debug"
19+
"strings"
1920
"sync"
2021
"time"
2122

@@ -148,7 +149,8 @@ func GroupId() (string, error) {
148149
os.Getenv("CI_SERVER_URL"),
149150
os.Getenv("CI_PROJECT_ROOT_NAMESPACE"))
150151
} else if ci == "bitbucket" {
151-
rawId = os.Getenv("BITBUCKET_WORKSPACE")
152+
rawId = fmt.Sprintf("https://bitbucket.com/%s",
153+
os.Getenv("BITBUCKET_WORKSPACE"))
152154
}
153155

154156
id, err := deterministic(rawId)
@@ -363,12 +365,31 @@ func SendJitsuEvent(action string, e error, extra map[string]interface{}) {
363365
}
364366
}
365367

368+
// Exclude runs from GitHub Codespaces at Iterative
369+
if strings.HasPrefix(os.Getenv("GITHUB_REPOSITORY"), "iterative/") {
370+
return
371+
}
372+
366373
payload, err := JitsuEventPayload(action, e, extra)
367374
if err != nil {
368375
logrus.Debugf("analytics: Failure generating Jitsu Event Payload; doing nothing")
369376
return
370377
}
371378

379+
// Exclude continuous integration tests and internal projects from analytics
380+
for _, group := range []string{
381+
"dc16cd76-71b7-5afa-bf11-e85e02ee1554", // deterministic("https://github.com/iterative")
382+
"b0e229bf-2598-54b7-a3e0-81869cdad579", // deterministic("https://github.com/iterative-test")
383+
"d5aaeca4-fe6a-5c72-8aa7-6dcd65974973", // deterministic("https://gitlab.com/iterative.ai")
384+
"b6df227b-5b3d-5190-a8fa-d272b617ee6c", // deterministic("https://gitlab.com/iterative-test")
385+
"2c6415f0-cb5a-5e52-8c81-c5af4f11715d", // deterministic("https://bitbucket.com/iterative-ai")
386+
"c0b86b90-d63c-5fb0-b84d-718d8e15f8d6", // deterministic("https://bitbucket.com/iterative-test")
387+
} {
388+
if payload["group_id"].(string) == group {
389+
return
390+
}
391+
}
392+
372393
if payload["user_id"] == "do-not-track" {
373394
logrus.Debugf("analytics: user_id %s is set; doing nothing", payload["user_id"])
374395
return

0 commit comments

Comments
 (0)