From 88f1089d0694b16f0ca8db4eb3335e436a5415b5 Mon Sep 17 00:00:00 2001 From: Eyal Ben Moshe Date: Mon, 23 Dec 2024 19:54:48 +0200 Subject: [PATCH 1/2] Add product_version to VisibilityMetric (#1062) --- jfconnect/services/metrics.go | 1 + 1 file changed, 1 insertion(+) diff --git a/jfconnect/services/metrics.go b/jfconnect/services/metrics.go index e7ff49543..847656755 100644 --- a/jfconnect/services/metrics.go +++ b/jfconnect/services/metrics.go @@ -45,6 +45,7 @@ func (jcs *JfConnectService) PostVisibilityMetric(metric VisibilityMetric) error type Labels struct { ProductID string `json:"product_id"` + ProductVersion string `json:"product_version"` FeatureID string `json:"feature_id"` OIDCUsed string `json:"oidc_used"` JobID string `json:"job_id"` From 80a5e1ba7a2c4ed605e6e0f8c78832f7df046443 Mon Sep 17 00:00:00 2001 From: Eyal Ben Moshe Date: Wed, 25 Dec 2024 20:37:33 +0200 Subject: [PATCH 2/2] Internal Remove Call Home version validation (#1063) --- artifactory/usage/call_home.go | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/artifactory/usage/call_home.go b/artifactory/usage/call_home.go index cdcb76eae..77e5dd86d 100644 --- a/artifactory/usage/call_home.go +++ b/artifactory/usage/call_home.go @@ -11,8 +11,6 @@ import ( "github.com/jfrog/jfrog-client-go/utils/io/httputils" ) -const minArtifactoryVersion = "6.9.0" - type ReportUsageAttribute struct { AttributeName string AttributeValue string @@ -28,7 +26,7 @@ func (rua *ReportUsageAttribute) isEmpty() bool { return rua.AttributeName == "" } -func (ach *ArtifactoryCallHome) validateAndGetUsageServerInfo(serviceManager artifactory.ArtifactoryServicesManager) (url string, clientDetails httputils.HttpClientDetails, err error) { +func (ach *ArtifactoryCallHome) getUsageServerInfo(serviceManager artifactory.ArtifactoryServicesManager) (url string, clientDetails httputils.HttpClientDetails, err error) { config := serviceManager.GetConfig() if config == nil { err = errorutils.CheckErrorf("expected full config, but no configuration exists.") @@ -39,15 +37,6 @@ func (ach *ArtifactoryCallHome) validateAndGetUsageServerInfo(serviceManager art err = errorutils.CheckErrorf("Artifactory details not configured.") return } - // Check Artifactory version - artifactoryVersion, err := rtDetails.GetVersion() - if err != nil { - err = errors.New("Couldn't get Artifactory version. Error: " + err.Error()) - return - } - if err = clientutils.ValidateMinimumVersion(clientutils.Artifactory, artifactoryVersion, minArtifactoryVersion); err != nil { - return - } url, err = clientutils.BuildUrl(rtDetails.GetUrl(), "api/system/usage", make(map[string]string)) if err != nil { return @@ -69,8 +58,8 @@ func (ach *ArtifactoryCallHome) sendReport(url string, serviceManager artifactor return nil } -func (ach *ArtifactoryCallHome) SendUsageToArtifactory(productId string, serviceManager artifactory.ArtifactoryServicesManager, features ...Feature) error { - url, clientDetails, err := ach.validateAndGetUsageServerInfo(serviceManager) +func (ach *ArtifactoryCallHome) SendToArtifactory(productId string, serviceManager artifactory.ArtifactoryServicesManager, features ...Feature) error { + url, clientDetails, err := ach.getUsageServerInfo(serviceManager) if err != nil || url == "" { return err } @@ -81,8 +70,8 @@ func (ach *ArtifactoryCallHome) SendUsageToArtifactory(productId string, service return ach.sendReport(url, serviceManager, clientDetails, bodyContent) } -func (ach *ArtifactoryCallHome) SendUsage(productId, commandName string, serviceManager artifactory.ArtifactoryServicesManager, attributes ...ReportUsageAttribute) error { - url, clientDetails, err := ach.validateAndGetUsageServerInfo(serviceManager) +func (ach *ArtifactoryCallHome) Send(productId, commandName string, serviceManager artifactory.ArtifactoryServicesManager, attributes ...ReportUsageAttribute) error { + url, clientDetails, err := ach.getUsageServerInfo(serviceManager) if err != nil || url == "" { return err }