2017-04-12 08:27:57 -04:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
2019-11-29 12:59:40 +01:00
// See LICENSE.txt for license information.
2017-02-24 17:33:59 +00:00
package app
import (
2018-07-19 05:01:39 -04:00
"path/filepath"
2017-02-24 17:33:59 +00:00
"runtime"
2018-08-23 11:48:57 +01:00
"strings"
2019-11-28 14:39:38 +01:00
"github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model"
2020-07-28 04:26:44 +02:00
"github.com/mattermost/mattermost-server/v5/services/marketplace"
2019-11-28 14:39:38 +01:00
"github.com/mattermost/mattermost-server/v5/store"
2020-06-22 08:35:03 +01:00
rudder "github.com/rudderlabs/analytics-go"
2017-02-24 17:33:59 +00:00
)
const (
2020-04-21 09:23:00 +01:00
RUDDER_KEY = "placeholder_rudder_key"
RUDDER_DATAPLANE_URL = "placeholder_rudder_dataplane_url"
2017-02-24 17:33:59 +00:00
2018-08-23 11:48:57 +01:00
TRACK_CONFIG_SERVICE = "config_service"
TRACK_CONFIG_TEAM = "config_team"
TRACK_CONFIG_CLIENT_REQ = "config_client_requirements"
TRACK_CONFIG_SQL = "config_sql"
TRACK_CONFIG_LOG = "config_log"
2020-04-14 22:30:27 -04:00
TRACK_CONFIG_AUDIT = "config_audit"
2019-05-21 17:51:15 -04:00
TRACK_CONFIG_NOTIFICATION_LOG = "config_notifications_log"
2018-08-23 11:48:57 +01:00
TRACK_CONFIG_FILE = "config_file"
TRACK_CONFIG_RATE = "config_rate"
TRACK_CONFIG_EMAIL = "config_email"
TRACK_CONFIG_PRIVACY = "config_privacy"
TRACK_CONFIG_THEME = "config_theme"
TRACK_CONFIG_OAUTH = "config_oauth"
TRACK_CONFIG_LDAP = "config_ldap"
TRACK_CONFIG_COMPLIANCE = "config_compliance"
TRACK_CONFIG_LOCALIZATION = "config_localization"
TRACK_CONFIG_SAML = "config_saml"
TRACK_CONFIG_PASSWORD = "config_password"
TRACK_CONFIG_CLUSTER = "config_cluster"
TRACK_CONFIG_METRICS = "config_metrics"
TRACK_CONFIG_SUPPORT = "config_support"
TRACK_CONFIG_NATIVEAPP = "config_nativeapp"
TRACK_CONFIG_EXPERIMENTAL = "config_experimental"
TRACK_CONFIG_ANALYTICS = "config_analytics"
TRACK_CONFIG_ANNOUNCEMENT = "config_announcement"
TRACK_CONFIG_ELASTICSEARCH = "config_elasticsearch"
TRACK_CONFIG_PLUGIN = "config_plugin"
TRACK_CONFIG_DATA_RETENTION = "config_data_retention"
TRACK_CONFIG_MESSAGE_EXPORT = "config_message_export"
TRACK_CONFIG_DISPLAY = "config_display"
2019-10-11 07:27:55 -04:00
TRACK_CONFIG_GUEST_ACCOUNTS = "config_guest_accounts"
2019-01-24 16:11:32 -04:00
TRACK_CONFIG_IMAGE_PROXY = "config_image_proxy"
2020-06-09 09:04:52 +01:00
TRACK_CONFIG_BLEVE = "config_bleve"
2018-08-23 11:48:57 +01:00
TRACK_PERMISSIONS_GENERAL = "permissions_general"
TRACK_PERMISSIONS_SYSTEM_SCHEME = "permissions_system_scheme"
TRACK_PERMISSIONS_TEAM_SCHEMES = "permissions_team_schemes"
2019-11-21 13:04:21 +01:00
TRACK_ELASTICSEARCH = "elasticsearch"
2020-02-06 09:25:36 -05:00
TRACK_GROUPS = "groups"
2020-03-17 11:09:37 -04:00
TRACK_CHANNEL_MODERATION = "channel_moderation"
2020-07-22 20:32:21 -07:00
TRACK_WARN_METRICS = "warn_metrics"
2017-02-24 17:33:59 +00:00
TRACK_ACTIVITY = "activity"
TRACK_LICENSE = "license"
TRACK_SERVER = "server"
2017-10-30 14:10:48 -04:00
TRACK_PLUGINS = "plugins"
2017-02-24 17:33:59 +00:00
)
2020-05-21 16:13:37 +03:00
// declaring this as var to allow overriding in tests
var SENTRY_DSN = "placeholder_sentry_dsn"
2020-06-12 13:43:50 +02:00
func ( s * Server ) SendDailyDiagnostics ( ) {
s . sendDailyDiagnostics ( false )
2018-12-13 12:31:53 +00:00
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) sendDailyDiagnostics ( override bool ) {
if * s . Config ( ) . LogSettings . EnableDiagnostics && s . IsLeader ( ) && ( ( ! strings . Contains ( RUDDER_KEY , "placeholder" ) && ! strings . Contains ( RUDDER_DATAPLANE_URL , "placeholder" ) ) || override ) {
2020-06-22 08:35:03 +01:00
s . initDiagnostics ( RUDDER_DATAPLANE_URL )
2020-06-12 13:43:50 +02:00
s . trackActivity ( )
s . trackConfig ( )
s . trackLicense ( )
s . trackPlugins ( )
s . trackServer ( )
s . trackPermissions ( )
s . trackElasticsearch ( )
s . trackGroups ( )
s . trackChannelModeration ( )
2020-07-22 20:32:21 -07:00
s . trackWarnMetrics ( )
2020-04-21 09:23:00 +01:00
}
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) SendDiagnostic ( event string , properties map [ string ] interface { } ) {
if s . rudderClient != nil {
s . rudderClient . Enqueue ( rudder . Track {
2020-04-21 09:23:00 +01:00
Event : event ,
2020-06-12 13:43:50 +02:00
UserId : s . diagnosticId ,
2020-04-21 09:23:00 +01:00
Properties : properties ,
} )
}
2017-02-24 17:33:59 +00:00
}
func isDefault ( setting interface { } , defaultValue interface { } ) bool {
2017-10-30 11:57:24 -05:00
return setting == defaultValue
2017-02-24 17:33:59 +00:00
}
2017-10-23 02:39:51 -07:00
func pluginSetting ( pluginSettings * model . PluginSettings , plugin , key string , defaultValue interface { } ) interface { } {
settings , ok := pluginSettings . Plugins [ plugin ]
2017-08-02 01:36:54 -07:00
if ! ok {
return defaultValue
}
2018-07-09 07:25:57 -07:00
if value , ok := settings [ key ] ; ok {
2017-08-02 01:36:54 -07:00
return value
}
return defaultValue
}
2017-12-07 17:03:11 -05:00
func pluginActivated ( pluginStates map [ string ] * model . PluginState , pluginId string ) bool {
state , ok := pluginStates [ pluginId ]
if ! ok {
return false
}
return state . Enable
}
2020-01-16 08:46:36 -05:00
func pluginVersion ( pluginsAvailable [ ] * model . BundleInfo , pluginId string ) string {
for _ , plugin := range pluginsAvailable {
if plugin . Manifest != nil && plugin . Manifest . Id == pluginId {
return plugin . Manifest . Version
}
}
return ""
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackActivity ( ) {
2017-02-24 17:33:59 +00:00
var userCount int64
2020-04-09 11:05:43 +02:00
var guestAccountsCount int64
MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)
* bots model, store and api
Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119
* uncomment tests incorrectly commented, and fix merge issues
* add etags support
* add missing licenses
* remove unused sqlbuilder.go (for now...)
* rejig permissions
* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS
* conform to general rest api pattern
* eliminate redundant http.StatusOK
* Update api4/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* s/model.UserFromBotModel/model.UserFromBot/g
* Update model/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* Update model/client4.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* move sessionHasPermissionToManageBot to app/authorization.go
* use api.ApiSessionRequired for createBot
* introduce BOT_DESCRIPTION_MAX_RUNES constant
* MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings
* Add additional config settings to tests
* upgrade db to 5.7 (#10019)
* MM-13526 Add validation when setting a user's Locale field (#10022)
* Fix typos (#10024)
* Fixing first user being created with system admin privilages without being explicity specified. (#10014)
* Revert "Support for Embeded chat (#9129)" (#10017)
This reverts commit 3fcecd521a5c6ccfdb52fb4c3fb1f8c6ea528a4e.
* s/DisableBot/UpdateBotActive
* add permissions on upgrade
* Update NOTICE.txt (#10054)
- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates
* avoid leaking bot knowledge without permission
* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts
* 6798 added the permsission check before getting the reactions
* GH-6798 added a new app function for the new endpoint
* 6798 added a store method to get reactions for multiple posts
* 6798 connected the app function with the new store function
* 6798 fixed the review comments
* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)
Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023
* Trigger Login Hooks with OAuth (#10061)
* make BotStore.GetAll deterministic even on duplicate CreateAt
* fix spurious TestMuteCommandSpecificChannel test failure
See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw
* fix race in TestExportUserChannels
* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway
* MM-13117: bot tokens (#10111)
* eliminate redundant Client/AdminClient declarations
* harden TestUpdateChannelScheme to API failures
* eliminate unnecessary config restoration
* minor cleanup
* make TestGenerateMfaSecret config dependency explicit
* TestCreateUserAccessToken for bots
* TestGetUserAccessToken* for bots
* leverage SessionHasPermissionToUserOrBot for user token APIs
* Test(Revoke|Disable|Enable)UserAccessToken
* make EnableUserAccessTokens explicit, so as to not rely on local config.json
* uncomment TestResetPassword, but still skip
* mark assert(Invalid)Token as helper
* fix whitespace issues
* fix mangled comments
* MM-13116: bot plugin api (#10113)
* MM-13117: expose bot API to plugins
This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.
* gofmt issues
* expunge use of BotList in plugin/client API
* introduce model.BotGetOptions
* use botUserId term for clarity
* MM-13129 Adding functionality to deal with orphaned bots (#10238)
* Add way to list orphaned bots.
* Add /assign route to modify ownership of bot accounts.
* Apply suggestions from code review
Co-Authored-By: crspeller <crspeller@gmail.com>
* MM-13120: add IsBot field to returned user objects (#10103)
* MM-13104: forbid bot login (#10251)
* MM-13104: disallow bot login
* fix shadowing
* MM-13136 Disable user bots when user is disabled. (#10293)
* Disable user bots when user is disabled.
* Grammer.
Co-Authored-By: crspeller <crspeller@gmail.com>
* Fixing bot branch for test changes.
* Don't use external dependancies in bot plugin tests.
* Rename bot CreatorId to OwnerId
* Adding ability to re-enable bots
* Fixing IsBot to not attempt to be saved to DB.
* Adding diagnostics and licencing counting for bot accounts.
* Modifying gorp to allow reading of '-' fields.
* Removing unnessisary nil values from UserCountOptions.
* Changing comment to GoDoc format
* Improving user count SQL
* Some improvments from feedback.
* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
var botAccountsCount int64
2017-02-24 17:33:59 +00:00
var inactiveUserCount int64
var publicChannelCount int64
var privateChannelCount int64
var directChannelCount int64
var deletedPublicChannelCount int64
var deletedPrivateChannelCount int64
var postsCount int64
2019-07-02 16:10:22 -05:00
var postsCountPreviousDay int64
var botPostsCountPreviousDay int64
2019-01-31 09:02:16 -08:00
var slashCommandsCount int64
var incomingWebhooksCount int64
var outgoingWebhooksCount int64
2017-02-24 17:33:59 +00:00
2019-07-03 18:16:27 +07:00
activeUsersDailyCountChan := make ( chan store . StoreResult , 1 )
go func ( ) {
2020-06-12 13:43:50 +02:00
count , err := s . Store . User ( ) . AnalyticsActiveCount ( DAY_MILLISECONDS , model . UserCountOptions { IncludeBotAccounts : false , IncludeDeleted : false } )
2019-07-03 18:16:27 +07:00
activeUsersDailyCountChan <- store . StoreResult { Data : count , Err : err }
close ( activeUsersDailyCountChan )
} ( )
2017-02-24 17:33:59 +00:00
2019-07-03 18:16:27 +07:00
activeUsersMonthlyCountChan := make ( chan store . StoreResult , 1 )
go func ( ) {
2020-06-12 13:43:50 +02:00
count , err := s . Store . User ( ) . AnalyticsActiveCount ( MONTH_MILLISECONDS , model . UserCountOptions { IncludeBotAccounts : false , IncludeDeleted : false } )
2019-07-03 18:16:27 +07:00
activeUsersMonthlyCountChan <- store . StoreResult { Data : count , Err : err }
close ( activeUsersMonthlyCountChan )
} ( )
2018-06-05 18:19:20 +01:00
2020-06-12 13:43:50 +02:00
if count , err := s . Store . User ( ) . Count ( model . UserCountOptions { IncludeDeleted : true } ) ; err == nil {
2019-06-26 10:41:45 +02:00
userCount = count
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if count , err := s . Store . User ( ) . AnalyticsGetGuestCount ( ) ; err == nil {
2020-04-09 11:05:43 +02:00
guestAccountsCount = count
}
2020-06-12 13:43:50 +02:00
if count , err := s . Store . User ( ) . Count ( model . UserCountOptions { IncludeBotAccounts : true , ExcludeRegularUsers : true } ) ; err == nil {
2019-06-26 10:41:45 +02:00
botAccountsCount = count
MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)
* bots model, store and api
Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119
* uncomment tests incorrectly commented, and fix merge issues
* add etags support
* add missing licenses
* remove unused sqlbuilder.go (for now...)
* rejig permissions
* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS
* conform to general rest api pattern
* eliminate redundant http.StatusOK
* Update api4/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* s/model.UserFromBotModel/model.UserFromBot/g
* Update model/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* Update model/client4.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* move sessionHasPermissionToManageBot to app/authorization.go
* use api.ApiSessionRequired for createBot
* introduce BOT_DESCRIPTION_MAX_RUNES constant
* MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings
* Add additional config settings to tests
* upgrade db to 5.7 (#10019)
* MM-13526 Add validation when setting a user's Locale field (#10022)
* Fix typos (#10024)
* Fixing first user being created with system admin privilages without being explicity specified. (#10014)
* Revert "Support for Embeded chat (#9129)" (#10017)
This reverts commit 3fcecd521a5c6ccfdb52fb4c3fb1f8c6ea528a4e.
* s/DisableBot/UpdateBotActive
* add permissions on upgrade
* Update NOTICE.txt (#10054)
- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates
* avoid leaking bot knowledge without permission
* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts
* 6798 added the permsission check before getting the reactions
* GH-6798 added a new app function for the new endpoint
* 6798 added a store method to get reactions for multiple posts
* 6798 connected the app function with the new store function
* 6798 fixed the review comments
* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)
Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023
* Trigger Login Hooks with OAuth (#10061)
* make BotStore.GetAll deterministic even on duplicate CreateAt
* fix spurious TestMuteCommandSpecificChannel test failure
See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw
* fix race in TestExportUserChannels
* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway
* MM-13117: bot tokens (#10111)
* eliminate redundant Client/AdminClient declarations
* harden TestUpdateChannelScheme to API failures
* eliminate unnecessary config restoration
* minor cleanup
* make TestGenerateMfaSecret config dependency explicit
* TestCreateUserAccessToken for bots
* TestGetUserAccessToken* for bots
* leverage SessionHasPermissionToUserOrBot for user token APIs
* Test(Revoke|Disable|Enable)UserAccessToken
* make EnableUserAccessTokens explicit, so as to not rely on local config.json
* uncomment TestResetPassword, but still skip
* mark assert(Invalid)Token as helper
* fix whitespace issues
* fix mangled comments
* MM-13116: bot plugin api (#10113)
* MM-13117: expose bot API to plugins
This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.
* gofmt issues
* expunge use of BotList in plugin/client API
* introduce model.BotGetOptions
* use botUserId term for clarity
* MM-13129 Adding functionality to deal with orphaned bots (#10238)
* Add way to list orphaned bots.
* Add /assign route to modify ownership of bot accounts.
* Apply suggestions from code review
Co-Authored-By: crspeller <crspeller@gmail.com>
* MM-13120: add IsBot field to returned user objects (#10103)
* MM-13104: forbid bot login (#10251)
* MM-13104: disallow bot login
* fix shadowing
* MM-13136 Disable user bots when user is disabled. (#10293)
* Disable user bots when user is disabled.
* Grammer.
Co-Authored-By: crspeller <crspeller@gmail.com>
* Fixing bot branch for test changes.
* Don't use external dependancies in bot plugin tests.
* Rename bot CreatorId to OwnerId
* Adding ability to re-enable bots
* Fixing IsBot to not attempt to be saved to DB.
* Adding diagnostics and licencing counting for bot accounts.
* Modifying gorp to allow reading of '-' fields.
* Removing unnessisary nil values from UserCountOptions.
* Changing comment to GoDoc format
* Improving user count SQL
* Some improvments from feedback.
* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
}
2020-06-12 13:43:50 +02:00
if iucr , err := s . Store . User ( ) . AnalyticsGetInactiveUsersCount ( ) ; err == nil {
2019-06-28 15:39:53 +01:00
inactiveUserCount = iucr
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
teamCount , err := s . Store . Team ( ) . AnalyticsTeamCount ( false )
2019-06-14 08:01:24 -06:00
if err != nil {
mlog . Error ( err . Error ( ) )
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if ucc , err := s . Store . Channel ( ) . AnalyticsTypeCount ( "" , "O" ) ; err == nil {
2019-06-14 19:06:30 +02:00
publicChannelCount = ucc
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if pcc , err := s . Store . Channel ( ) . AnalyticsTypeCount ( "" , "P" ) ; err == nil {
2019-06-14 19:06:30 +02:00
privateChannelCount = pcc
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if dcc , err := s . Store . Channel ( ) . AnalyticsTypeCount ( "" , "D" ) ; err == nil {
2019-06-14 19:06:30 +02:00
directChannelCount = dcc
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if duccr , err := s . Store . Channel ( ) . AnalyticsDeletedTypeCount ( "" , "O" ) ; err == nil {
2019-06-19 15:23:16 +00:00
deletedPublicChannelCount = duccr
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if dpccr , err := s . Store . Channel ( ) . AnalyticsDeletedTypeCount ( "" , "P" ) ; err == nil {
2019-06-19 15:23:16 +00:00
deletedPrivateChannelCount = dpccr
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
postsCount , _ = s . Store . Post ( ) . AnalyticsPostCount ( "" , false , false )
2017-02-24 17:33:59 +00:00
2019-07-02 16:10:22 -05:00
postCountsOptions := & model . AnalyticsPostCountsOptions { TeamId : "" , BotsOnly : false , YesterdayOnly : true }
2020-06-12 13:43:50 +02:00
postCountsYesterday , _ := s . Store . Post ( ) . AnalyticsPostCountsByDay ( postCountsOptions )
2019-07-02 16:10:22 -05:00
postsCountPreviousDay = 0
if len ( postCountsYesterday ) > 0 {
postsCountPreviousDay = int64 ( postCountsYesterday [ 0 ] . Value )
}
postCountsOptions = & model . AnalyticsPostCountsOptions { TeamId : "" , BotsOnly : true , YesterdayOnly : true }
2020-06-12 13:43:50 +02:00
botPostCountsYesterday , _ := s . Store . Post ( ) . AnalyticsPostCountsByDay ( postCountsOptions )
2019-07-02 16:10:22 -05:00
botPostsCountPreviousDay = 0
if len ( botPostCountsYesterday ) > 0 {
botPostsCountPreviousDay = int64 ( botPostCountsYesterday [ 0 ] . Value )
}
2020-06-12 13:43:50 +02:00
slashCommandsCount , _ = s . Store . Command ( ) . AnalyticsCommandCount ( "" )
2019-01-31 09:02:16 -08:00
2020-06-12 13:43:50 +02:00
if c , err := s . Store . Webhook ( ) . AnalyticsIncomingCount ( "" ) ; err == nil {
2019-04-25 15:17:43 +09:00
incomingWebhooksCount = c
2019-01-31 09:02:16 -08:00
}
2020-06-12 13:43:50 +02:00
outgoingWebhooksCount , _ = s . Store . Webhook ( ) . AnalyticsOutgoingCount ( "" )
2019-01-31 09:02:16 -08:00
2019-07-03 18:16:27 +07:00
var activeUsersDailyCount int64
if r := <- activeUsersDailyCountChan ; r . Err == nil {
activeUsersDailyCount = r . Data . ( int64 )
}
var activeUsersMonthlyCount int64
if r := <- activeUsersMonthlyCountChan ; r . Err == nil {
activeUsersMonthlyCount = r . Data . ( int64 )
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_ACTIVITY , map [ string ] interface { } {
2018-05-03 10:00:33 -04:00
"registered_users" : userCount ,
MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)
* bots model, store and api
Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119
* uncomment tests incorrectly commented, and fix merge issues
* add etags support
* add missing licenses
* remove unused sqlbuilder.go (for now...)
* rejig permissions
* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS
* conform to general rest api pattern
* eliminate redundant http.StatusOK
* Update api4/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* s/model.UserFromBotModel/model.UserFromBot/g
* Update model/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* Update model/client4.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* move sessionHasPermissionToManageBot to app/authorization.go
* use api.ApiSessionRequired for createBot
* introduce BOT_DESCRIPTION_MAX_RUNES constant
* MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings
* Add additional config settings to tests
* upgrade db to 5.7 (#10019)
* MM-13526 Add validation when setting a user's Locale field (#10022)
* Fix typos (#10024)
* Fixing first user being created with system admin privilages without being explicity specified. (#10014)
* Revert "Support for Embeded chat (#9129)" (#10017)
This reverts commit 3fcecd521a5c6ccfdb52fb4c3fb1f8c6ea528a4e.
* s/DisableBot/UpdateBotActive
* add permissions on upgrade
* Update NOTICE.txt (#10054)
- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates
* avoid leaking bot knowledge without permission
* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts
* 6798 added the permsission check before getting the reactions
* GH-6798 added a new app function for the new endpoint
* 6798 added a store method to get reactions for multiple posts
* 6798 connected the app function with the new store function
* 6798 fixed the review comments
* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)
Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023
* Trigger Login Hooks with OAuth (#10061)
* make BotStore.GetAll deterministic even on duplicate CreateAt
* fix spurious TestMuteCommandSpecificChannel test failure
See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw
* fix race in TestExportUserChannels
* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway
* MM-13117: bot tokens (#10111)
* eliminate redundant Client/AdminClient declarations
* harden TestUpdateChannelScheme to API failures
* eliminate unnecessary config restoration
* minor cleanup
* make TestGenerateMfaSecret config dependency explicit
* TestCreateUserAccessToken for bots
* TestGetUserAccessToken* for bots
* leverage SessionHasPermissionToUserOrBot for user token APIs
* Test(Revoke|Disable|Enable)UserAccessToken
* make EnableUserAccessTokens explicit, so as to not rely on local config.json
* uncomment TestResetPassword, but still skip
* mark assert(Invalid)Token as helper
* fix whitespace issues
* fix mangled comments
* MM-13116: bot plugin api (#10113)
* MM-13117: expose bot API to plugins
This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.
* gofmt issues
* expunge use of BotList in plugin/client API
* introduce model.BotGetOptions
* use botUserId term for clarity
* MM-13129 Adding functionality to deal with orphaned bots (#10238)
* Add way to list orphaned bots.
* Add /assign route to modify ownership of bot accounts.
* Apply suggestions from code review
Co-Authored-By: crspeller <crspeller@gmail.com>
* MM-13120: add IsBot field to returned user objects (#10103)
* MM-13104: forbid bot login (#10251)
* MM-13104: disallow bot login
* fix shadowing
* MM-13136 Disable user bots when user is disabled. (#10293)
* Disable user bots when user is disabled.
* Grammer.
Co-Authored-By: crspeller <crspeller@gmail.com>
* Fixing bot branch for test changes.
* Don't use external dependancies in bot plugin tests.
* Rename bot CreatorId to OwnerId
* Adding ability to re-enable bots
* Fixing IsBot to not attempt to be saved to DB.
* Adding diagnostics and licencing counting for bot accounts.
* Modifying gorp to allow reading of '-' fields.
* Removing unnessisary nil values from UserCountOptions.
* Changing comment to GoDoc format
* Improving user count SQL
* Some improvments from feedback.
* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
"bot_accounts" : botAccountsCount ,
2020-04-09 11:05:43 +02:00
"guest_accounts" : guestAccountsCount ,
2018-06-05 18:19:20 +01:00
"active_users_daily" : activeUsersDailyCount ,
"active_users_monthly" : activeUsersMonthlyCount ,
2018-05-03 10:00:33 -04:00
"registered_deactivated_users" : inactiveUserCount ,
2018-10-01 19:19:11 +02:00
"teams" : teamCount ,
"public_channels" : publicChannelCount ,
"private_channels" : privateChannelCount ,
"direct_message_channels" : directChannelCount ,
"public_channels_deleted" : deletedPublicChannelCount ,
"private_channels_deleted" : deletedPrivateChannelCount ,
2019-07-02 16:10:22 -05:00
"posts_previous_day" : postsCountPreviousDay ,
"bot_posts_previous_day" : botPostsCountPreviousDay ,
2018-10-01 19:19:11 +02:00
"posts" : postsCount ,
2019-01-31 09:02:16 -08:00
"slash_commands" : slashCommandsCount ,
"incoming_webhooks" : incomingWebhooksCount ,
"outgoing_webhooks" : outgoingWebhooksCount ,
2017-02-24 17:33:59 +00:00
} )
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackConfig ( ) {
cfg := s . Config ( )
s . SendDiagnostic ( TRACK_CONFIG_SERVICE , map [ string ] interface { } {
2018-10-01 19:19:11 +02:00
"web_server_mode" : * cfg . ServiceSettings . WebserverMode ,
"enable_security_fix_alert" : * cfg . ServiceSettings . EnableSecurityFixAlert ,
"enable_insecure_outgoing_connections" : * cfg . ServiceSettings . EnableInsecureOutgoingConnections ,
"enable_incoming_webhooks" : cfg . ServiceSettings . EnableIncomingWebhooks ,
"enable_outgoing_webhooks" : cfg . ServiceSettings . EnableOutgoingWebhooks ,
"enable_commands" : * cfg . ServiceSettings . EnableCommands ,
2018-10-31 08:38:38 +00:00
"enable_only_admin_integrations" : * cfg . ServiceSettings . DEPRECATED_DO_NOT_USE_EnableOnlyAdminIntegrations ,
2018-10-01 19:19:11 +02:00
"enable_post_username_override" : cfg . ServiceSettings . EnablePostUsernameOverride ,
"enable_post_icon_override" : cfg . ServiceSettings . EnablePostIconOverride ,
"enable_user_access_tokens" : * cfg . ServiceSettings . EnableUserAccessTokens ,
"enable_custom_emoji" : * cfg . ServiceSettings . EnableCustomEmoji ,
"enable_emoji_picker" : * cfg . ServiceSettings . EnableEmojiPicker ,
"enable_gif_picker" : * cfg . ServiceSettings . EnableGifPicker ,
"gfycat_api_key" : isDefault ( * cfg . ServiceSettings . GfycatApiKey , model . SERVICE_SETTINGS_DEFAULT_GFYCAT_API_KEY ) ,
"gfycat_api_secret" : isDefault ( * cfg . ServiceSettings . GfycatApiSecret , model . SERVICE_SETTINGS_DEFAULT_GFYCAT_API_SECRET ) ,
"experimental_enable_authentication_transfer" : * cfg . ServiceSettings . ExperimentalEnableAuthenticationTransfer ,
2018-10-31 08:38:38 +00:00
"restrict_custom_emoji_creation" : * cfg . ServiceSettings . DEPRECATED_DO_NOT_USE_RestrictCustomEmojiCreation ,
2018-10-01 19:19:11 +02:00
"enable_testing" : cfg . ServiceSettings . EnableTesting ,
"enable_developer" : * cfg . ServiceSettings . EnableDeveloper ,
"enable_multifactor_authentication" : * cfg . ServiceSettings . EnableMultifactorAuthentication ,
"enforce_multifactor_authentication" : * cfg . ServiceSettings . EnforceMultifactorAuthentication ,
"enable_oauth_service_provider" : cfg . ServiceSettings . EnableOAuthServiceProvider ,
"connection_security" : * cfg . ServiceSettings . ConnectionSecurity ,
2019-01-22 15:29:15 -05:00
"tls_strict_transport" : * cfg . ServiceSettings . TLSStrictTransport ,
2018-10-01 19:19:11 +02:00
"uses_letsencrypt" : * cfg . ServiceSettings . UseLetsEncrypt ,
"forward_80_to_443" : * cfg . ServiceSettings . Forward80To443 ,
"maximum_login_attempts" : * cfg . ServiceSettings . MaximumLoginAttempts ,
2020-05-06 15:41:10 -04:00
"extend_session_length_with_activity" : * cfg . ServiceSettings . ExtendSessionLengthWithActivity ,
2018-10-01 19:19:11 +02:00
"session_length_web_in_days" : * cfg . ServiceSettings . SessionLengthWebInDays ,
"session_length_mobile_in_days" : * cfg . ServiceSettings . SessionLengthMobileInDays ,
"session_length_sso_in_days" : * cfg . ServiceSettings . SessionLengthSSOInDays ,
"session_cache_in_minutes" : * cfg . ServiceSettings . SessionCacheInMinutes ,
"session_idle_timeout_in_minutes" : * cfg . ServiceSettings . SessionIdleTimeoutInMinutes ,
"isdefault_site_url" : isDefault ( * cfg . ServiceSettings . SiteURL , model . SERVICE_SETTINGS_DEFAULT_SITE_URL ) ,
"isdefault_tls_cert_file" : isDefault ( * cfg . ServiceSettings . TLSCertFile , model . SERVICE_SETTINGS_DEFAULT_TLS_CERT_FILE ) ,
"isdefault_tls_key_file" : isDefault ( * cfg . ServiceSettings . TLSKeyFile , model . SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE ) ,
"isdefault_read_timeout" : isDefault ( * cfg . ServiceSettings . ReadTimeout , model . SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT ) ,
"isdefault_write_timeout" : isDefault ( * cfg . ServiceSettings . WriteTimeout , model . SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT ) ,
2020-04-13 23:38:57 +05:30
"isdefault_idle_timeout" : isDefault ( * cfg . ServiceSettings . IdleTimeout , model . SERVICE_SETTINGS_DEFAULT_IDLE_TIMEOUT ) ,
2018-10-01 19:19:11 +02:00
"isdefault_google_developer_key" : isDefault ( cfg . ServiceSettings . GoogleDeveloperKey , "" ) ,
"isdefault_allow_cors_from" : isDefault ( * cfg . ServiceSettings . AllowCorsFrom , model . SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM ) ,
"isdefault_cors_exposed_headers" : isDefault ( cfg . ServiceSettings . CorsExposedHeaders , "" ) ,
"cors_allow_credentials" : * cfg . ServiceSettings . CorsAllowCredentials ,
"cors_debug" : * cfg . ServiceSettings . CorsDebug ,
2018-01-10 14:04:04 -08:00
"isdefault_allowed_untrusted_internal_connections" : isDefault ( * cfg . ServiceSettings . AllowedUntrustedInternalConnections , "" ) ,
2018-10-31 08:38:38 +00:00
"restrict_post_delete" : * cfg . ServiceSettings . DEPRECATED_DO_NOT_USE_RestrictPostDelete ,
"allow_edit_post" : * cfg . ServiceSettings . DEPRECATED_DO_NOT_USE_AllowEditPost ,
2018-01-10 14:04:04 -08:00
"post_edit_time_limit" : * cfg . ServiceSettings . PostEditTimeLimit ,
"enable_user_typing_messages" : * cfg . ServiceSettings . EnableUserTypingMessages ,
"enable_channel_viewed_messages" : * cfg . ServiceSettings . EnableChannelViewedMessages ,
"time_between_user_typing_updates_milliseconds" : * cfg . ServiceSettings . TimeBetweenUserTypingUpdatesMilliseconds ,
"cluster_log_timeout_milliseconds" : * cfg . ServiceSettings . ClusterLogTimeoutMilliseconds ,
"enable_post_search" : * cfg . ServiceSettings . EnablePostSearch ,
2019-03-11 22:09:50 +09:00
"minimum_hashtag_length" : * cfg . ServiceSettings . MinimumHashtagLength ,
2018-01-10 14:04:04 -08:00
"enable_user_statuses" : * cfg . ServiceSettings . EnableUserStatuses ,
"close_unused_direct_messages" : * cfg . ServiceSettings . CloseUnusedDirectMessages ,
2018-01-23 15:07:31 -05:00
"enable_preview_features" : * cfg . ServiceSettings . EnablePreviewFeatures ,
"enable_tutorial" : * cfg . ServiceSettings . EnableTutorial ,
2018-01-10 14:04:04 -08:00
"experimental_enable_default_channel_leave_join_messages" : * cfg . ServiceSettings . ExperimentalEnableDefaultChannelLeaveJoinMessages ,
2018-01-23 17:59:41 -03:00
"experimental_group_unread_channels" : * cfg . ServiceSettings . ExperimentalGroupUnreadChannels ,
2018-02-20 12:49:45 -08:00
"websocket_url" : isDefault ( * cfg . ServiceSettings . WebsocketURL , "" ) ,
"allow_cookies_for_subdomains" : * cfg . ServiceSettings . AllowCookiesForSubdomains ,
2018-06-07 15:52:07 +02:00
"enable_api_team_deletion" : * cfg . ServiceSettings . EnableAPITeamDeletion ,
"experimental_enable_hardened_mode" : * cfg . ServiceSettings . ExperimentalEnableHardenedMode ,
2019-04-17 15:48:11 +02:00
"disable_legacy_mfa" : * cfg . ServiceSettings . DisableLegacyMFA ,
2019-01-31 20:39:02 +01:00
"experimental_strict_csrf_enforcement" : * cfg . ServiceSettings . ExperimentalStrictCSRFEnforcement ,
2018-07-12 10:21:29 -04:00
"enable_email_invitations" : * cfg . ServiceSettings . EnableEmailInvitations ,
2018-07-23 08:18:24 -07:00
"experimental_channel_organization" : * cfg . ServiceSettings . ExperimentalChannelOrganization ,
2020-03-17 12:01:59 -04:00
"experimental_channel_sidebar_organization" : * cfg . ServiceSettings . ExperimentalChannelSidebarOrganization ,
MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)
* bots model, store and api
Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119
* uncomment tests incorrectly commented, and fix merge issues
* add etags support
* add missing licenses
* remove unused sqlbuilder.go (for now...)
* rejig permissions
* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS
* conform to general rest api pattern
* eliminate redundant http.StatusOK
* Update api4/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* s/model.UserFromBotModel/model.UserFromBot/g
* Update model/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* Update model/client4.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* move sessionHasPermissionToManageBot to app/authorization.go
* use api.ApiSessionRequired for createBot
* introduce BOT_DESCRIPTION_MAX_RUNES constant
* MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings
* Add additional config settings to tests
* upgrade db to 5.7 (#10019)
* MM-13526 Add validation when setting a user's Locale field (#10022)
* Fix typos (#10024)
* Fixing first user being created with system admin privilages without being explicity specified. (#10014)
* Revert "Support for Embeded chat (#9129)" (#10017)
This reverts commit 3fcecd521a5c6ccfdb52fb4c3fb1f8c6ea528a4e.
* s/DisableBot/UpdateBotActive
* add permissions on upgrade
* Update NOTICE.txt (#10054)
- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates
* avoid leaking bot knowledge without permission
* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts
* 6798 added the permsission check before getting the reactions
* GH-6798 added a new app function for the new endpoint
* 6798 added a store method to get reactions for multiple posts
* 6798 connected the app function with the new store function
* 6798 fixed the review comments
* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)
Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023
* Trigger Login Hooks with OAuth (#10061)
* make BotStore.GetAll deterministic even on duplicate CreateAt
* fix spurious TestMuteCommandSpecificChannel test failure
See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw
* fix race in TestExportUserChannels
* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway
* MM-13117: bot tokens (#10111)
* eliminate redundant Client/AdminClient declarations
* harden TestUpdateChannelScheme to API failures
* eliminate unnecessary config restoration
* minor cleanup
* make TestGenerateMfaSecret config dependency explicit
* TestCreateUserAccessToken for bots
* TestGetUserAccessToken* for bots
* leverage SessionHasPermissionToUserOrBot for user token APIs
* Test(Revoke|Disable|Enable)UserAccessToken
* make EnableUserAccessTokens explicit, so as to not rely on local config.json
* uncomment TestResetPassword, but still skip
* mark assert(Invalid)Token as helper
* fix whitespace issues
* fix mangled comments
* MM-13116: bot plugin api (#10113)
* MM-13117: expose bot API to plugins
This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.
* gofmt issues
* expunge use of BotList in plugin/client API
* introduce model.BotGetOptions
* use botUserId term for clarity
* MM-13129 Adding functionality to deal with orphaned bots (#10238)
* Add way to list orphaned bots.
* Add /assign route to modify ownership of bot accounts.
* Apply suggestions from code review
Co-Authored-By: crspeller <crspeller@gmail.com>
* MM-13120: add IsBot field to returned user objects (#10103)
* MM-13104: forbid bot login (#10251)
* MM-13104: disallow bot login
* fix shadowing
* MM-13136 Disable user bots when user is disabled. (#10293)
* Disable user bots when user is disabled.
* Grammer.
Co-Authored-By: crspeller <crspeller@gmail.com>
* Fixing bot branch for test changes.
* Don't use external dependancies in bot plugin tests.
* Rename bot CreatorId to OwnerId
* Adding ability to re-enable bots
* Fixing IsBot to not attempt to be saved to DB.
* Adding diagnostics and licencing counting for bot accounts.
* Modifying gorp to allow reading of '-' fields.
* Removing unnessisary nil values from UserCountOptions.
* Changing comment to GoDoc format
* Improving user count SQL
* Some improvments from feedback.
* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
"disable_bots_when_owner_is_deactivated" : * cfg . ServiceSettings . DisableBotsWhenOwnerIsDeactivated ,
2019-05-23 16:03:22 -04:00
"enable_bot_account_creation" : * cfg . ServiceSettings . EnableBotAccountCreation ,
2019-08-14 13:40:40 -04:00
"enable_svgs" : * cfg . ServiceSettings . EnableSVGs ,
2019-10-25 19:58:48 +02:00
"enable_latex" : * cfg . ServiceSettings . EnableLatex ,
2020-04-16 20:17:46 +03:00
"enable_opentracing" : * cfg . ServiceSettings . EnableOpenTracing ,
2020-06-03 14:43:59 +05:30
"experimental_data_prefetch" : * cfg . ServiceSettings . ExperimentalDataPrefetch ,
2020-06-09 09:04:52 +01:00
"enable_local_mode" : * cfg . ServiceSettings . EnableLocalMode ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_TEAM , map [ string ] interface { } {
2018-05-25 04:41:30 +08:00
"enable_user_creation" : cfg . TeamSettings . EnableUserCreation ,
2018-10-31 08:38:38 +00:00
"enable_team_creation" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_EnableTeamCreation ,
"restrict_team_invite" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictTeamInvite ,
"restrict_public_channel_creation" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPublicChannelCreation ,
"restrict_private_channel_creation" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPrivateChannelCreation ,
"restrict_public_channel_management" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPublicChannelManagement ,
"restrict_private_channel_management" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPrivateChannelManagement ,
"restrict_public_channel_deletion" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPublicChannelDeletion ,
"restrict_private_channel_deletion" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPrivateChannelDeletion ,
2018-05-25 04:41:30 +08:00
"enable_open_server" : * cfg . TeamSettings . EnableOpenServer ,
2018-06-07 15:52:07 +02:00
"enable_user_deactivation" : * cfg . TeamSettings . EnableUserDeactivation ,
2018-05-25 04:41:30 +08:00
"enable_custom_brand" : * cfg . TeamSettings . EnableCustomBrand ,
"restrict_direct_message" : * cfg . TeamSettings . RestrictDirectMessage ,
"max_notifications_per_channel" : * cfg . TeamSettings . MaxNotificationsPerChannel ,
"enable_confirm_notifications_to_channel" : * cfg . TeamSettings . EnableConfirmNotificationsToChannel ,
"max_users_per_team" : * cfg . TeamSettings . MaxUsersPerTeam ,
"max_channels_per_team" : * cfg . TeamSettings . MaxChannelsPerTeam ,
"teammate_name_display" : * cfg . TeamSettings . TeammateNameDisplay ,
2018-08-22 20:12:51 +01:00
"experimental_view_archived_channels" : * cfg . TeamSettings . ExperimentalViewArchivedChannels ,
2019-12-12 09:17:31 -05:00
"lock_teammate_name_display" : * cfg . TeamSettings . LockTeammateNameDisplay ,
2018-05-25 04:41:30 +08:00
"isdefault_site_name" : isDefault ( cfg . TeamSettings . SiteName , "Mattermost" ) ,
"isdefault_custom_brand_text" : isDefault ( * cfg . TeamSettings . CustomBrandText , model . TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT ) ,
"isdefault_custom_description_text" : isDefault ( * cfg . TeamSettings . CustomDescriptionText , model . TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT ) ,
"isdefault_user_status_away_timeout" : isDefault ( * cfg . TeamSettings . UserStatusAwayTimeout , model . TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT ) ,
2018-10-31 08:38:38 +00:00
"restrict_private_channel_manage_members" : * cfg . TeamSettings . DEPRECATED_DO_NOT_USE_RestrictPrivateChannelManageMembers ,
2018-05-25 04:41:30 +08:00
"enable_X_to_leave_channels_from_LHS" : * cfg . TeamSettings . EnableXToLeaveChannelsFromLHS ,
"experimental_enable_automatic_replies" : * cfg . TeamSettings . ExperimentalEnableAutomaticReplies ,
"experimental_town_square_is_hidden_in_lhs" : * cfg . TeamSettings . ExperimentalHideTownSquareinLHS ,
"experimental_town_square_is_read_only" : * cfg . TeamSettings . ExperimentalTownSquareIsReadOnly ,
"experimental_primary_team" : isDefault ( * cfg . TeamSettings . ExperimentalPrimaryTeam , "" ) ,
2018-07-20 23:00:58 +02:00
"experimental_default_channels" : len ( cfg . TeamSettings . ExperimentalDefaultChannels ) ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_CLIENT_REQ , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"android_latest_version" : cfg . ClientRequirements . AndroidLatestVersion ,
"android_min_version" : cfg . ClientRequirements . AndroidMinVersion ,
"desktop_latest_version" : cfg . ClientRequirements . DesktopLatestVersion ,
"desktop_min_version" : cfg . ClientRequirements . DesktopMinVersion ,
"ios_latest_version" : cfg . ClientRequirements . IosLatestVersion ,
"ios_min_version" : cfg . ClientRequirements . IosMinVersion ,
2017-08-28 09:22:54 -07:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_SQL , map [ string ] interface { } {
2018-10-25 13:25:27 -04:00
"driver_name" : * cfg . SqlSettings . DriverName ,
"trace" : cfg . SqlSettings . Trace ,
"max_idle_conns" : * cfg . SqlSettings . MaxIdleConns ,
"conn_max_lifetime_milliseconds" : * cfg . SqlSettings . ConnMaxLifetimeMilliseconds ,
"max_open_conns" : * cfg . SqlSettings . MaxOpenConns ,
"data_source_replicas" : len ( cfg . SqlSettings . DataSourceReplicas ) ,
"data_source_search_replicas" : len ( cfg . SqlSettings . DataSourceSearchReplicas ) ,
"query_timeout" : * cfg . SqlSettings . QueryTimeout ,
2020-06-09 09:04:52 +01:00
"disable_database_search" : * cfg . SqlSettings . DisableDatabaseSearch ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_LOG , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_console" : cfg . LogSettings . EnableConsole ,
"console_level" : cfg . LogSettings . ConsoleLevel ,
2018-04-27 12:49:45 -07:00
"console_json" : * cfg . LogSettings . ConsoleJson ,
2017-10-23 02:39:51 -07:00
"enable_file" : cfg . LogSettings . EnableFile ,
"file_level" : cfg . LogSettings . FileLevel ,
2018-04-27 12:49:45 -07:00
"file_json" : cfg . LogSettings . FileJson ,
2017-10-23 02:39:51 -07:00
"enable_webhook_debugging" : cfg . LogSettings . EnableWebhookDebugging ,
"isdefault_file_location" : isDefault ( cfg . LogSettings . FileLocation , "" ) ,
2020-07-15 14:40:36 -04:00
"advanced_logging_config" : * cfg . LogSettings . AdvancedLoggingConfig != "" ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_AUDIT , map [ string ] interface { } {
2020-07-22 18:48:46 -04:00
"file_enabled" : * cfg . ExperimentalAuditSettings . FileEnabled ,
"file_max_size_mb" : * cfg . ExperimentalAuditSettings . FileMaxSizeMB ,
"file_max_age_days" : * cfg . ExperimentalAuditSettings . FileMaxAgeDays ,
"file_max_backups" : * cfg . ExperimentalAuditSettings . FileMaxBackups ,
"file_compress" : * cfg . ExperimentalAuditSettings . FileCompress ,
"file_max_queue_size" : * cfg . ExperimentalAuditSettings . FileMaxQueueSize ,
"advanced_logging_config" : * cfg . ExperimentalAuditSettings . AdvancedLoggingConfig != "" ,
2020-04-14 22:30:27 -04:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_NOTIFICATION_LOG , map [ string ] interface { } {
2019-05-21 17:51:15 -04:00
"enable_console" : * cfg . NotificationLogSettings . EnableConsole ,
"console_level" : * cfg . NotificationLogSettings . ConsoleLevel ,
"console_json" : * cfg . NotificationLogSettings . ConsoleJson ,
"enable_file" : * cfg . NotificationLogSettings . EnableFile ,
"file_level" : * cfg . NotificationLogSettings . FileLevel ,
"file_json" : * cfg . NotificationLogSettings . FileJson ,
"isdefault_file_location" : isDefault ( * cfg . NotificationLogSettings . FileLocation , "" ) ,
2020-07-22 18:48:46 -04:00
"advanced_logging_config" : * cfg . NotificationLogSettings . AdvancedLoggingConfig != "" ,
2019-05-21 17:51:15 -04:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_PASSWORD , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"minimum_length" : * cfg . PasswordSettings . MinimumLength ,
"lowercase" : * cfg . PasswordSettings . Lowercase ,
"number" : * cfg . PasswordSettings . Number ,
"uppercase" : * cfg . PasswordSettings . Uppercase ,
"symbol" : * cfg . PasswordSettings . Symbol ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_FILE , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_public_links" : cfg . FileSettings . EnablePublicLink ,
"driver_name" : * cfg . FileSettings . DriverName ,
2019-01-31 08:12:01 -05:00
"isdefault_directory" : isDefault ( * cfg . FileSettings . Directory , model . FILE_SETTINGS_DEFAULT_DIRECTORY ) ,
"isabsolute_directory" : filepath . IsAbs ( * cfg . FileSettings . Directory ) ,
2017-10-23 02:39:51 -07:00
"amazon_s3_ssl" : * cfg . FileSettings . AmazonS3SSL ,
"amazon_s3_sse" : * cfg . FileSettings . AmazonS3SSE ,
"amazon_s3_signv2" : * cfg . FileSettings . AmazonS3SignV2 ,
"amazon_s3_trace" : * cfg . FileSettings . AmazonS3Trace ,
"max_file_size" : * cfg . FileSettings . MaxFileSize ,
"enable_file_attachments" : * cfg . FileSettings . EnableFileAttachments ,
"enable_mobile_upload" : * cfg . FileSettings . EnableMobileUpload ,
"enable_mobile_download" : * cfg . FileSettings . EnableMobileDownload ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_EMAIL , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_sign_up_with_email" : cfg . EmailSettings . EnableSignUpWithEmail ,
"enable_sign_in_with_email" : * cfg . EmailSettings . EnableSignInWithEmail ,
"enable_sign_in_with_username" : * cfg . EmailSettings . EnableSignInWithUsername ,
"require_email_verification" : cfg . EmailSettings . RequireEmailVerification ,
"send_email_notifications" : cfg . EmailSettings . SendEmailNotifications ,
2018-01-10 21:50:22 -05:00
"use_channel_in_email_notifications" : * cfg . EmailSettings . UseChannelInEmailNotifications ,
2017-10-23 02:39:51 -07:00
"email_notification_contents_type" : * cfg . EmailSettings . EmailNotificationContentsType ,
"enable_smtp_auth" : * cfg . EmailSettings . EnableSMTPAuth ,
"connection_security" : cfg . EmailSettings . ConnectionSecurity ,
"send_push_notifications" : * cfg . EmailSettings . SendPushNotifications ,
"push_notification_contents" : * cfg . EmailSettings . PushNotificationContents ,
"enable_email_batching" : * cfg . EmailSettings . EnableEmailBatching ,
"email_batching_buffer_size" : * cfg . EmailSettings . EmailBatchingBufferSize ,
"email_batching_interval" : * cfg . EmailSettings . EmailBatchingInterval ,
2018-05-23 02:10:27 +08:00
"enable_preview_mode_banner" : * cfg . EmailSettings . EnablePreviewModeBanner ,
2017-10-23 02:39:51 -07:00
"isdefault_feedback_name" : isDefault ( cfg . EmailSettings . FeedbackName , "" ) ,
"isdefault_feedback_email" : isDefault ( cfg . EmailSettings . FeedbackEmail , "" ) ,
2019-02-04 17:01:05 -05:00
"isdefault_reply_to_address" : isDefault ( cfg . EmailSettings . ReplyToAddress , "" ) ,
2017-10-23 02:39:51 -07:00
"isdefault_feedback_organization" : isDefault ( * cfg . EmailSettings . FeedbackOrganization , model . EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION ) ,
"skip_server_certificate_verification" : * cfg . EmailSettings . SkipServerCertificateVerification ,
2018-01-10 21:50:22 -05:00
"isdefault_login_button_color" : isDefault ( * cfg . EmailSettings . LoginButtonColor , "" ) ,
"isdefault_login_button_border_color" : isDefault ( * cfg . EmailSettings . LoginButtonBorderColor , "" ) ,
"isdefault_login_button_text_color" : isDefault ( * cfg . EmailSettings . LoginButtonTextColor , "" ) ,
2020-04-13 22:08:57 +03:00
"smtp_server_timeout" : * cfg . EmailSettings . SMTPServerTimeout ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_RATE , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_rate_limiter" : * cfg . RateLimitSettings . Enable ,
2018-02-05 11:18:46 -05:00
"vary_by_remote_address" : * cfg . RateLimitSettings . VaryByRemoteAddr ,
"vary_by_user" : * cfg . RateLimitSettings . VaryByUser ,
2017-10-23 02:39:51 -07:00
"per_sec" : * cfg . RateLimitSettings . PerSec ,
"max_burst" : * cfg . RateLimitSettings . MaxBurst ,
"memory_store_size" : * cfg . RateLimitSettings . MemoryStoreSize ,
"isdefault_vary_by_header" : isDefault ( cfg . RateLimitSettings . VaryByHeader , "" ) ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_PRIVACY , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"show_email_address" : cfg . PrivacySettings . ShowEmailAddress ,
"show_full_name" : cfg . PrivacySettings . ShowFullName ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_THEME , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_theme_selection" : * cfg . ThemeSettings . EnableThemeSelection ,
"isdefault_default_theme" : isDefault ( * cfg . ThemeSettings . DefaultTheme , model . TEAM_SETTINGS_DEFAULT_TEAM_TEXT ) ,
"allow_custom_themes" : * cfg . ThemeSettings . AllowCustomThemes ,
"allowed_themes" : len ( cfg . ThemeSettings . AllowedThemes ) ,
2017-09-05 19:28:46 -05:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_OAUTH , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_gitlab" : cfg . GitLabSettings . Enable ,
"enable_google" : cfg . GoogleSettings . Enable ,
"enable_office365" : cfg . Office365Settings . Enable ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_SUPPORT , map [ string ] interface { } {
2018-11-09 02:18:14 +05:30
"isdefault_terms_of_service_link" : isDefault ( * cfg . SupportSettings . TermsOfServiceLink , model . SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK ) ,
"isdefault_privacy_policy_link" : isDefault ( * cfg . SupportSettings . PrivacyPolicyLink , model . SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK ) ,
"isdefault_about_link" : isDefault ( * cfg . SupportSettings . AboutLink , model . SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK ) ,
"isdefault_help_link" : isDefault ( * cfg . SupportSettings . HelpLink , model . SUPPORT_SETTINGS_DEFAULT_HELP_LINK ) ,
"isdefault_report_a_problem_link" : isDefault ( * cfg . SupportSettings . ReportAProblemLink , model . SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK ) ,
"isdefault_support_email" : isDefault ( * cfg . SupportSettings . SupportEmail , model . SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL ) ,
"custom_terms_of_service_enabled" : * cfg . SupportSettings . CustomTermsOfServiceEnabled ,
"custom_terms_of_service_re_acceptance_period" : * cfg . SupportSettings . CustomTermsOfServiceReAcceptancePeriod ,
2020-07-09 17:59:22 +05:30
"enable_ask_community_link" : * cfg . SupportSettings . EnableAskCommunityLink ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_LDAP , map [ string ] interface { } {
2019-01-10 15:17:31 -05:00
"enable" : * cfg . LdapSettings . Enable ,
"enable_sync" : * cfg . LdapSettings . EnableSync ,
2020-01-13 12:50:01 -05:00
"enable_admin_filter" : * cfg . LdapSettings . EnableAdminFilter ,
2019-01-10 15:17:31 -05:00
"connection_security" : * cfg . LdapSettings . ConnectionSecurity ,
"skip_certificate_verification" : * cfg . LdapSettings . SkipCertificateVerification ,
"sync_interval_minutes" : * cfg . LdapSettings . SyncIntervalMinutes ,
"query_timeout" : * cfg . LdapSettings . QueryTimeout ,
"max_page_size" : * cfg . LdapSettings . MaxPageSize ,
"isdefault_first_name_attribute" : isDefault ( * cfg . LdapSettings . FirstNameAttribute , model . LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE ) ,
"isdefault_last_name_attribute" : isDefault ( * cfg . LdapSettings . LastNameAttribute , model . LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE ) ,
"isdefault_email_attribute" : isDefault ( * cfg . LdapSettings . EmailAttribute , model . LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE ) ,
"isdefault_username_attribute" : isDefault ( * cfg . LdapSettings . UsernameAttribute , model . LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE ) ,
"isdefault_nickname_attribute" : isDefault ( * cfg . LdapSettings . NicknameAttribute , model . LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE ) ,
"isdefault_id_attribute" : isDefault ( * cfg . LdapSettings . IdAttribute , model . LDAP_SETTINGS_DEFAULT_ID_ATTRIBUTE ) ,
"isdefault_position_attribute" : isDefault ( * cfg . LdapSettings . PositionAttribute , model . LDAP_SETTINGS_DEFAULT_POSITION_ATTRIBUTE ) ,
"isdefault_login_id_attribute" : isDefault ( * cfg . LdapSettings . LoginIdAttribute , "" ) ,
"isdefault_login_field_name" : isDefault ( * cfg . LdapSettings . LoginFieldName , model . LDAP_SETTINGS_DEFAULT_LOGIN_FIELD_NAME ) ,
"isdefault_login_button_color" : isDefault ( * cfg . LdapSettings . LoginButtonColor , "" ) ,
"isdefault_login_button_border_color" : isDefault ( * cfg . LdapSettings . LoginButtonBorderColor , "" ) ,
"isdefault_login_button_text_color" : isDefault ( * cfg . LdapSettings . LoginButtonTextColor , "" ) ,
"isempty_group_filter" : isDefault ( * cfg . LdapSettings . GroupFilter , "" ) ,
"isdefault_group_display_name_attribute" : isDefault ( * cfg . LdapSettings . GroupDisplayNameAttribute , model . LDAP_SETTINGS_DEFAULT_GROUP_DISPLAY_NAME_ATTRIBUTE ) ,
"isdefault_group_id_attribute" : isDefault ( * cfg . LdapSettings . GroupIdAttribute , model . LDAP_SETTINGS_DEFAULT_GROUP_ID_ATTRIBUTE ) ,
2019-10-14 11:38:17 -06:00
"isempty_guest_filter" : isDefault ( * cfg . LdapSettings . GuestFilter , "" ) ,
2020-01-13 12:50:01 -05:00
"isempty_admin_filter" : isDefault ( * cfg . LdapSettings . AdminFilter , "" ) ,
2020-05-27 10:24:58 -04:00
"isnotempty_picture_attribute" : ! isDefault ( * cfg . LdapSettings . PictureAttribute , "" ) ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_COMPLIANCE , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable" : * cfg . ComplianceSettings . Enable ,
"enable_daily" : * cfg . ComplianceSettings . EnableDaily ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_LOCALIZATION , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"default_server_locale" : * cfg . LocalizationSettings . DefaultServerLocale ,
"default_client_locale" : * cfg . LocalizationSettings . DefaultClientLocale ,
"available_locales" : * cfg . LocalizationSettings . AvailableLocales ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_SAML , map [ string ] interface { } {
2018-10-01 19:19:11 +02:00
"enable" : * cfg . SamlSettings . Enable ,
"enable_sync_with_ldap" : * cfg . SamlSettings . EnableSyncWithLdap ,
"enable_sync_with_ldap_include_auth" : * cfg . SamlSettings . EnableSyncWithLdapIncludeAuth ,
2020-01-13 12:50:01 -05:00
"enable_admin_attribute" : * cfg . SamlSettings . EnableAdminAttribute ,
2018-01-10 21:50:22 -05:00
"verify" : * cfg . SamlSettings . Verify ,
"encrypt" : * cfg . SamlSettings . Encrypt ,
2019-06-11 14:14:15 +03:00
"sign_request" : * cfg . SamlSettings . SignRequest ,
2019-12-12 09:17:31 -05:00
"isdefault_signature_algorithm" : isDefault ( * cfg . SamlSettings . SignatureAlgorithm , "" ) ,
"isdefault_canonical_algorithm" : isDefault ( * cfg . SamlSettings . CanonicalAlgorithm , "" ) ,
2018-03-28 07:54:44 -04:00
"isdefault_scoping_idp_provider_id" : isDefault ( * cfg . SamlSettings . ScopingIDPProviderId , "" ) ,
"isdefault_scoping_idp_name" : isDefault ( * cfg . SamlSettings . ScopingIDPName , "" ) ,
2018-08-28 11:56:40 +02:00
"isdefault_id_attribute" : isDefault ( * cfg . SamlSettings . IdAttribute , model . SAML_SETTINGS_DEFAULT_ID_ATTRIBUTE ) ,
2019-10-10 11:37:57 -06:00
"isdefault_guest_attribute" : isDefault ( * cfg . SamlSettings . GuestAttribute , model . SAML_SETTINGS_DEFAULT_GUEST_ATTRIBUTE ) ,
2020-01-13 12:50:01 -05:00
"isdefault_admin_attribute" : isDefault ( * cfg . SamlSettings . AdminAttribute , model . SAML_SETTINGS_DEFAULT_ADMIN_ATTRIBUTE ) ,
2018-01-10 21:50:22 -05:00
"isdefault_first_name_attribute" : isDefault ( * cfg . SamlSettings . FirstNameAttribute , model . SAML_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE ) ,
"isdefault_last_name_attribute" : isDefault ( * cfg . SamlSettings . LastNameAttribute , model . SAML_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE ) ,
"isdefault_email_attribute" : isDefault ( * cfg . SamlSettings . EmailAttribute , model . SAML_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE ) ,
"isdefault_username_attribute" : isDefault ( * cfg . SamlSettings . UsernameAttribute , model . SAML_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE ) ,
"isdefault_nickname_attribute" : isDefault ( * cfg . SamlSettings . NicknameAttribute , model . SAML_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE ) ,
"isdefault_locale_attribute" : isDefault ( * cfg . SamlSettings . LocaleAttribute , model . SAML_SETTINGS_DEFAULT_LOCALE_ATTRIBUTE ) ,
"isdefault_position_attribute" : isDefault ( * cfg . SamlSettings . PositionAttribute , model . SAML_SETTINGS_DEFAULT_POSITION_ATTRIBUTE ) ,
"isdefault_login_button_text" : isDefault ( * cfg . SamlSettings . LoginButtonText , model . USER_AUTH_SERVICE_SAML_TEXT ) ,
"isdefault_login_button_color" : isDefault ( * cfg . SamlSettings . LoginButtonColor , "" ) ,
"isdefault_login_button_border_color" : isDefault ( * cfg . SamlSettings . LoginButtonBorderColor , "" ) ,
"isdefault_login_button_text_color" : isDefault ( * cfg . SamlSettings . LoginButtonTextColor , "" ) ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_CLUSTER , map [ string ] interface { } {
2020-07-30 22:18:54 +05:30
"enable" : * cfg . ClusterSettings . Enable ,
"network_interface" : isDefault ( * cfg . ClusterSettings . NetworkInterface , "" ) ,
"bind_address" : isDefault ( * cfg . ClusterSettings . BindAddress , "" ) ,
"advertise_address" : isDefault ( * cfg . ClusterSettings . AdvertiseAddress , "" ) ,
"use_ip_address" : * cfg . ClusterSettings . UseIpAddress ,
"use_experimental_gossip" : * cfg . ClusterSettings . UseExperimentalGossip ,
"enable_experimental_gossip_encryption" : * cfg . ClusterSettings . EnableExperimentalGossipEncryption ,
"read_only_config" : * cfg . ClusterSettings . ReadOnlyConfig ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_METRICS , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable" : * cfg . MetricsSettings . Enable ,
"block_profile_rate" : * cfg . MetricsSettings . BlockProfileRate ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_NATIVEAPP , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"isdefault_app_download_link" : isDefault ( * cfg . NativeAppSettings . AppDownloadLink , model . NATIVEAPP_SETTINGS_DEFAULT_APP_DOWNLOAD_LINK ) ,
"isdefault_android_app_download_link" : isDefault ( * cfg . NativeAppSettings . AndroidAppDownloadLink , model . NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK ) ,
"isdefault_iosapp_download_link" : isDefault ( * cfg . NativeAppSettings . IosAppDownloadLink , model . NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK ) ,
2017-02-24 17:33:59 +00:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_EXPERIMENTAL , map [ string ] interface { } {
2019-01-31 09:40:23 -05:00
"client_side_cert_enable" : * cfg . ExperimentalSettings . ClientSideCertEnable ,
"isdefault_client_side_cert_check" : isDefault ( * cfg . ExperimentalSettings . ClientSideCertCheck , model . CLIENT_SIDE_CERT_CHECK_PRIMARY_AUTH ) ,
"link_metadata_timeout_milliseconds" : * cfg . ExperimentalSettings . LinkMetadataTimeoutMilliseconds ,
2019-04-01 14:23:49 -04:00
"enable_click_to_reply" : * cfg . ExperimentalSettings . EnableClickToReply ,
"restrict_system_admin" : * cfg . ExperimentalSettings . RestrictSystemAdmin ,
2020-01-13 10:54:30 -07:00
"use_new_saml_library" : * cfg . ExperimentalSettings . UseNewSAMLLibrary ,
2018-06-26 13:47:07 -04:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_ANALYTICS , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"isdefault_max_users_for_statistics" : isDefault ( * cfg . AnalyticsSettings . MaxUsersForStatistics , model . ANALYTICS_SETTINGS_DEFAULT_MAX_USERS_FOR_STATISTICS ) ,
2017-02-24 17:33:59 +00:00
} )
2017-07-01 02:34:57 +01:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_ANNOUNCEMENT , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_banner" : * cfg . AnnouncementSettings . EnableBanner ,
"isdefault_banner_color" : isDefault ( * cfg . AnnouncementSettings . BannerColor , model . ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR ) ,
"isdefault_banner_text_color" : isDefault ( * cfg . AnnouncementSettings . BannerTextColor , model . ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR ) ,
"allow_banner_dismissal" : * cfg . AnnouncementSettings . AllowBannerDismissal ,
2017-07-01 02:34:57 +01:00
} )
2017-07-31 16:53:44 +01:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_ELASTICSEARCH , map [ string ] interface { } {
2017-11-03 12:57:13 -04:00
"isdefault_connection_url" : isDefault ( * cfg . ElasticsearchSettings . ConnectionUrl , model . ELASTICSEARCH_SETTINGS_DEFAULT_CONNECTION_URL ) ,
"isdefault_username" : isDefault ( * cfg . ElasticsearchSettings . Username , model . ELASTICSEARCH_SETTINGS_DEFAULT_USERNAME ) ,
"isdefault_password" : isDefault ( * cfg . ElasticsearchSettings . Password , model . ELASTICSEARCH_SETTINGS_DEFAULT_PASSWORD ) ,
"enable_indexing" : * cfg . ElasticsearchSettings . EnableIndexing ,
"enable_searching" : * cfg . ElasticsearchSettings . EnableSearching ,
2019-03-15 17:53:53 +00:00
"enable_autocomplete" : * cfg . ElasticsearchSettings . EnableAutocomplete ,
2017-11-03 12:57:13 -04:00
"sniff" : * cfg . ElasticsearchSettings . Sniff ,
"post_index_replicas" : * cfg . ElasticsearchSettings . PostIndexReplicas ,
"post_index_shards" : * cfg . ElasticsearchSettings . PostIndexShards ,
2019-03-15 17:53:53 +00:00
"channel_index_replicas" : * cfg . ElasticsearchSettings . ChannelIndexReplicas ,
"channel_index_shards" : * cfg . ElasticsearchSettings . ChannelIndexShards ,
"user_index_replicas" : * cfg . ElasticsearchSettings . UserIndexReplicas ,
"user_index_shards" : * cfg . ElasticsearchSettings . UserIndexShards ,
2017-11-03 12:57:13 -04:00
"isdefault_index_prefix" : isDefault ( * cfg . ElasticsearchSettings . IndexPrefix , model . ELASTICSEARCH_SETTINGS_DEFAULT_INDEX_PREFIX ) ,
"live_indexing_batch_size" : * cfg . ElasticsearchSettings . LiveIndexingBatchSize ,
"bulk_indexing_time_window_seconds" : * cfg . ElasticsearchSettings . BulkIndexingTimeWindowSeconds ,
"request_timeout_seconds" : * cfg . ElasticsearchSettings . RequestTimeoutSeconds ,
2019-06-23 12:03:55 +01:00
"skip_tls_verification" : * cfg . ElasticsearchSettings . SkipTLSVerification ,
2019-05-30 16:48:19 +01:00
"trace" : * cfg . ElasticsearchSettings . Trace ,
2017-07-31 16:53:44 +01:00
} )
2017-08-02 01:36:54 -07:00
2020-07-28 04:26:44 +02:00
s . trackPluginConfig ( cfg , model . PLUGIN_SETTINGS_DEFAULT_MARKETPLACE_URL )
2017-09-29 10:54:59 +01:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_DATA_RETENTION , map [ string ] interface { } {
2017-10-23 02:39:51 -07:00
"enable_message_deletion" : * cfg . DataRetentionSettings . EnableMessageDeletion ,
"enable_file_deletion" : * cfg . DataRetentionSettings . EnableFileDeletion ,
"message_retention_days" : * cfg . DataRetentionSettings . MessageRetentionDays ,
"file_retention_days" : * cfg . DataRetentionSettings . FileRetentionDays ,
"deletion_job_start_time" : * cfg . DataRetentionSettings . DeletionJobStartTime ,
2017-09-29 10:54:59 +01:00
} )
2017-11-30 09:07:04 -05:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_MESSAGE_EXPORT , map [ string ] interface { } {
2018-03-12 17:52:17 +00:00
"enable_message_export" : * cfg . MessageExportSettings . EnableExport ,
"export_format" : * cfg . MessageExportSettings . ExportFormat ,
"daily_run_time" : * cfg . MessageExportSettings . DailyRunTime ,
"default_export_from_timestamp" : * cfg . MessageExportSettings . ExportFromTimestamp ,
"batch_size" : * cfg . MessageExportSettings . BatchSize ,
"global_relay_customer_type" : * cfg . MessageExportSettings . GlobalRelaySettings . CustomerType ,
"is_default_global_relay_smtp_username" : isDefault ( * cfg . MessageExportSettings . GlobalRelaySettings . SmtpUsername , "" ) ,
"is_default_global_relay_smtp_password" : isDefault ( * cfg . MessageExportSettings . GlobalRelaySettings . SmtpPassword , "" ) ,
"is_default_global_relay_email_address" : isDefault ( * cfg . MessageExportSettings . GlobalRelaySettings . EmailAddress , "" ) ,
2020-07-16 11:21:55 +03:00
"global_relay_smtp_server_timeout" : * cfg . EmailSettings . SMTPServerTimeout ,
2017-11-30 09:07:04 -05:00
} )
2018-04-04 08:14:23 -04:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_DISPLAY , map [ string ] interface { } {
2018-06-07 15:52:07 +02:00
"experimental_timezone" : * cfg . DisplaySettings . ExperimentalTimezone ,
2018-12-06 07:56:06 -08:00
"isdefault_custom_url_schemes" : len ( cfg . DisplaySettings . CustomUrlSchemes ) != 0 ,
2018-04-04 08:14:23 -04:00
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_GUEST_ACCOUNTS , map [ string ] interface { } {
2019-10-11 07:27:55 -04:00
"enable" : * cfg . GuestAccountsSettings . Enable ,
"allow_email_accounts" : * cfg . GuestAccountsSettings . AllowEmailAccounts ,
"enforce_multifactor_authentication" : * cfg . GuestAccountsSettings . EnforceMultifactorAuthentication ,
"isdefault_restrict_creation_to_domains" : isDefault ( * cfg . GuestAccountsSettings . RestrictCreationToDomains , "" ) ,
} )
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_IMAGE_PROXY , map [ string ] interface { } {
2019-01-24 16:11:32 -04:00
"enable" : * cfg . ImageProxySettings . Enable ,
"image_proxy_type" : * cfg . ImageProxySettings . ImageProxyType ,
"isdefault_remote_image_proxy_url" : isDefault ( * cfg . ImageProxySettings . RemoteImageProxyURL , "" ) ,
"isdefault_remote_image_proxy_options" : isDefault ( * cfg . ImageProxySettings . RemoteImageProxyOptions , "" ) ,
} )
2020-06-09 09:04:52 +01:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CONFIG_BLEVE , map [ string ] interface { } {
2020-06-09 09:04:52 +01:00
"enable_indexing" : * cfg . BleveSettings . EnableIndexing ,
"enable_searching" : * cfg . BleveSettings . EnableSearching ,
"enable_autocomplete" : * cfg . BleveSettings . EnableAutocomplete ,
"bulk_indexing_time_window_seconds" : * cfg . BleveSettings . BulkIndexingTimeWindowSeconds ,
} )
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackLicense ( ) {
if license := s . License ( ) ; license != nil {
2017-02-24 17:33:59 +00:00
data := map [ string ] interface { } {
2018-02-06 17:25:49 -06:00
"customer_id" : license . Customer . Id ,
"license_id" : license . Id ,
"issued" : license . IssuedAt ,
"start" : license . StartsAt ,
"expire" : license . ExpiresAt ,
"users" : * license . Features . Users ,
2018-11-28 09:49:43 -05:00
"edition" : license . SkuShortName ,
2017-02-24 17:33:59 +00:00
}
2018-02-06 17:25:49 -06:00
features := license . Features . ToMap ( )
2017-02-24 17:33:59 +00:00
for featureName , featureValue := range features {
data [ "feature_" + featureName ] = featureValue
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_LICENSE , data )
2017-02-24 17:33:59 +00:00
}
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackPlugins ( ) {
pluginsEnvironment := s . GetPluginsEnvironment ( )
2018-11-20 08:52:51 -05:00
if pluginsEnvironment == nil {
return
}
totalEnabledCount := 0
webappEnabledCount := 0
backendEnabledCount := 0
totalDisabledCount := 0
webappDisabledCount := 0
backendDisabledCount := 0
brokenManifestCount := 0
settingsCount := 0
2020-06-12 13:43:50 +02:00
pluginStates := s . Config ( ) . PluginSettings . PluginStates
2018-11-20 08:52:51 -05:00
plugins , _ := pluginsEnvironment . Available ( )
if pluginStates != nil && plugins != nil {
for _ , plugin := range plugins {
if plugin . Manifest == nil {
brokenManifestCount += 1
continue
}
2020-01-16 08:46:36 -05:00
2018-11-20 08:52:51 -05:00
if state , ok := pluginStates [ plugin . Manifest . Id ] ; ok && state . Enable {
totalEnabledCount += 1
if plugin . Manifest . HasServer ( ) {
backendEnabledCount += 1
2017-11-08 11:39:30 -05:00
}
2018-11-20 08:52:51 -05:00
if plugin . Manifest . HasWebapp ( ) {
webappEnabledCount += 1
2017-10-30 14:10:48 -04:00
}
2018-11-20 08:52:51 -05:00
} else {
totalDisabledCount += 1
if plugin . Manifest . HasServer ( ) {
backendDisabledCount += 1
2017-11-08 11:39:30 -05:00
}
2018-11-20 08:52:51 -05:00
if plugin . Manifest . HasWebapp ( ) {
webappDisabledCount += 1
}
}
if plugin . Manifest . SettingsSchema != nil {
settingsCount += 1
2017-10-30 14:10:48 -04:00
}
}
2018-11-20 08:52:51 -05:00
} else {
totalEnabledCount = - 1 // -1 to indicate disabled or error
totalDisabledCount = - 1 // -1 to indicate disabled or error
2017-10-30 14:10:48 -04:00
}
2018-11-20 08:52:51 -05:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_PLUGINS , map [ string ] interface { } {
2018-11-20 08:52:51 -05:00
"enabled_plugins" : totalEnabledCount ,
"enabled_webapp_plugins" : webappEnabledCount ,
"enabled_backend_plugins" : backendEnabledCount ,
"disabled_plugins" : totalDisabledCount ,
"disabled_webapp_plugins" : webappDisabledCount ,
"disabled_backend_plugins" : backendDisabledCount ,
"plugins_with_settings" : settingsCount ,
"plugins_with_broken_manifests" : brokenManifestCount ,
} )
2017-10-30 14:10:48 -04:00
}
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackServer ( ) {
2017-02-24 17:33:59 +00:00
data := map [ string ] interface { } {
"edition" : model . BuildEnterpriseReady ,
"version" : model . CurrentVersion ,
2020-06-12 13:43:50 +02:00
"database_type" : * s . Config ( ) . SqlSettings . DriverName ,
2017-02-24 17:33:59 +00:00
"operating_system" : runtime . GOOS ,
}
2020-06-12 13:43:50 +02:00
if scr , err := s . Store . User ( ) . AnalyticsGetSystemAdminCount ( ) ; err == nil {
2019-07-02 14:51:38 +05:30
data [ "system_admins" ] = scr
2017-02-24 17:33:59 +00:00
}
2020-06-12 13:43:50 +02:00
if scr , err := s . Store . GetDbVersion ( ) ; err == nil {
2020-04-09 11:08:15 +02:00
data [ "database_version" ] = scr
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_SERVER , data )
2017-02-24 17:33:59 +00:00
}
2018-08-23 11:48:57 +01:00
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackPermissions ( ) {
2018-08-23 11:48:57 +01:00
phase1Complete := false
2020-06-12 13:43:50 +02:00
if _ , err := s . Store . System ( ) . GetByName ( ADVANCED_PERMISSIONS_MIGRATION_KEY ) ; err == nil {
2018-08-23 11:48:57 +01:00
phase1Complete = true
}
phase2Complete := false
2020-06-12 13:43:50 +02:00
if _ , err := s . Store . System ( ) . GetByName ( model . MIGRATION_KEY_ADVANCED_PERMISSIONS_PHASE_2 ) ; err == nil {
2018-08-23 11:48:57 +01:00
phase2Complete = true
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_PERMISSIONS_GENERAL , map [ string ] interface { } {
2018-08-23 11:48:57 +01:00
"phase_1_migration_complete" : phase1Complete ,
"phase_2_migration_complete" : phase2Complete ,
} )
systemAdminPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . SYSTEM_ADMIN_ROLE_ID ) ; err == nil {
2018-08-23 11:48:57 +01:00
systemAdminPermissions = strings . Join ( role . Permissions , " " )
}
systemUserPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . SYSTEM_USER_ROLE_ID ) ; err == nil {
2018-08-23 11:48:57 +01:00
systemUserPermissions = strings . Join ( role . Permissions , " " )
}
teamAdminPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . TEAM_ADMIN_ROLE_ID ) ; err == nil {
2018-08-23 11:48:57 +01:00
teamAdminPermissions = strings . Join ( role . Permissions , " " )
}
teamUserPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . TEAM_USER_ROLE_ID ) ; err == nil {
2018-08-23 11:48:57 +01:00
teamUserPermissions = strings . Join ( role . Permissions , " " )
}
2019-04-30 20:36:21 +02:00
teamGuestPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . TEAM_GUEST_ROLE_ID ) ; err == nil {
2019-04-30 20:36:21 +02:00
teamGuestPermissions = strings . Join ( role . Permissions , " " )
}
2018-08-23 11:48:57 +01:00
channelAdminPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . CHANNEL_ADMIN_ROLE_ID ) ; err == nil {
2018-08-23 11:48:57 +01:00
channelAdminPermissions = strings . Join ( role . Permissions , " " )
}
channelUserPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . CHANNEL_USER_ROLE_ID ) ; err == nil {
2019-04-30 20:36:21 +02:00
channelUserPermissions = strings . Join ( role . Permissions , " " )
}
channelGuestPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( model . CHANNEL_GUEST_ROLE_ID ) ; err == nil {
2019-04-30 20:36:21 +02:00
channelGuestPermissions = strings . Join ( role . Permissions , " " )
2018-08-23 11:48:57 +01:00
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_PERMISSIONS_SYSTEM_SCHEME , map [ string ] interface { } {
2018-08-23 11:48:57 +01:00
"system_admin_permissions" : systemAdminPermissions ,
"system_user_permissions" : systemUserPermissions ,
"team_admin_permissions" : teamAdminPermissions ,
"team_user_permissions" : teamUserPermissions ,
2019-04-30 20:36:21 +02:00
"team_guest_permissions" : teamGuestPermissions ,
2018-08-23 11:48:57 +01:00
"channel_admin_permissions" : channelAdminPermissions ,
"channel_user_permissions" : channelUserPermissions ,
2019-04-30 20:36:21 +02:00
"channel_guest_permissions" : channelGuestPermissions ,
2018-08-23 11:48:57 +01:00
} )
2020-06-12 13:43:50 +02:00
if schemes , err := s . GetSchemes ( model . SCHEME_SCOPE_TEAM , 0 , 100 ) ; err == nil {
2018-08-23 11:48:57 +01:00
for _ , scheme := range schemes {
teamAdminPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( scheme . DefaultTeamAdminRole ) ; err == nil {
2018-08-23 11:48:57 +01:00
teamAdminPermissions = strings . Join ( role . Permissions , " " )
}
teamUserPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( scheme . DefaultTeamUserRole ) ; err == nil {
2018-08-23 11:48:57 +01:00
teamUserPermissions = strings . Join ( role . Permissions , " " )
}
2019-04-30 20:36:21 +02:00
teamGuestPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( scheme . DefaultTeamGuestRole ) ; err == nil {
2019-04-30 20:36:21 +02:00
teamGuestPermissions = strings . Join ( role . Permissions , " " )
}
2018-08-23 11:48:57 +01:00
channelAdminPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( scheme . DefaultChannelAdminRole ) ; err == nil {
2018-08-23 11:48:57 +01:00
channelAdminPermissions = strings . Join ( role . Permissions , " " )
}
channelUserPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( scheme . DefaultChannelUserRole ) ; err == nil {
2019-04-30 20:36:21 +02:00
channelUserPermissions = strings . Join ( role . Permissions , " " )
}
channelGuestPermissions := ""
2020-06-12 13:43:50 +02:00
if role , err := s . GetRoleByName ( scheme . DefaultChannelGuestRole ) ; err == nil {
2019-04-30 20:36:21 +02:00
channelGuestPermissions = strings . Join ( role . Permissions , " " )
2018-08-23 11:48:57 +01:00
}
2020-06-12 13:43:50 +02:00
count , _ := s . Store . Team ( ) . AnalyticsGetTeamCountForScheme ( scheme . Id )
2018-08-23 11:48:57 +01:00
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_PERMISSIONS_TEAM_SCHEMES , map [ string ] interface { } {
2018-08-23 11:48:57 +01:00
"scheme_id" : scheme . Id ,
"team_admin_permissions" : teamAdminPermissions ,
"team_user_permissions" : teamUserPermissions ,
2019-04-30 20:36:21 +02:00
"team_guest_permissions" : teamGuestPermissions ,
2018-08-23 11:48:57 +01:00
"channel_admin_permissions" : channelAdminPermissions ,
"channel_user_permissions" : channelUserPermissions ,
2019-04-30 20:36:21 +02:00
"channel_guest_permissions" : channelGuestPermissions ,
2018-08-23 11:48:57 +01:00
"team_count" : count ,
} )
}
}
}
2019-11-21 13:04:21 +01:00
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackElasticsearch ( ) {
2019-11-21 13:04:21 +01:00
data := map [ string ] interface { } { }
2020-06-12 13:43:50 +02:00
for _ , engine := range s . SearchEngine . GetActiveEngines ( ) {
2020-03-13 15:33:18 +01:00
if engine . GetVersion ( ) != 0 && engine . GetName ( ) == "elasticsearch" {
data [ "elasticsearch_server_version" ] = engine . GetVersion ( )
}
2019-11-21 13:04:21 +01:00
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_ELASTICSEARCH , data )
2019-11-21 13:04:21 +01:00
}
2020-02-06 09:25:36 -05:00
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackGroups ( ) {
groupCount , err := s . Store . Group ( ) . GroupCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
groupTeamCount , err := s . Store . Group ( ) . GroupTeamCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
groupChannelCount , err := s . Store . Group ( ) . GroupChannelCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
groupSyncedTeamCount , err := s . Store . Team ( ) . GroupSyncedTeamCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
groupSyncedChannelCount , err := s . Store . Channel ( ) . GroupSyncedChannelCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
groupMemberCount , err := s . Store . Group ( ) . GroupMemberCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
distinctGroupMemberCount , err := s . Store . Group ( ) . DistinctGroupMemberCount ( )
2020-02-06 09:25:36 -05:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
groupCountWithAllowReference , err := s . Store . Group ( ) . GroupCountWithAllowReference ( )
2020-05-22 10:56:15 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_GROUPS , map [ string ] interface { } {
2020-05-22 10:56:15 -04:00
"group_count" : groupCount ,
"group_team_count" : groupTeamCount ,
"group_channel_count" : groupChannelCount ,
"group_synced_team_count" : groupSyncedTeamCount ,
"group_synced_channel_count" : groupSyncedChannelCount ,
"group_member_count" : groupMemberCount ,
"distinct_group_member_count" : distinctGroupMemberCount ,
"group_count_with_allow_reference" : groupCountWithAllowReference ,
2020-02-06 09:25:36 -05:00
} )
}
2020-03-17 11:09:37 -04:00
2020-06-12 13:43:50 +02:00
func ( s * Server ) trackChannelModeration ( ) {
channelSchemeCount , err := s . Store . Scheme ( ) . CountByScope ( model . SCHEME_SCOPE_CHANNEL )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
createPostUser , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_CREATE_POST . Id , model . RoleScopeChannel , model . RoleTypeUser )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
createPostGuest , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_CREATE_POST . Id , model . RoleScopeChannel , model . RoleTypeGuest )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
// only need to track one of 'add_reaction' or 'remove_reaction` because they're both toggled together by the channel moderation feature
2020-06-12 13:43:50 +02:00
postReactionsUser , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_ADD_REACTION . Id , model . RoleScopeChannel , model . RoleTypeUser )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
postReactionsGuest , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_ADD_REACTION . Id , model . RoleScopeChannel , model . RoleTypeGuest )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
// only need to track one of 'manage_public_channel_members' or 'manage_private_channel_members` because they're both toggled together by the channel moderation feature
2020-06-12 13:43:50 +02:00
manageMembersUser , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS . Id , model . RoleScopeChannel , model . RoleTypeUser )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
useChannelMentionsUser , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_USE_CHANNEL_MENTIONS . Id , model . RoleScopeChannel , model . RoleTypeUser )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
useChannelMentionsGuest , err := s . Store . Scheme ( ) . CountWithoutPermission ( model . SCHEME_SCOPE_CHANNEL , model . PERMISSION_USE_CHANNEL_MENTIONS . Id , model . RoleScopeChannel , model . RoleTypeGuest )
2020-03-17 11:09:37 -04:00
if err != nil {
mlog . Error ( err . Error ( ) )
}
2020-06-12 13:43:50 +02:00
s . SendDiagnostic ( TRACK_CHANNEL_MODERATION , map [ string ] interface { } {
2020-03-17 11:09:37 -04:00
"channel_scheme_count" : channelSchemeCount ,
"create_post_user_disabled_count" : createPostUser ,
"create_post_guest_disabled_count" : createPostGuest ,
"post_reactions_user_disabled_count" : postReactionsUser ,
"post_reactions_guest_disabled_count" : postReactionsGuest ,
"manage_members_user_disabled_count" : manageMembersUser , // the UI does not allow this to be removed for guests
"use_channel_mentions_user_disabled_count" : useChannelMentionsUser ,
"use_channel_mentions_guest_disabled_count" : useChannelMentionsGuest ,
} )
}
2020-07-22 20:32:21 -07:00
func ( s * Server ) trackWarnMetrics ( ) {
systemDataList , appErr := s . Store . System ( ) . Get ( )
if appErr != nil {
return
}
for key , value := range systemDataList {
if strings . HasPrefix ( key , model . WARN_METRIC_STATUS_STORE_PREFIX ) {
if _ , ok := model . WarnMetricsTable [ key ] ; ok {
s . SendDiagnostic ( TRACK_WARN_METRICS , map [ string ] interface { } {
key : value != "false" ,
} )
}
}
}
}
2020-07-28 04:26:44 +02:00
func ( s * Server ) trackPluginConfig ( cfg * model . Config , marketplaceURL string ) {
pluginConfigData := map [ string ] interface { } {
"enable_nps_survey" : pluginSetting ( & cfg . PluginSettings , "com.mattermost.nps" , "enablesurvey" , true ) ,
"enable" : * cfg . PluginSettings . Enable ,
"enable_uploads" : * cfg . PluginSettings . EnableUploads ,
"allow_insecure_download_url" : * cfg . PluginSettings . AllowInsecureDownloadUrl ,
"enable_health_check" : * cfg . PluginSettings . EnableHealthCheck ,
"enable_marketplace" : * cfg . PluginSettings . EnableMarketplace ,
"require_pluginSignature" : * cfg . PluginSettings . RequirePluginSignature ,
"enable_remote_marketplace" : * cfg . PluginSettings . EnableRemoteMarketplace ,
"automatic_prepackaged_plugins" : * cfg . PluginSettings . AutomaticPrepackagedPlugins ,
"is_default_marketplace_url" : isDefault ( * cfg . PluginSettings . MarketplaceUrl , model . PLUGIN_SETTINGS_DEFAULT_MARKETPLACE_URL ) ,
"signature_public_key_files" : len ( cfg . PluginSettings . SignaturePublicKeyFiles ) ,
}
// knownPluginIDs lists all known plugin IDs in the Marketplace
knownPluginIDs := [ ] string {
"antivirus" ,
"com.github.manland.mattermost-plugin-gitlab" ,
"com.github.moussetc.mattermost.plugin.giphy" ,
"com.github.phillipahereza.mattermost-plugin-digitalocean" ,
"com.mattermost.aws-sns" ,
"com.mattermost.confluence" ,
"com.mattermost.custom-attributes" ,
"com.mattermost.mscalendar" ,
"com.mattermost.nps" ,
"com.mattermost.plugin-incident-response" ,
"com.mattermost.plugin-todo" ,
"com.mattermost.webex" ,
"com.mattermost.welcomebot" ,
"github" ,
"jenkins" ,
"jira" ,
"jitsi" ,
"mattermost-autolink" ,
"memes" ,
"skype4business" ,
"zoom" ,
}
marketplacePlugins , err := s . getAllMarketplaceplugins ( marketplaceURL )
if err != nil {
mlog . Info ( "Failed to fetch marketplace plugins for telemetry. Using predefined list." , mlog . Err ( err ) )
for _ , id := range knownPluginIDs {
pluginConfigData [ "enable_" + id ] = pluginActivated ( cfg . PluginSettings . PluginStates , id )
}
} else {
for _ , p := range marketplacePlugins {
id := p . Manifest . Id
pluginConfigData [ "enable_" + id ] = pluginActivated ( cfg . PluginSettings . PluginStates , id )
}
}
pluginsEnvironment := s . GetPluginsEnvironment ( )
if pluginsEnvironment != nil {
if plugins , appErr := pluginsEnvironment . Available ( ) ; appErr != nil {
mlog . Error ( "Unable to add plugin versions to diagnostics" , mlog . Err ( appErr ) )
} else {
// If marketplace request failed, use predefined list
if marketplacePlugins == nil {
for _ , id := range knownPluginIDs {
pluginConfigData [ "version_" + id ] = pluginActivated ( cfg . PluginSettings . PluginStates , id )
}
} else {
for _ , p := range marketplacePlugins {
id := p . Manifest . Id
pluginConfigData [ "version_" + id ] = pluginVersion ( plugins , id )
}
}
}
}
s . SendDiagnostic ( TRACK_CONFIG_PLUGIN , pluginConfigData )
}
func ( s * Server ) getAllMarketplaceplugins ( marketplaceURL string ) ( [ ] * model . BaseMarketplacePlugin , error ) {
marketplaceClient , err := marketplace . NewClient (
marketplaceURL ,
s . HTTPService ,
)
if err != nil {
return nil , err
}
// Fetch all plugins from marketplace.
filter := & model . MarketplacePluginFilter {
PerPage : - 1 ,
ServerVersion : model . CurrentVersion ,
}
license := s . License ( )
if license != nil && * license . Features . EnterprisePlugins {
filter . EnterprisePlugins = true
}
if model . BuildEnterpriseReady == "true" {
filter . BuildEnterpriseReady = true
}
return marketplaceClient . GetPlugins ( filter )
}