StoredFrequencyCapPolicy constructor
StoredFrequencyCapPolicy({
- required KeyValueStore store,
- required Map<
String, FrequencyCap> slotCaps, - required FrequencyCap globalCap,
- Set<
String> globalCapExemptSlots = const {}, - DateTime now()?,
Creates a policy.
slotCaps maps slot names (e.g. 'interstitial', 'app_open') to
their caps; slots without an entry are limited only by globalCap.
globalCapExemptSlots are slots whose shows the globalCap may not
block — but whose impressions it still records (ADR-039). This is what
separates the two jobs the global cap was doing: pacing involuntary
ads (an interstitial or app-open the user never asked for) is its real
purpose; blocking an ad the user explicitly tapped "watch for a reward"
on is not. AdFlow exempts the classic rewarded slot (the rewarded
interstitial is NOT exempt — its intro is an app-chosen interruption).
Implementation
StoredFrequencyCapPolicy({
required KeyValueStore store,
required Map<String, FrequencyCap> slotCaps,
required FrequencyCap globalCap,
Set<String> globalCapExemptSlots = const {},
DateTime Function()? now,
}) : _store = store,
_slotCaps = Map.of(slotCaps),
_globalCap = globalCap,
_globalCapExemptSlots = Set.of(globalCapExemptSlots),
_now = now ?? DateTime.now;