:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { CrawlHistoryItem, CrawlHistoryStore } from './crawl-history'
/** A v2 or v3 reference carries its dataset version, so the two never share a frontier entry. */
const SCOPED_URL_REF = /^imageurl:v[23]:/
export class VersionedCrawlHistory implements CrawlHistoryStore {
constructor(
private readonly legacy: CrawlHistoryStore,
private readonly v3: CrawlHistoryStore
) {}
public async read(keys: string[]): Promise<Map<string, CrawlHistoryItem>> {
const scoped = keys.filter((key) => SCOPED_URL_REF.test(key))
const legacy = keys.filter((key) => !SCOPED_URL_REF.test(key))
const results = await Promise.all([this.legacy.read(legacy), this.v3.read(scoped)])
return new Map(results.flatMap((result) => [...result]))
}
public async write(items: CrawlHistoryItem[]): Promise<void> {
await Promise.all([
this.legacy.write(items.filter((item) => !SCOPED_URL_REF.test(item.key))),
this.v3.write(items.filter((item) => SCOPED_URL_REF.test(item.key))),
])
}
}