diff --git a/src/dev-center/js/dev-center.js b/src/dev-center/js/dev-center.js index ec87bd13f..ccbcba1e1 100644 --- a/src/dev-center/js/dev-center.js +++ b/src/dev-center/js/dev-center.js @@ -507,6 +507,7 @@ function generate_edit_app_section(app) {
@@ -623,6 +624,35 @@ function generate_edit_app_section(app) {
+
+ + +
+

Users

+
+
+
+

Opens

+
+
+
` return h; } @@ -758,7 +788,8 @@ async function edit_app_section(cur_app_name) { $('.tab-btn').removeClass('active'); $('.tab-btn[data-tab="apps"]').addClass('active'); - let cur_app = await puter.apps.get(cur_app_name, {icon_size: 128}); + let cur_app = await puter.apps.get(cur_app_name, {icon_size: 128, stats_period: 'today'}); + currently_editing_app = cur_app; // generate edit app section @@ -768,6 +799,11 @@ async function edit_app_section(cur_app_name) { toggleResetButton(); // Ensure Reset button is initially disabled $('#edit-app').show(); + // analytics + $('#analytics-users .count').html(cur_app.stats.user_count); + $('#analytics-opens .count').html(cur_app.stats.open_count); + + // get analytics const filetype_association_input = document.querySelector('textarea[id=edit-app-filetype-associations]'); let tagify = new Tagify(filetype_association_input, { pattern: /\.(?:[a-z0-9]+)|(?:[a-z]+\/(?:[a-z0-9.-]+|\*))/, @@ -2777,4 +2813,11 @@ $(document).on('click', '.copy-app-uid', function(e) { setTimeout(() => { $(this).html(copy_svg); }, 2000); -}); \ No newline at end of file +}); + +$(document).on('change', '#analytics-period', async function(e) { + const app = await puter.apps.get(currently_editing_app.name, { icon_size: 64, stats_period: $(this).val() }); + + $('#analytics-users .count').html(number_format(app.stats.user_count)); + $('#analytics-opens .count').html(number_format(app.stats.open_count)); +}) \ No newline at end of file