Skip to content

Commit

Permalink
Merge pull request #337 from projectdiscovery/metric-options
Browse files Browse the repository at this point in the history
add missing utm_source value
  • Loading branch information
tarunKoyalwar authored Feb 16, 2024
2 parents b084807 + c427ef8 commit eeee5a2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions update/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package updateutils

import (
"fmt"
"os"
"strings"

"github.com/Masterminds/semver/v3"
Expand Down Expand Up @@ -99,3 +100,51 @@ func IsDevReleaseOutdated(current string, latest string) bool {
}
return false
}

// getUtmSource returns utm_source from environment variable or "unknown" value
func getUtmSource() string {
value := ""
switch {
case os.Getenv("GH_ACTION") != "":
value = "ghci"
case os.Getenv("TRAVIS") != "":
value = "travis"
case os.Getenv("CIRCLECI") != "":
value = "circleci"
case os.Getenv("CI") != "":
value = "gitlabci" // this also includes bitbucket
case os.Getenv("GITHUB_ACTIONS") != "":
value = "ghci"
case os.Getenv("AWS_EXECUTION_ENV") != "":
value = os.Getenv("AWS_EXECUTION_ENV")
case os.Getenv("JENKINS_URL") != "":
value = "jenkins"
case os.Getenv("FUNCTION_TARGET") != "":
value = "gcf"
case os.Getenv("GOOGLE_CLOUD_PROJECT") != "":
value = "gcp"
case os.Getenv("HEROKU_APP_NAME") != "":
value = "heroku"
case os.Getenv("DYNO") != "":
value = "heroku"
case os.Getenv("ECS_CONTAINER_METADATA_URI") != "":
value = "ecs"
case os.Getenv("EC2_INSTANCE_ID") != "":
value = "ec2"
case os.Getenv("KUBERNETES_SERVICE_HOST") != "":
value = "k8s"
case os.Getenv("KUBERNETES_PORT") != "":
value = "k8s"
case os.Getenv("AZURE_FUNCTIONS_ENVIRONMENT") != "":
value = "azure"
case os.Getenv("__OW_API_HOST") != "":
value = "ibmcf"
case os.Getenv("OCI_RESOURCE_PRINCIPAL_VERSION") != "":
value = "oracle"
case os.Getenv("GAE_RUNTIME") != "":
value = os.Getenv("GAE_RUNTIME")
default:
value = "unknown"
}
return value
}
1 change: 1 addition & 0 deletions update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func GetpdtmParams(version string) string {
params.Add("go_version", runtime.Version())
params.Add("v", version)
params.Add("machine_id", buildMachineId())
params.Add("utm_source", getUtmSource())
return params.Encode()
}

Expand Down

0 comments on commit eeee5a2

Please sign in to comment.