diff --git a/README.md b/README.md index cbaa22c..eddbfe7 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ To uninstall, run: helm plugin uninstall dashboard ``` -Note: In case standard Helm plugin way did not work for you, you can just download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it. +> In case standard Helm plugin way did not work for you, you can just download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it. ## Running @@ -70,6 +70,8 @@ If you don't want browser tab to automatically open, add `--no-browser` flag in If you want to increase the logging verbosity and see all the debug info, use the `--verbose` flag. +> Disclaimer: For the sake of improving the project quality, there is user analytics collected by the tool. You can disable this collecting with `--no-analytics` option. The collection is done via DataDog RUM and Heap Analytics. Only the anonymous data is collected, no sensitive information is used. No session recording is performed. + ## Scanner Integrations Upon startup, Helm Dashboard detects the presence of [Trivy](https://github.com/aquasecurity/trivy) diff --git a/main.go b/main.go index 72990fe..dbe7dc2 100644 --- a/main.go +++ b/main.go @@ -17,9 +17,10 @@ var ( ) type options struct { - Verbose bool `short:"v" long:"verbose" description:"Show verbose debug information"` - NoBrowser bool `short:"b" long:"no-browser" description:"Do not attempt to open Web browser upon start"` - Version bool `long:"version" description:"Show tool version"` + Version bool `long:"version" description:"Show tool version"` + Verbose bool `short:"v" long:"verbose" description:"Show verbose debug information"` + NoBrowser bool `short:"b" long:"no-browser" description:"Do not attempt to open Web browser upon start"` + NoTracking bool `long:"no-analytics" description:"Disable user analytics (GA, DataDog etc.)"` Port uint `short:"p" long:"port" description:"Port to start server on" default:"8080"` // TODO: better default port to clash less? @@ -31,7 +32,11 @@ func main() { setupLogging(opts.Verbose) - address, webServerDone := dashboard.StartServer(version, int(opts.Port), opts.Namespace, opts.Verbose) + address, webServerDone := dashboard.StartServer(version, int(opts.Port), opts.Namespace, opts.Verbose, opts.NoTracking) + + if !opts.NoTracking { + log.Infof("User analytics collected to improve the quality, disable it with --no-analytics") + } if opts.NoBrowser { log.Infof("Access web UI at: %s", address) diff --git a/pkg/dashboard/server.go b/pkg/dashboard/server.go index a767476..e550f27 100644 --- a/pkg/dashboard/server.go +++ b/pkg/dashboard/server.go @@ -16,7 +16,7 @@ import ( "time" ) -func StartServer(version string, port int, ns string, debug bool) (string, utils.ControlChan) { +func StartServer(version string, port int, ns string, debug bool, noTracking bool) (string, utils.ControlChan) { data := subproc.DataLayer{ Namespace: ns, } @@ -26,7 +26,10 @@ func StartServer(version string, port int, ns string, debug bool) (string, utils os.Exit(1) // TODO: propagate error instead? } - data.VersionInfo = &subproc.VersionInfo{CurVer: version} + data.VersionInfo = &subproc.VersionInfo{ + CurVer: version, + Analytics: !noTracking, + } go checkUpgrade(data.VersionInfo) discoverScanners(&data) diff --git a/pkg/dashboard/static/analytics.js b/pkg/dashboard/static/analytics.js new file mode 100644 index 0000000..6a841b4 --- /dev/null +++ b/pkg/dashboard/static/analytics.js @@ -0,0 +1,58 @@ +const xhr = new XMLHttpRequest(); +xhr.onload = function () { + if (xhr.readyState === XMLHttpRequest.DONE) { + const status = JSON.parse(xhr.responseText); + if (status.Analytics && status.version !== "dev") { + enableDD(status.version) + enableHeap() + } + } +} +xhr.open('GET', '/status', true); +xhr.send(null); + + +function enableDD(version) { + (function (h, o, u, n, d) { + h = h[d] = h[d] || { + q: [], onReady: function (c) { + h.q.push(c) + } + } + d = o.createElement(u); + d.async = true; + d.src = n + n = o.getElementsByTagName(u)[0]; + n.parentNode.insertBefore(d, n) + })(window, document, 'script', 'https://www.datadoghq-browser-agent.com/datadog-rum-v4.js', 'DD_RUM') + DD_RUM.onReady(function () { + DD_RUM.init({ + clientToken: 'pub16d64cd1c00cf073ce85af914333bf72', + applicationId: 'e75439e5-e1b3-46ba-a9e9-a2e58579a2e2', + site: 'datadoghq.com', + service: 'helm-dashboard', + version: version, + trackInteractions: true, + trackResources: true, + trackLongTasks: true, + defaultPrivacyLevel: 'mask', + sessionReplaySampleRate: 0 + }) + }) +} + +function enableHeap() { + window.heap = window.heap || [], heap.load = function (e, t) { + window.heap.appid = e, window.heap.config = t = t || {}; + let r = document.createElement("script"); + r.type = "text/javascript", r.async = !0, r.src = "https://cdn.heapanalytics.com/js/heap-" + e + ".js"; + let a = document.getElementsByTagName("script")[0]; + a.parentNode.insertBefore(r, a); + for (let n = function (e) { + return function () { + heap.push([e].concat(Array.prototype.slice.call(arguments, 0))) + } + }, p = ["addEventProperties", "addUserProperties", "clearEventProperties", "identify", "resetIdentity", "removeEventProperty", "setEventProperties", "track", "unsetEventProperty"], o = 0; o < p.length; o++) heap[p[o]] = n(p[o]) + }; + heap.load("3615793373"); +} \ No newline at end of file diff --git a/pkg/dashboard/static/datadog.js b/pkg/dashboard/static/datadog.js deleted file mode 100644 index d4d50c3..0000000 --- a/pkg/dashboard/static/datadog.js +++ /dev/null @@ -1,26 +0,0 @@ -(function(h,o,u,n,d) { - h=h[d]=h[d]||{q:[],onReady:function(c){h.q.push(c)}} - d=o.createElement(u);d.async=1;d.src=n - n=o.getElementsByTagName(u)[0];n.parentNode.insertBefore(d,n) -})(window,document,'script','https://www.datadoghq-browser-agent.com/datadog-rum-v4.js','DD_RUM') - DD_RUM.onReady(function() { - const xhr = new XMLHttpRequest(); - xhr.onload = function() { - const version = JSON.parse(xhr.responseText).CurVer; - if (xhr.readyState === XMLHttpRequest.DONE && version!=="dev") { - DD_RUM.init({ - clientToken: 'pub16d64cd1c00cf073ce85af914333bf72', - applicationId: 'e75439e5-e1b3-46ba-a9e9-a2e58579a2e2', - site: 'datadoghq.com', - service: 'helm-dashboard', - version: version, - trackInteractions: true, - trackResources: true, - trackLongTasks: true, - defaultPrivacyLevel: 'mask' - }) - } - } - xhr.open('GET', '/status', true); - xhr.send(null); -}) \ No newline at end of file diff --git a/pkg/dashboard/static/index.html b/pkg/dashboard/static/index.html index 5e09361..6956369 100644 --- a/pkg/dashboard/static/index.html +++ b/pkg/dashboard/static/index.html @@ -5,10 +5,9 @@