CleanInsightsSDK Documentation Beta

Class Campaign

@objcMembers open class Campaign: NSObject, Codable
Campaign Campaign Codable Codable Campaign->Codable NSObject NSObject Campaign->NSObject

Nested Types

Campaign.EventAggregationRule

Conforms To

Codable
NSObject

Initializers

init(start:​end:​aggregation​Period​Length:​number​OfPeriods:​only​Record​Once:​event​Aggregation​Rule:​)

public init(start: Date, end: Date, aggregationPeriodLength: UInt, numberOfPeriods: UInt = 1, onlyRecordOnce: Bool = false, eventAggregationRule: EventAggregationRule = .sum)

init(from:​)

public required init(from decoder: Decoder) throws

Properties

start

let start: Date

The start of the campaign. (inclusive)

end

let end: Date

The end of the campaign. (inclusive)

aggregation​Period​Length

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.

number​OfPeriods

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.

only​Record​Once

let onlyRecordOnce: Bool

Will result in recording only the first time a visit or event happened per period. Useful for yes/no questions.

event​Aggregation​Rule

let eventAggregationRule: EventAggregationRule

The rule how to aggregate the value of an event (if any given) with subsequent calls.

current​Measurement​Period

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, will return nil.

The first period is defined as aggregationPeriodLength number of days after the start of the campaign.

next​Total​Measurement​Period

var nextTotalMeasurementPeriod: (start: Date, end: Date)?

aggregation​Period

var aggregationPeriod: TimeInterval

description

var description: String

Methods

apply(value:​to:​)

open func apply(value: Double?, to event: Event)

Apply the eventAggregationRule to the given event with the given value.

Parameters

value Double?

The value to apply.

event Event

The event to apply the value to.