Skip to content

Events tracking

All event types derive from public abstract class AffiseEvent (Runtime/Events/AffiseEvent.cs:8). Native-bridged events inherit from public abstract class NativeEvent : AffiseEvent (Runtime/Events/NativeEvent.cs:8) which sets timestamp via Timestamp.New() (line 19) and category "native" (line 30).

AffiseEvent exposes two send flavors:

  • public void Send()Runtime/Events/AffiseEvent.cs:141
  • public void SendNow(OnSendSuccessCallback success, OnSendFailedCallback failed)Runtime/Events/AffiseEvent.cs:148

Callback delegates:

  • public delegate void OnSendSuccessCallback();Runtime/Events/OnSendSuccessCallback.cs:3
  • public delegate void OnSendFailedCallback(HttpResponse status);Runtime/Events/OnSendFailedCallback.cs:5

Send() — cache event for later scheduled batch send:

AddToCartEvent()
.Send();

SendNow(...) — immediate send with success/failure callbacks. The event is NOT cached for later send if delivery fails.

AddToCartEvent()
.SendNow(() =>
{
// handle event send success
}, (errorResponse) =>
{
// handle event send failed
// Warning: event is NOT cached for later send
}
);

Chain predefined-parameter setters before Send() / SendNow(...):

class Presenter {
void OnUnlockAchievement()
{
var achievement = new JSONObject
{
["achievement"] = "new level",
};
new UnlockAchievementEvent("best damage")
.AddPredefinedParameter(PredefinedLong.USER_SCORE, 12552L)
.AddPredefinedParameter(PredefinedString.ACHIEVEMENT_ID, "1334-1225-ASDZ")
.AddPredefinedParameter(PredefinedObject.CONTENT, achievement)
.Send();
}
}

Overloads for AddPredefinedParameter(...) exist per parameter enum on AffiseEvent at Runtime/Events/AffiseEvent.cs:66,75,84,93,102,111.

The following concrete NativeEvent subclasses live in Runtime/Events/Predefined/:

AchieveLevelEvent, AddPaymentInfoEvent, AddToCartEvent, AddToWishlistEvent, AdRevenueEvent, ClickAdvEvent, CompleteRegistrationEvent, CompleteStreamEvent, CompleteTrialEvent, CompleteTutorialEvent, ContactEvent, ContentItemsViewEvent, CustomId01EventCustomId10Event, CustomizeProductEvent, DeepLinkedEvent, DonateEvent, FindLocationEvent, InitiateCheckoutEvent, InitiatePurchaseEvent, InitiateStreamEvent, InviteEvent, LastAttributedTouchEvent, LeadEvent, ListViewEvent, LoginEvent, OpenedFromPushNotificationEvent, OrderCancelEvent, OrderEvent, OrderItemAddedEvent, OrderItemRemoveEvent, OrderReturnRequestCancelEvent, OrderReturnRequestEvent, PurchaseEvent, RateEvent, ReEngageEvent, ReserveEvent, SalesEvent, ScheduleEvent, SearchEvent, ShareEvent, SpendCreditsEvent, StartRegistrationEvent, StartTrialEvent, StartTutorialEvent, SubmitApplicationEvent, SubscribeEvent, TravelBookingEvent, UnlockAchievementEvent, UnsubscribeEvent, UpdateEvent, ViewAdvEvent, ViewCartEvent, ViewContentEvent, ViewItemEvent, ViewItemsEvent.

Each class is declared public class *Event : NativeEvent at Runtime/Events/Predefined/<Name>.cs:3.

Runtime/Events/Subscription/ defines subscription-lifecycle events:

  • Base: public abstract class BaseSubscriptionEvent (Runtime/Events/Subscription/BaseSubscriptionEvent.cs:7).
  • Activation (SubscriptionActivation.cs): InitialSubscriptionEvent (line 5), InitialTrialEvent (line 20), InitialOfferEvent (line 35).
  • First conversion (SubscriptionFirstConversion.cs): ConvertedTrialEvent (line 5), ConvertedOfferEvent (line 20).
  • Entered billing retry (SubscriptionEnteredBillingRetry.cs): TrialInRetryEvent (line 5), OfferInRetryEvent (line 20), SubscriptionInRetryEvent (line 35).
  • Renewal (SubscriptionRenewal.cs): RenewedSubscriptionEvent (line 5).
  • Cancellation (SubscriptionCancellation.cs): FailedTrialEvent (line 5), FailedOfferiseEvent (line 20), FailedSubscriptionEvent (line 35), FailedTrialFromRetryEvent (line 50), FailedOfferFromRetryEvent (line 65), FailedSubscriptionFromRetryEvent (line 80).
  • Reactivation (SubscriptionReactivation.cs): ReactivatedSubscriptionEvent (line 5).
  • Renewal from billing retry (SubscriptionRenewalFromBillingRetry.cs): ConvertedTrialFromRetryEvent (line 5), ConvertedOfferFromRetryEvent (line 20), RenewedSubscriptionFromRetryEvent (line 35).
  • Unsubscription (Unsubscription.cs): UnsubscriptionEvent (line 6).

