DEV: Deprecate show_in_ui argument of the register_stat API (#28727)

We need to start printing deprecation notices when the `show_in_ui` argument is used because it works only for the old about page which will be removed soon. For the new about page, we've introduced a new API `addAboutPageActivity` which is more flexible than a true/false argument on the server side.

Internal topic: t/136551.
This commit is contained in:
Osama Sayegh
2024-09-04 19:58:14 +03:00
committed by GitHub
parent e6edd52047
commit a23773f83d
7 changed files with 63 additions and 29 deletions

View File

@ -1122,9 +1122,24 @@ class Plugin::Instance
# table. Some stats may be needed purely for reporting purposes and thus
# do not need to be shown in the UI to admins/users.
#
# TODO(osama): deprecate show_in_ui when experimental_redesigned_about_page_groups
# is removed
def register_stat(name, show_in_ui: false, expose_via_api: false, &block)
# TODO(osama): remove show_in_ui when experimental_redesigned_about_page_groups is removed
def register_stat(
name,
show_in_ui: (
not_using_deprecated_arg = true
false
),
expose_via_api: false,
&block
)
if !not_using_deprecated_arg
Discourse.deprecate(
"`show_in_ui` argument of the `register_stat` API is deprecated. Please use the `addAboutPageActivity` JS API instead if you want your custom stat to be shown on the about page.",
since: "3.4.0.beta2",
drop_from: "3.5.0.beta1",
)
end
# We do not want to register and display the same group multiple times.
return if DiscoursePluginRegistry.stats.any? { |stat| stat.name == name }