DEV: Add new chat metrics (#23872)

This adds the following chat metrics:

- _chat_open_channels_with_threads_enabled_ — a count of open channels 
where threading is enabled.
- _chat_channel_messages_ — a count of messages sent in a chat channel 
(i.e. not a personal chat / direct message), within a thread or outside of a thread.
- _chat_threaded_messages_ — a count of messages sent within a thread 
in a chat channel (i.e. not a personal chat / direct messages).
- _chat_direct_messages_ — a count of messages sent in a personal chat / direct messages.

The metrics added using the plugin API introduced in 098ab29d, 
and extended in d91456fd.

Note that these stats won't be exposed at the `about.json` 
and the `site/statistics.json` routes.
This commit is contained in:
Andrei Prigorshnev
2024-01-04 16:10:03 +04:00
committed by GitHub
parent b43bba7dd7
commit 93ca13e534
3 changed files with 271 additions and 2 deletions

View File

@ -489,10 +489,15 @@ after_initialize do
register_stat("chat_messages", show_in_ui: true, expose_via_api: true) do
Chat::Statistics.about_messages
end
register_stat("chat_users", expose_via_api: true) { Chat::Statistics.about_users }
register_stat("chat_channels", expose_via_api: true) { Chat::Statistics.about_channels }
register_stat("chat_users", expose_via_api: true) { Chat::Statistics.about_users }
register_stat("chat_channel_messages") { Chat::Statistics.channel_messages }
register_stat("chat_direct_messages") { Chat::Statistics.direct_messages }
register_stat("chat_open_channels_with_threads_enabled") do
Chat::Statistics.open_channels_with_threads_enabled
end
register_stat("chat_threaded_messages") { Chat::Statistics.threaded_messages }
# Make sure to update spec/system/hashtag_autocomplete_spec.rb when changing this.
register_hashtag_data_source(Chat::ChannelHashtagDataSource)