@objcMembers open class Campaign: NSObject, Codable
public init(start: Date, end: Date, aggregationPeriodLength: UInt, numberOfPeriods: UInt = 1, onlyRecordOnce: Bool = false, eventAggregationRule: EventAggregationRule = .sum)
public required init(from decoder: Decoder) throws
let start: Date
The start of the campaign. (inclusive)
let end: Date
The end of the campaign. (inclusive)
let aggregationPeriodLength: UInt
The length of the aggregation period in number of days. At the end of a period, the aggregated data will be sent to the analytics server.
let numberOfPeriods: UInt
The number of periods you want to measure in a row. Therefore the total length in days you measure
one user is
aggregationPeriodLength * numberOfPeriods beginning with the first
day of the next period after the user consented.
let onlyRecordOnce: Bool
Will result in recording only the first time a visit or event happened per period. Useful for yes/no questions.
let eventAggregationRule: EventAggregationRule
The rule how to aggregate the value of an event (if any given) with subsequent calls.
var currentMeasurementPeriod: (start: Date, end: Date)?
Returns the current measurement period, aka. the period where NOW is in.
If NOW is outside any possible period, because the campaign hasn't started, yet, or already ended,
The first period is defined as
aggregationPeriodLength number of days after the
of the campaign.
var nextTotalMeasurementPeriod: (start: Date, end: Date)?
var aggregationPeriod: TimeInterval
var description: String
open func apply(value: Double?, to event: Event)
eventAggregationRule to the given event with the given value.
The value to apply.
The event to apply the value to.