@@ -19,14 +19,12 @@ import (
19
19
"crypto/hmac"
20
20
"crypto/sha256"
21
21
"encoding/hex"
22
- "net/http"
23
- "path/filepath"
24
-
25
- "github.com/arduino/arduino-cli/repertory"
22
+ "github.com/arduino/arduino-cli/inventory"
26
23
"github.com/segmentio/stats/v4"
27
24
"github.com/segmentio/stats/v4/prometheus"
28
25
"github.com/sirupsen/logrus"
29
26
"github.com/spf13/viper"
27
+ "net/http"
30
28
)
31
29
32
30
// serverPattern is the telemetry endpoint resource path for consume metrics
@@ -39,7 +37,7 @@ func Activate(metricPrefix string) {
39
37
// Create a new stats engine with an engine that prepends the "daemon" prefix to all metrics
40
38
// and includes the installationID as a tag, then replace the default stats engine
41
39
stats .DefaultEngine = stats .WithPrefix (metricPrefix , stats .T ("installationID" ,
42
- repertory .Store .GetString ("installation.id" )))
40
+ inventory .Store .GetString ("installation.id" )))
43
41
// Register the handler so it receives metrics from the default engine.
44
42
stats .Register (ph )
45
43
@@ -53,16 +51,15 @@ func Activate(metricPrefix string) {
53
51
54
52
}
55
53
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" )
62
59
// Create a new HMAC by defining the hash type and the key (as byte array)
63
60
h := hmac .New (sha256 .New , []byte (installationSecret ))
64
61
// Write Data to it
65
- h .Write ([]byte (sketchName ))
62
+ h .Write ([]byte (s ))
66
63
// Get result and encode as hexadecimal string
67
64
return hex .EncodeToString (h .Sum (nil ))
68
65
}
0 commit comments