Skip to content

Commit

Permalink
fix: add usage stats for dynamic menu entries
Browse files Browse the repository at this point in the history
Fixes: #20209
  • Loading branch information
tltv committed Oct 10, 2024
1 parent 2d42aad commit f05575f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.internal.UsageStatistics;
import com.vaadin.flow.internal.menu.MenuRegistry;
import com.vaadin.flow.router.HasDynamicTitle;
import com.vaadin.flow.router.PageTitle;
Expand All @@ -38,13 +39,16 @@
*/
public final class MenuConfiguration {

private static final String STATISTICS_DYNAMIC_MENU_ENTRIES = "flow/dynamic-menu-entries";

/**
* Collect ordered list of menu entries for menu population. All client
* views are collected and any accessible server views.
*
* @return ordered list of {@link MenuEntry} instances
*/
public static List<MenuEntry> getMenuEntries() {
UsageStatistics.markAsUsed(STATISTICS_DYNAMIC_MENU_ENTRIES, null);
return MenuRegistry.collectMenuItemsList().stream()
.map(MenuConfiguration::createMenuEntry).toList();
}
Expand All @@ -59,6 +63,7 @@ public static List<MenuEntry> getMenuEntries() {
* @return ordered list of {@link MenuEntry} instances
*/
public static List<MenuEntry> getMenuEntries(Locale locale) {
UsageStatistics.markAsUsed(STATISTICS_DYNAMIC_MENU_ENTRIES, null);
return MenuRegistry.collectMenuItemsList(locale).stream()
.map(MenuConfiguration::createMenuEntry).toList();
}
Expand Down

0 comments on commit f05575f

Please sign in to comment.