Spotify track ID that was skipped
Decimal progress through the track when skipped (0.0-1.0)
// Record a skip for pattern analysis
if (skipResult.isSkip) {
recordSkipForPatternAnalysis(
previousState.currentTrackId,
previousState.lastProgress / previousState.currentTrackDuration
);
}
export function recordSkipForPatternAnalysis(
trackId: string,
progress: number,
): void {
// Add to the beginning of the array (most recent first)
recentSkips.unshift({
trackId,
timestamp: Date.now(),
progress,
});
// Limit the size of the array
if (recentSkips.length > MAX_RECENT_SKIPS) {
recentSkips.pop();
}
// Update consecutive quick skips counter
if (progress < QUICK_SKIP_THRESHOLD) {
consecutiveQuickSkips++;
// Detect "skipping through playlist" behavior
if (consecutiveQuickSkips >= AGGRESSIVE_SKIP_PATTERN_THRESHOLD) {
store.saveLog(
`Detected rapid skipping pattern (${consecutiveQuickSkips} consecutive quick skips)`,
"INFO",
);
}
} else {
// Reset counter if not a quick skip
consecutiveQuickSkips = 0;
}
}
Records a skip event for pattern analysis
Adds a skip event to the pattern analysis system, which tracks recent skip behavior to identify patterns like rapid skipping through a playlist or repeated skipping of similar content.
This function maintains a record of recent skips and identifies patterns like consecutive quick skips that may indicate user dissatisfaction or searching behavior.