Add platform information for push notification metrics (#27460)

* Add platform information for push notification metrics

* Address feedback

* Add the client platform returned by the devices to the normalize function

* Add "no platform" platform label to distinguish from unknown
Этот коммит содержится в:
Daniel Espino García
2024-07-05 09:34:01 +02:00
коммит произвёл GitHub
родитель 6bbf7bbb9f
Коммит e5a3dd7fea
15 изменённых файлов: 122 добавлений и 105 удалений

Просмотреть файл

@@ -357,7 +357,7 @@ func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel
if rpost.RootId != "" {
if appErr := a.ResolvePersistentNotification(c, parentPostList.Posts[post.RootId], rpost.UserId); appErr != nil {
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeWebsocket, model.NotificationReasonResolvePersistentNotificationError)
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeWebsocket, model.NotificationReasonResolvePersistentNotificationError, model.NotificationNoPlatform)
a.NotificationsLog().Error("Error resolving persistent notification",
mlog.String("sender_id", rpost.UserId),
mlog.String("post_id", post.RootId),
@@ -488,7 +488,7 @@ func (a *App) handlePostEvents(c request.CTX, post *model.Post, user *model.User
if channel.TeamId != "" {
t, err := a.Srv().Store().Team().Get(channel.TeamId)
if err != nil {
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError)
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError, model.NotificationNoPlatform)
a.NotificationsLog().Error("Missing team",
mlog.String("post_id", post.Id),
mlog.String("status", model.NotificationStatusError),
@@ -783,7 +783,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(c request.CTX, post *model.P
}
if !model.IsValidId(previewedPostID) {
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonParseError)
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonParseError, model.NotificationNoPlatform)
a.NotificationsLog().Error("Invalid post prop id for permalink post",
mlog.String("type", model.NotificationTypeWebsocket),
mlog.String("post_id", post.Id),
@@ -798,7 +798,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(c request.CTX, post *model.P
previewedPost, err := a.GetSinglePost(c, previewedPostID, false)
if err != nil {
if err.StatusCode == http.StatusNotFound {
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError)
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError, model.NotificationNoPlatform)
a.NotificationsLog().Error("permalink post not found",
mlog.String("type", model.NotificationTypeWebsocket),
mlog.String("post_id", post.Id),
@@ -815,7 +815,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(c request.CTX, post *model.P
userIDs, nErr := a.Srv().Store().Channel().GetAllChannelMemberIdsByChannelId(post.ChannelId)
if nErr != nil {
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError)
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError, model.NotificationNoPlatform)
a.NotificationsLog().Error("Cannot get channel members",
mlog.String("type", model.NotificationTypeWebsocket),
mlog.String("post_id", post.Id),
@@ -830,7 +830,7 @@ func (a *App) publishWebsocketEventForPermalinkPost(c request.CTX, post *model.P
permalinkPreviewedChannel, err := a.GetChannel(c, previewedPost.ChannelId)
if err != nil {
if err.StatusCode == http.StatusNotFound {
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError)
a.CountNotificationReason(model.NotificationStatusError, model.NotificationTypeAll, model.NotificationReasonFetchError, model.NotificationNoPlatform)
a.NotificationsLog().Error("Cannot get channel",
mlog.String("type", model.NotificationTypeWebsocket),
mlog.String("post_id", post.Id),