Spotify track ID that is now playing
Human-readable name of the track
Name of the artist performing the track
// Log when a new track starts playing
logNowPlaying(
'spotify:track:1234567890',
'Bohemian Rhapsody',
'Queen'
);
export function logNowPlaying(
trackId: string,
trackName: string,
artistName: string,
): void {
// Avoid logging the same track multiple times in quick succession
const lastLogged = getTrackLastLogged(trackId);
const now = Date.now();
// If we've logged this track in the last 3 seconds, don't log again
if (now - lastLogged < 3000) {
return;
}
// Record that we've logged this track
setTrackLastLogged(trackId, now);
// Log the track information
store.saveLog(`Now playing: "${trackName}" by ${artistName}`, "INFO");
}
Logs information about the currently playing track
Records and logs information about the track that is currently playing, avoiding duplicate logging of the same track within a short time period. This function is used to maintain a clean record of tracks as they begin playing for monitoring and analysis purposes.