import dayjs from 'dayjs' export const EXPLORER_BANNER_EXPOSURE_INTERVAL_DAYS = 7 /** * The exposure event is sent at most once per interval per browser. A missing or unparseable * timestamp, or one in the future (e.g. after a clock change), counts as due so the event * can't be suppressed indefinitely. */ export const isExplorerBannerExposureDue = ( lastTrackedAt: string | null | undefined, now: dayjs.ConfigType = dayjs() ) => { if (typeof lastTrackedAt !== 'string') return true const lastTracked = dayjs(lastTrackedAt) if (!lastTracked.isValid()) return true const daysSince = dayjs(now).diff(lastTracked, 'day', true) return daysSince < 0 || daysSince >= EXPLORER_BANNER_EXPOSURE_INTERVAL_DAYS }