telemetry: add product hooks to daily telemetry (#21870)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f31380f577
Коммит
e10460675e
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/product"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v6/services/imageproxy"
|
||||
"github.com/mattermost/mattermost-server/v6/services/remotecluster"
|
||||
@@ -868,6 +869,7 @@ type AppIface interface {
|
||||
HasPermissionToTeam(askingUserId string, teamID string, permission *model.Permission) bool
|
||||
HasPermissionToUser(askingUserId string, userID string) bool
|
||||
HasSharedChannel(channelID string) (bool, error)
|
||||
HooksManager() *product.HooksManager
|
||||
ImageProxy() *imageproxy.ImageProxy
|
||||
ImageProxyAdder() func(string) string
|
||||
ImageProxyRemover() (f func(string) string)
|
||||
|
||||
@@ -317,6 +317,10 @@ func (ch *Channels) RequestTrialLicense(requesterID string, users int, termsAcce
|
||||
receiveEmailsAccepted)
|
||||
}
|
||||
|
||||
func (a *App) HooksManager() *product.HooksManager {
|
||||
return a.Srv().hooksManager
|
||||
}
|
||||
|
||||
// Ensure hooksService implements `product.HooksService`
|
||||
var _ product.HooksService = (*hooksService)(nil)
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/product"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v6/services/imageproxy"
|
||||
"github.com/mattermost/mattermost-server/v6/services/remotecluster"
|
||||
@@ -11559,6 +11560,23 @@ func (a *OpenTracingAppLayer) HasSharedChannel(channelID string) (bool, error) {
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) HooksManager() *product.HooksManager {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.HooksManager")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store().SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store().SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.HooksManager()
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) HubRegister(webConn *platform.WebConn) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.HubRegister")
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
model "github.com/mattermost/mattermost-server/v6/model"
|
||||
|
||||
plugin "github.com/mattermost/mattermost-server/v6/plugin"
|
||||
|
||||
product "github.com/mattermost/mattermost-server/v6/product"
|
||||
)
|
||||
|
||||
// ServerIface is an autogenerated mock type for the ServerIface type
|
||||
@@ -118,6 +120,22 @@ func (_m *ServerIface) HTTPService() httpservice.HTTPService {
|
||||
return r0
|
||||
}
|
||||
|
||||
// HooksManager provides a mock function with given fields:
|
||||
func (_m *ServerIface) HooksManager() *product.HooksManager {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 *product.HooksManager
|
||||
if rf, ok := ret.Get(0).(func() *product.HooksManager); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*product.HooksManager)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// IsLeader provides a mock function with given fields:
|
||||
func (_m *ServerIface) IsLeader() bool {
|
||||
ret := _m.Called()
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/product"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v6/services/marketplace"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine"
|
||||
@@ -91,6 +92,7 @@ type ServerIface interface {
|
||||
License() *model.License
|
||||
GetRoleByName(context.Context, string) (*model.Role, *model.AppError)
|
||||
GetSchemes(string, int, int) ([]*model.Scheme, *model.AppError)
|
||||
HooksManager() *product.HooksManager
|
||||
}
|
||||
|
||||
type TelemetryService struct {
|
||||
@@ -165,6 +167,7 @@ func (ts *TelemetryService) sendDailyTelemetry(override bool) {
|
||||
ts.trackGroups()
|
||||
ts.trackChannelModeration()
|
||||
ts.trackWarnMetrics()
|
||||
ts.trackProducts()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,6 +947,18 @@ func (ts *TelemetryService) trackPlugins() {
|
||||
}, plugin.OnSendDailyTelemetryID)
|
||||
}
|
||||
|
||||
func (ts *TelemetryService) trackProducts() {
|
||||
hm := ts.srv.HooksManager()
|
||||
if hm == nil {
|
||||
return
|
||||
}
|
||||
|
||||
hm.RunMultiHook(func(hooks plugin.Hooks) bool {
|
||||
hooks.OnSendDailyTelemetry()
|
||||
return true
|
||||
}, plugin.OnSendDailyTelemetryID)
|
||||
}
|
||||
|
||||
func (ts *TelemetryService) trackServer() {
|
||||
data := map[string]any{
|
||||
"edition": model.BuildEnterpriseReady,
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin/plugintest"
|
||||
"github.com/mattermost/mattermost-server/v6/product"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine"
|
||||
"github.com/mattermost/mattermost-server/v6/services/telemetry/mocks"
|
||||
@@ -189,6 +190,7 @@ func initializeMocks(cfg *model.Config, cloudLicense bool) (*mocks.ServerIface,
|
||||
serverIfaceMock.On("GetRoleByName", context.Background(), "channel_guest").Return(&model.Role{Permissions: []string{"cg-test1", "cg-test2"}}, nil)
|
||||
serverIfaceMock.On("GetSchemes", "team", 0, 100).Return([]*model.Scheme{}, nil)
|
||||
serverIfaceMock.On("HTTPService").Return(httpservice.MakeHTTPService(configService))
|
||||
serverIfaceMock.On("HooksManager").Return(product.NewHooksManager(nil))
|
||||
|
||||
storeMock := &storeMocks.Store{}
|
||||
storeMock.On("GetDbVersion", false).Return("5.24.0", nil)
|
||||
|
||||
Ссылка в новой задаче
Block a user