mattermost/server/platform/services/telemetry/telemetry.go
Jesse Hallam 8cace74692
MM-64486: Remove telemetry (#33606)
* MM-64486: Remove telemetry

Remove telemetry from Mattermost. We're no longer relying on Rudder upstream, and no longer making use of this information.

* recover mock for SystemStore.Get

* Fix TestClearPushNotificationSync by adding missing SystemStore mock

The test was failing because the SystemStore mock was missing the Get()
method that's required by the ServerId() function. Added the missing mock
to return a StringMap with SystemServerId.

* fix mocking issue

* Remove now-unused telemetry and constants

* Remove "Disable telemetry events" debug setting

* Remove empty functions

* Remove most "Telemetry tracking removed" comments

* Remove remains of DataPrefetch telemetry

* Remove now-unused prop from InviteMembersButton

* Remove trackDotMenuEvent

* Remove some more leftover comments

* Remove lingering logic related to trackingLocation

* Remove now-unused argument from useCopyText

* Remove lingering telemetry references from PreparingWorkspace

* fixup Remove trackDotMenuEvent

* Remove lingering telemetry references from signup page and password check

* Update snapshots and fix test broken by my changes

* Fix unintended behavior change in thread list filtering

Remove handleSetFilter wrapper that was accidentally modified during
telemetry removal. The function was calling clear() when switching to
unread filter, which was not the original behavior. Use setFilter
directly instead, restoring the original functionality.

* Remove unused useOpenDowngradeModal hook

The useOpenDowngradeModal hook was not being used anywhere in the codebase.

* Remove unused expandableLink from useExpandOverageUsersCheck

The expandableLink return value was not being used by any components.

* Re-add missing TeamLinkClicked performance telemetry

The mark(Mark.TeamLinkClicked) call was accidentally removed from the
handleSwitch function. This telemetry is needed for Looker-based
performance tracking.

* drop LogSettings.VerboseDiagnostics

---------

Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-04 18:46:18 +00:00

70 lines
1.5 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package telemetry
import (
"fmt"
"time"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
"github.com/mattermost/mattermost/server/v8/channels/store"
)
const (
DBAccessAttempts = 3
DBAccessTimeoutSecs = 10
)
type ServerIface interface {
Config() *model.Config
IsLeader() bool
}
type TelemetryService struct {
srv ServerIface
dbStore store.Store
log *mlog.Logger
ServerID string
}
func New(srv ServerIface, dbStore store.Store, log *mlog.Logger) (*TelemetryService, error) {
service := &TelemetryService{
srv: srv,
dbStore: dbStore,
log: log,
}
if err := service.ensureServerID(); err != nil {
return nil, fmt.Errorf("unable to ensure telemetry ID: %w", err)
}
return service, nil
}
func (ts *TelemetryService) ensureServerID() error {
if ts.ServerID != "" {
return nil
}
id := model.NewId()
var err error
for range DBAccessAttempts {
ts.log.Info("Ensuring the telemetry ID..")
systemID := &model.System{Name: model.SystemServerId, Value: id}
systemID, err = ts.dbStore.System().InsertIfExists(systemID)
if err != nil {
ts.log.Info("Unable to get/set the telemetry ID", mlog.Err(err))
time.Sleep(DBAccessTimeoutSecs * time.Second)
continue
}
ts.ServerID = systemID.Value
ts.log.Info("server ID is set", mlog.String("id", ts.ServerID))
return nil
}
return fmt.Errorf("unable to get the server ID: %w", err)
}