Skip to content

Commit

Permalink
Display the found tracking domain in the validator output (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
academo authored Dec 11, 2023
1 parent 8d7bbda commit 54d678e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/analysis/passes/trackingscripts/trackingscripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package trackingscripts
import (
"bytes"
_ "embed"
"fmt"
"strings"

"github.com/grafana/plugin-validator/pkg/analysis"
Expand Down Expand Up @@ -37,7 +38,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
for _, content := range moduleJsMap {
for _, url := range servers {
if len(url) > 0 && bytes.Contains(content, []byte(url)) {
pass.ReportResult(pass.AnalyzerName, trackingScripts, "module.js: should not include tracking scripts", "Tracking scripts are not allowed in Grafana plugins (e.g. google analytics). Please remove any usage of tracking code.")
pass.ReportResult(pass.AnalyzerName, trackingScripts, "module.js: should not include tracking scripts", fmt.Sprintf("Tracking scripts are not allowed in Grafana plugins (e.g. google analytics). Please remove any usage of tracking code. Found: %s", url))
hasTrackingScripts = true
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ func TestTrackingScriptsInvalid(t *testing.T) {
require.NoError(t, err)
require.Len(t, interceptor.Diagnostics, 1)
require.Equal(t, interceptor.Diagnostics[0].Title, "module.js: should not include tracking scripts")
require.Equal(t, interceptor.Diagnostics[0].Detail, "Tracking scripts are not allowed in Grafana plugins (e.g. google analytics). Please remove any usage of tracking code. Found: google-analytics.com")
}

0 comments on commit 54d678e

Please sign in to comment.