summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2015-10-05 09:27:24 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2015-10-05 09:27:24 -0400
commitb144ac103607bb716f7ea340b28498b47b77af9f (patch)
tree816473caffb28b57a41c4b4f1ba246d30c61659b /utils
parent44ceedc2ad2ea193cedb71865931dcdc1624ed2b (diff)
parente0743a6a2bee391efafa2b5c5c0fa3e8a3d2ee27 (diff)
downloadchat-b144ac103607bb716f7ea340b28498b47b77af9f.tar.gz
chat-b144ac103607bb716f7ea340b28498b47b77af9f.tar.bz2
chat-b144ac103607bb716f7ea340b28498b47b77af9f.zip
Merge pull request #900 from mattermost/PLT-462
PLT-462 Adding diagnostic info
Diffstat (limited to 'utils')
-rw-r--r--utils/diagnostic.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/utils/diagnostic.go b/utils/diagnostic.go
new file mode 100644
index 000000000..9a61ae934
--- /dev/null
+++ b/utils/diagnostic.go
@@ -0,0 +1,45 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package utils
+
+import (
+ "net/http"
+
+ l4g "code.google.com/p/log4go"
+
+ "github.com/mattermost/platform/model"
+)
+
+const (
+ PROP_DIAGNOSTIC_ID = "id"
+ PROP_DIAGNOSTIC_CATEGORY = "c"
+ VAL_DIAGNOSTIC_CATEGORY_DEFALUT = "d"
+ PROP_DIAGNOSTIC_BUILD = "b"
+ PROP_DIAGNOSTIC_DATABASE = "db"
+ PROP_DIAGNOSTIC_OS = "os"
+ PROP_DIAGNOSTIC_USER_COUNT = "uc"
+)
+
+func SendDiagnostic(data model.StringMap) *model.AppError {
+ if Cfg.PrivacySettings.EnableDiagnostic && !model.IsOfficalBuild() {
+
+ query := "?"
+ for name, value := range data {
+ if len(query) > 1 {
+ query += "&"
+ }
+
+ query += name + "=" + UrlEncode(value)
+ }
+
+ res, err := http.Get("http://d7zmvsa9e04kk.cloudfront.net/i" + query)
+ if err != nil {
+ l4g.Error("Failed to send diagnostics %v", err.Error())
+ }
+
+ res.Body.Close()
+ }
+
+ return nil
+}