umami icon indicating copy to clipboard operation
umami copied to clipboard

Fix multiple issues: export empty datasets, reset large data, geo-location tracking, and timezone consistency

Open Ayush3603 opened this issue 1 month ago • 3 comments

Fixes Multiple Issues

This PR addresses several open issues in the Umami project:

1. Issue #3699: 🧩 UX – Prevent exporting empty datasets & display a warning message

Problem: When there is no data available in the dashboard, clicking the "Download" button still triggers a file download, resulting in empty CSV files.

Solution:

  • Modified the export API route to check if all datasets are empty before creating the zip file
  • Returns { error: 'no_data' } when no data is available
  • Modified the ExportButton component to handle the new error response and display a user-friendly toast message
  • Maintains existing functionality when data is available

2. Issue #3698: Cannot reset large data

Problem: Resetting websites with large amounts of data causes transaction timeouts with error: "A rollback cannot be executed on an expired transaction"

Solution:

  • Modified the resetWebsite function to delete data in batches of 10,000 records
  • Prevents transaction timeouts by processing large datasets incrementally
  • Follows the batch data deletion pattern to avoid memory issues

3. Issue #3701: Geo-location tracking (Country) broken in v3.0

Problem: Country tracking showing "Unknown" for majority of visitors after upgrading to v3.0

Solution:

  • Enhanced the getLocation function to try multiple sources for country code (country, registered_country, represented_country, continent)
  • Added better error handling and logging
  • Ensures location data is returned only when at least a country code is available

4. Issue #3700: Chart timezone is different from realtime page

Problem: Chart and realtime page showing data in different timezones

Solution:

  • Modified the getRealtimeData function to ensure consistent timezone usage
  • Passes timezone parameters to all stats functions to maintain data consistency
  • Follows the timezone consistency pattern across all API layers

Testing

  • Added unit tests for all modified functions
  • Verified that existing functionality remains intact
  • Tested edge cases and error conditions

Benefits

  • Improves user experience by providing clear feedback
  • Prevents downloading empty files and transaction timeouts
  • Fixes critical geo-location tracking issue
  • Ensures consistent timezone handling across the application
  • Maintains backward compatibility

Fixes #3699 Fixes #3698 Fixes #3701 Fixes #3700

Ayush3603 avatar Nov 08 '25 18:11 Ayush3603

@Ayush3603 is attempting to deploy a commit to the umami-software Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 08 '25 18:11 vercel[bot]

This looks great! But can you address the issues brought up by Greptile?

mikecao avatar Nov 08 '25 19:11 mikecao

Sure

Ayush3603 avatar Nov 10 '25 12:11 Ayush3603