Skip to content

Events tracking

Every event extends abstract class Event : PredefinedParameter (attribution/src/main/java/com/affise/attribution/events/Event.kt:18). Predefined event classes extend NativeEvent (attribution/src/main/java/com/affise/attribution/events/NativeEvent.kt:9-12, category "native") and carry a name from the EventName enum (attribution/src/main/java/com/affise/attribution/events/EventName.kt:3-69).

Every predefined event class has a @JvmOverloads constructor constructor(userData: String? = null, timeStampMillis: Long = timestamp()).

class Presenter {
fun onUserAddsItemsToCart(userData: String) {
AddToCartEvent(userData)
.send() // Send event
}
}

Two dispatch APIs are defined on Event:

  • fun send() — stores + schedules (Event.kt:136-138).
  • fun sendNow(success: OnSendSuccessCallback, failed: OnSendFailedCallback) — no retry if failed (Event.kt:143-145).

Callbacks:

  • fun interface OnSendSuccessCallback { fun handle() } (OnSendSuccessCallback.kt:3-5)
  • fun interface OnSendFailedCallback { fun handle(status: HttpResponse) } (OnSendFailedCallback.kt:5-7)
AddToCartEvent()
.send()
AddToCartEvent()
.sendNow({
// handle event send success
}) { errorResponse ->
// handle event send failed
// Warning: event is NOT cached for later send
}

All at attribution/src/main/java/com/affise/attribution/events/predefined/ unless noted. Each class extends NativeEvent.

AchieveLevelEvent, AddPaymentInfoEvent, AddToCartEvent, AddToWishlistEvent, AdRevenueEvent, ClickAdvEvent, CompleteRegistrationEvent, CompleteStreamEvent, CompleteTrialEvent, CompleteTutorialEvent, ContactEvent, ContentItemsViewEvent, CustomizeProductEvent, DeepLinkedEvent, DonateEvent, FindLocationEvent, InitiateCheckoutEvent, InitiatePurchaseEvent, InitiateStreamEvent, InviteEvent, LastAttributedTouchEvent, LeadEvent, ListViewEvent, LoginEvent, OpenedFromPushNotificationEvent.

OrderEvent, OrderItemAddedEvent, OrderItemRemoveEvent, OrderCancelEvent, OrderReturnRequestEvent, OrderReturnRequestCancelEvent.

PurchaseEvent, FailedPurchaseEvent, RateEvent, ReEngageEvent, ReserveEvent, SalesEvent, ScheduleEvent, SearchEvent, ShareEvent, SpendCreditsEvent, StartRegistrationEvent, StartTrialEvent, StartTutorialEvent, SubmitApplicationEvent, SubscribeEvent, TravelBookingEvent, UnlockAchievementEvent, UnsubscribeEvent, UpdateEvent, ViewAdvEvent, ViewCartEvent, ViewContentEvent, ViewItemEvent, ViewItemsEvent.

Full list + file:line source refs: see README and the events/predefined/ package.

Under attribution/src/main/java/com/affise/attribution/events/subscription/:

  • InitialSubscriptionEventsubscription/SubscriptionActivation.kt:8
  • InitialTrialEventsubscription/SubscriptionActivation.kt:27
  • InitialOfferEventsubscription/SubscriptionActivation.kt:46
  • ConvertedTrialEventsubscription/SubscriptionFirstConversion.kt:8
  • ConvertedOfferEventsubscription/SubscriptionFirstConversion.kt:27
  • TrialInRetryEventsubscription/SubscriptionEnteredBillingRetry.kt:8
  • OfferInRetryEventsubscription/SubscriptionEnteredBillingRetry.kt:27
  • SubscriptionInRetryEventsubscription/SubscriptionEnteredBillingRetry.kt:46
  • RenewedSubscriptionEventsubscription/SubscriptionRenewal.kt:8
  • FailedSubscriptionFromRetryEventsubscription/SubscriptionCancellation.kt:103
  • FailedOfferFromRetryEventsubscription/SubscriptionCancellation.kt:84
  • FailedTrialFromRetryEventsubscription/SubscriptionCancellation.kt:65
  • FailedSubscriptionEventsubscription/SubscriptionCancellation.kt:46
  • FailedOfferiseEventsubscription/SubscriptionCancellation.kt:27
  • FailedTrialEventsubscription/SubscriptionCancellation.kt:8
  • ReactivatedSubscriptionEventsubscription/SubscriptionReactivation.kt:8
  • RenewedSubscriptionFromRetryEventsubscription/SubscriptionRenewalFromBillingRetry.kt:46
  • ConvertedOfferFromRetryEventsubscription/SubscriptionRenewalFromBillingRetry.kt:27
  • ConvertedTrialFromRetryEventsubscription/SubscriptionRenewalFromBillingRetry.kt:8
  • UnsubscriptionEventsubscription/Unsubscription.kt:8

