Writes the complete statistics data structure to a JSON file in the application's
user data directory. The function handles proper serialization of complex data
structures (like Sets) and updates the lastUpdated timestamp.
The function performs several important operations:
Ensures the data directory exists before attempting to write
Updates the lastUpdated timestamp to the current time
Converts Set objects to arrays for proper JSON serialization
Formats JSON with proper indentation for readability
Handles error conditions gracefully
Example
// Update and save statistics after processing a skipped track conststats = awaitgetStatistics(); stats.totalSkips++; stats.overallSkipRate = stats.totalSkips / stats.totalPlays; awaitsaveStatistics(stats);
Saves statistics data to persistent storage
Writes the complete statistics data structure to a JSON file in the application's user data directory. The function handles proper serialization of complex data structures (like Sets) and updates the lastUpdated timestamp.
The function performs several important operations:
Example
Source