Classes in Runtime/Events/Custom/:

  • public class UserCustomEvent : NativeEvent (Runtime/Events/Custom/UserCustomEvent.cs:8) with the constructors:
    • UserCustomEvent(string eventName, string? category = null) — line 13
    • UserCustomEvent(string eventName, string? userData, string? category = null) — line 20
    • UserCustomEvent(string eventName, string? userData, long timeStampMillis, string? category) — line 27
    • InternalAddRawParameters<T>(Dictionary<string, T>?) — line 41
  • public class UserCustomSubscriptionEvent : BaseSubscriptionEvent (Runtime/Events/Custom/UserCustomSubscriptionEvent.cs:8)
  • Predefined CustomId01EventCustomId10Event classes (Runtime/Events/Predefined/CustomId*Event.cs).

Minimal example:

new UserCustomEvent(eventName: "MyCustomEvent")
.Send();

Constant prefix: PredefinedConstants.PREFIX = "affise_p_" (Runtime/Events/Parameters/PredefinedConstants.cs:5).

public enum PredefinedString (Runtime/Events/Parameters/PredefinedString.cs:3).

Members: ACHIEVEMENT_ID, ADREV_AD_TYPE, BRAND, BRICK, CAMPAIGN_ID, CATALOGUE_ID, CHANNEL_TYPE, CITY, CLASS, CLICK_ID, CONTENT_ID, CONTENT_NAME, CONTENT_TYPE, CONVERSION_ID, COUNTRY, COUPON_CODE, CURRENCY, CUSTOMER_SEGMENT, CUSTOMER_TYPE, CUSTOMER_USER_ID, DEEP_LINK, DESCRIPTION, DESTINATION_A, DESTINATION_B, DESTINATION_LIST, EVENT_NAME, NEW_VERSION, OLD_VERSION, ORDER_ID, PARAM_01PARAM_10, PAYMENT_INFO_AVAILABLE, PID, PREFERRED_NEIGHBORHOODS, PRODUCT_ID, PRODUCT_NAME, PURCHASE_CURRENCY, RECEIPT_ID, REGION, REGISTRATION_METHOD, REVIEW_TEXT, SEARCH_STRING, SEGMENT, STATUS, SUBSCRIPTION_ID, SUCCESS, SUGGESTED_DESTINATIONS, SUGGESTED_HOTELS, TUTORIAL_ID, UTM_CAMPAIGN, UTM_MEDIUM, UTM_SOURCE, VALIDATED, VERTICAL, VIRTUAL_CURRENCY_NAME, VOUCHER_CODE, SOURCE, NETWORK, UNIT, PLACEMENT (SOURCE/NETWORK/UNIT/PLACEMENT at lines 69-72).

public enum PredefinedLong (Runtime/Events/Parameters/PredefinedLong.cs:3).

Members: AMOUNT, DATE_A, DATE_B, DEPARTING_ARRIVAL_DATE, DEPARTING_DEPARTURE_DATE, HOTEL_SCORE, LEVEL, MAX_RATING_VALUE, NUM_ADULTS, NUM_CHILDREN, NUM_INFANTS, PREFERRED_NUM_STOPS, PREFERRED_STAR_RATINGS, QUANTITY, RATING_VALUE, RETURNING_ARRIVAL_DATE, RETURNING_DEPARTURE_DATE, SCORE, TRAVEL_START, TRAVEL_END, USER_SCORE, EVENT_START, EVENT_END.

public enum PredefinedFloat (Runtime/Events/Parameters/PredefinedFloat.cs:3).

Members: PREFERRED_PRICE_RANGE, PRICE, REVENUE, LAT, LONG.

public enum PredefinedObject (Runtime/Events/Parameters/PredefinedObject.cs:3).

Members: CONTENT.

public enum PredefinedListObject (Runtime/Events/Parameters/PredefinedListObject.cs:3).

Members: CONTENT_LIST.

public enum PredefinedListString (Runtime/Events/Parameters/PredefinedListString.cs:3).

Members: CONTENT_IDS.

Example combining multiple parameter enums

Section titled “Example combining multiple parameter enums”
class Presenter {
void OnUnlockAchievement()
{
var achievement = new JSONObject
{
["achievement"] = "new level",
};
new UnlockAchievementEvent(
userData: "best damage"
)
.AddPredefinedParameter(PredefinedString.DESCRIPTION, "best damage")
.AddPredefinedParameter(PredefinedObject.CONTENT, achievement)
.Send();
}
}

Affise library will send any pending events with first opportunity, but if there is no network connection or device is disabled, events are kept locally for 7 days before deletion.