@@ -19,14 +19,12 @@ import (
1919 "crypto/hmac"
2020 "crypto/sha256"
2121 "encoding/hex"
22- "net/http"
23- "path/filepath"
24-
25- "github.com/arduino/arduino-cli/repertory"
22+ "github.com/arduino/arduino-cli/inventory"
2623 "github.com/segmentio/stats/v4"
2724 "github.com/segmentio/stats/v4/prometheus"
2825 "github.com/sirupsen/logrus"
2926 "github.com/spf13/viper"
27+ "net/http"
3028)
3129
3230// serverPattern is the telemetry endpoint resource path for consume metrics
@@ -39,7 +37,7 @@ func Activate(metricPrefix string) {
3937 // Create a new stats engine with an engine that prepends the "daemon" prefix to all metrics
4038 // and includes the installationID as a tag, then replace the default stats engine
4139 stats .DefaultEngine = stats .WithPrefix (metricPrefix , stats .T ("installationID" ,
42- repertory .Store .GetString ("installation.id" )))
40+ inventory .Store .GetString ("installation.id" )))
4341 // Register the handler so it receives metrics from the default engine.
4442 stats .Register (ph )
4543
@@ -53,16 +51,15 @@ func Activate(metricPrefix string) {
5351
5452}
5553
56- // SanitizeSketchPath uses config generated UUID (installation.secret) as an HMAC secret to sanitize and anonymize
57- // the sketch name maintaining it distinguishable from a different sketch from the same Installation
58- func SanitizeSketchPath (sketchPath string ) string {
59- logrus .Infof ("repertory.Store.ConfigFileUsed() %s" , repertory .Store .ConfigFileUsed ())
60- installationSecret := repertory .Store .GetString ("installation.secret" )
61- sketchName := filepath .Base (sketchPath )
54+ // Sanitize uses config generated UUID (installation.secret) as an HMAC secret to sanitize and anonymize
55+ // a string, maintaining it distinguishable from a different string from the same Installation
56+ func Sanitize (s string ) string {
57+ logrus .Infof ("inventory.Store.ConfigFileUsed() %s" , inventory .Store .ConfigFileUsed ())
58+ installationSecret := inventory .Store .GetString ("installation.secret" )
6259 // Create a new HMAC by defining the hash type and the key (as byte array)
6360 h := hmac .New (sha256 .New , []byte (installationSecret ))
6461 // Write Data to it
65- h .Write ([]byte (sketchName ))
62+ h .Write ([]byte (s ))
6663 // Get result and encode as hexadecimal string
6764 return hex .EncodeToString (h .Sum (nil ))
6865}
0 commit comments