pub struct Campaign {
    pub start: DateTime<Utc>,
    pub end: DateTime<Utc>,
    pub aggregation_period_length: u32,
    pub number_of_periods: u32,
    pub only_record_once: bool,
    pub event_aggregation_rule: EventAggregationRule,
    pub strengthen_anonymity: bool,
}

Fields§

§start: DateTime<Utc>

The start of the campaign. (inclusive)

§end: DateTime<Utc>

The end of the campaign. (inclusive)

§aggregation_period_length: u32

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_of_periods: u32

The number of periods you want to measure in a row. Therefore the total length in days you measure one user is aggregation_period_length * number_of_periods beginning with the first day of the next period after the user consented.

§only_record_once: bool

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

§event_aggregation_rule: EventAggregationRule

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

§strengthen_anonymity: bool

Implementations§

source§

impl Campaign

source

pub fn new( start: DateTime<Utc>, end: DateTime<Utc>, aggregation_period_length: u32 ) -> Campaign

Returns a campaign with the given start, end and aggregation_period_length and sane defaults for the other properties.

Arguments
  • start: The start of the campaign. (inclusive)
  • end: The end of the campaign. (inclusive)
  • aggregation_period_length: 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.
Defaults:
  • number_of_periods: 1.
  • only_record_once: false.
  • event_aggregation_rule: Sum.
source

pub fn default_number_of_periods() -> u32

source

pub fn default_only_record_once() -> bool

source

pub fn default_event_aggregation_rule() -> EventAggregationRule

source

pub fn default_strengthen_anonymity() -> bool

source

pub fn aggregation_period(&self) -> Duration

source

pub fn current_measurement_period( &self ) -> Option<(DateTime<Utc>, DateTime<Utc>)>

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 None.

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

source

pub fn next_total_measurement_period( &self ) -> Option<(DateTime<Utc>, DateTime<Utc>)>

source

pub fn apply(&self, value: Option<f64>, event: &mut Event)

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

Arguments
  • value: The value to apply.
  • event: The event to apply the value to.

Trait Implementations§

source§

impl Clone for Campaign

source§

fn clone(&self) -> Campaign

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Campaign

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Campaign

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<Campaign> for Campaign

source§

fn eq(&self, other: &Campaign) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Campaign

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Campaign

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,