Classes CustomId01EventCustomId10Event live under events/predefined/ and are bound to EventName.CUSTOM_ID_01..10 (EventName.kt:16-25).

class UserCustomEvent(
eventName: String,
userData: String? = null,
timeStampMillis: Long = timestamp(),
category: String? = null,
) : NativeEvent(...)

(attribution/src/main/java/com/affise/attribution/events/custom/UserCustomEvent.kt:13-24)

UserCustomEvent("MyCustomNameEvent")
.addPredefinedParameter(PredefinedString.DESCRIPTION, "best before 2029")
.addPredefinedParameter(PredefinedObject.CONTENT, JSONObject().apply {
put("collection", "Greatest Hits")
})
.send() // Send event

Events accept additional typed parameters via Event.addPredefinedParameter(...) overloads (Event.kt:72-115). Base interface chain: PredefinedParameter : PredefinedSimple (attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedParameter.kt:6).

class Presenter {
fun onUserAddsItemsToCart(userData: String) {
AddToCartEvent(userData)
.addPredefinedParameter(PredefinedString.DESCRIPTION, "best before 2029")
.addPredefinedParameter(PredefinedObject.CONTENT, JSONObject().apply {
put("collection", "Greatest Hits")
})
.addPredefinedParameter(PredefinedListObject.CONTENT_LIST, listOf(
JSONObject().apply {
put("content", "songs, videos")
}
))
.send() // Send event
}
}

attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedString.kt:8-80.

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, NETWORK, OLD_VERSION, ORDER_ID, ORIGINAL_ORDER_ID, PARAM_01PARAM_10, PAYMENT_INFO_AVAILABLE, PID, PLACEMENT, PREFERRED_NEIGHBORHOODS, PRODUCT_ID, PRODUCT_NAME, PRODUCT_TYPE, PURCHASE_CURRENCY, RECEIPT_ID, REGION, REGISTRATION_METHOD, REVIEW_TEXT, SEARCH_STRING, SEGMENT, SOURCE, STATUS, SUBSCRIPTION_ID, SUBSCRIPTION_TYPE, SUCCESS, SUGGESTED_DESTINATIONS, SUGGESTED_HOTELS, TUTORIAL_ID, UNIT, UTM_CAMPAIGN, UTM_MEDIUM, UTM_SOURCE, VALIDATED, VERTICAL, VIRTUAL_CURRENCY_NAME, VOUCHER_CODE.

attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedLong.kt:8-31.

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.

attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedFloat.kt:8-13.

PREFERRED_PRICE_RANGE, PRICE, REVENUE, LAT, LONG.

attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedObject.kt:8-9 — single value CONTENT.

attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedListObject.kt:8-9 — single value CONTENT_LIST.

attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedListString.kt:8-9 — single value CONTENT_IDS.

Event.customPredefined(): PredefinedCustom (Event.kt:162-164) exposes PredefinedCustom.conversionId(orderId: String, productId: String): String (attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedCustom.kt:7-13). It sets PredefinedString.ORDER_ID, PredefinedString.PRODUCT_ID, and PredefinedString.CONVERSION_ID (as "${orderId}_${productId}").

val event = AddToCartEvent()
val conversionId = event.customPredefined().conversionId("ORDER_ID", "PRODUCT_ID")
event.send() // Send event

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.

There is no direct public API to tune this buffering window.