DecayDetector
The DecayDetector analyzes stored search analytics data to identify pages with declining performance.
Constructor
import { DecayDetector } from '@pagebridge/core'
// With default rules
const detector = new DecayDetector(db)
// With custom rules
const detector = new DecayDetector(db, [
{
type: 'position_decay',
threshold: 5,
minImpressions: 200,
comparisonWindowDays: 14,
sustainedDays: 7
},
{
type: 'low_ctr',
threshold: 0.02,
minImpressions: 500,
comparisonWindowDays: 28,
sustainedDays: 7
}
])detectDecay(siteId, publishedDates, quietPeriod?)
Runs all configured detection rules and returns an array of decay signals.
// publishedDates: Map of page URL -> publish date
// Used for quiet period filtering
const publishedDates = new Map([
['https://example.com/blog/post-1', new Date('2025-01-15')],
['https://example.com/blog/post-2', new Date('2024-11-01')]
])
const signals = await detector.detectDecay(
'sc-domain:example.com',
publishedDates,
{ days: 45 } // quiet period config
)
// signals: DecaySignal[]DecaySignal
interface DecaySignal {
page: string
reason: 'position_decay' | 'low_ctr' | 'impressions_drop'
severity: 'low' | 'medium' | 'high'
metrics: {
positionBefore: number
positionNow: number
positionDelta: number
ctrBefore: number
ctrNow: number
impressions: number
}
}Default rules
See Decay Detection concepts for default threshold values and a detailed explanation of each rule.
DecayRule type
interface DecayRule {
type: 'position_decay' | 'low_ctr' | 'impressions_drop'
threshold: number
minImpressions: number
comparisonWindowDays: number
sustainedDays: number
}